TestCrashLog.java
2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.dianping.cat.demo;
import java.util.Random;
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 {
while (true) {
for (int i = 0; i < 10; i++) {
Transaction t = Cat.newTransaction("AndroidCrashLog", "crashLog");
Cat.logEvent("Error", "AndroidCrashLogTest1", "ERROR", "Crash log detail stack info A !");
Cat.logEvent("Error", "AndroidCrashLogTest2", "ERROR", "Crash log detail stack info B !");
String plateform = getPlateform("Android", i);
String version = getVersion("Android", i);
String moudle = getModule("Android", i);
String level = getLevel("Android", i);
MessageTree tree = Cat.getManager().getThreadLocalMessageTree();
((DefaultMessageTree) tree).setIpAddress(version + ":" + plateform + ":" + moudle + ":" + level);
((DefaultMessageTree) tree).setDomain("AndroidCrashLog");
t.complete();
Transaction t2 = Cat.newTransaction("iOSCrashLog", "crashLog");
Cat.logEvent("Exception", "iOSCrashLogTest1", "ERROR", "Crash log detail stack info A !");
Cat.logEvent("Exception", "iOSCrashLogTest2", "ERROR", "Crash log detail stack info B !");
String plateform2 = getPlateform("iOS", i);
String version2 = getVersion("iOS", i);
String moudle2 = getModule("iOS", i);
String level2 = getLevel("iOS", i);
MessageTree tree2 = Cat.getManager().getThreadLocalMessageTree();
((DefaultMessageTree) tree2).setIpAddress(version2 + ":" + plateform2 + ":" + moudle2 + ":" + level2);
((DefaultMessageTree) tree2).setDomain("iOSCrashLog");
t2.complete();
}
Thread.sleep(10000);
// code nullpoint
}
}
private String getLevel(String platform, int index) {
return platform + "Level" + new Random().nextInt(20);
}
private String getModule(String platform, int index) {
return platform + "Module" + new Random().nextInt(20);
}
private String getPlateform(String platform, int index) {
return platform + new Random().nextInt(20);
}
private String getVersion(String platform, int index) {
return platform + "Version" + new Random().nextInt(20);
}
}