Package com.dianping.cat.demo

Source Code of com.dianping.cat.demo.TestCrashLog

package com.dianping.cat.demo;

import org.junit.Test;

import com.dianping.cat.Cat;
import com.dianping.cat.message.Transaction;
import com.dianping.cat.message.spi.MessageTree;
import com.dianping.cat.message.spi.internal.DefaultMessageTree;

public class TestCrashLog {

  @Test
  public void test() throws InterruptedException {
    for (int i = 0; i < 100; i++) {
      Transaction t = Cat.newTransaction("url", "crash");

      String message = parse(i);

      Cat.logEvent("Exception", message, "ERROR", "sdf");

      String plateform = getPlateform(i);
      String version = getVersion(i);

      MessageTree tree = Cat.getManager().getThreadLocalMessageTree();
      ((DefaultMessageTree) tree).setIpAddress(plateform + ":" + version);
      ((DefaultMessageTree) tree).setDomain("CrashLogWeb");
      t.complete();
    }
    Thread.sleep(10000);
    // code nullpoint
  }

  private String parse(int index) {
    return "message" + index % 3;
  }

  private String getPlateform(int index) {
    return "andriod" + index % 4;
  }

  private String getVersion(int index) {
    return "version" + index % 3;
  }

}
TOP

Related Classes of com.dianping.cat.demo.TestCrashLog

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.