-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.java
More file actions
51 lines (43 loc) · 1.41 KB
/
Copy pathLog.java
File metadata and controls
51 lines (43 loc) · 1.41 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
/*
* Copyright (c) 2020 Copyright bp All Rights Reserved.
* Author: pengxiang.li
* Desc:
*/
package cn.brainpoint.febs;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.contrib.java.lang.system.SystemErrRule;
import org.junit.contrib.java.lang.system.SystemOutRule;
/**
* @author pengxiang.li
*/
public class Log {
// 正确输出
@Rule
protected final static SystemOutRule logOut = new SystemOutRule();
// 错误输出
@Rule
protected final static SystemErrRule logErr = new SystemErrRule();
public static void out(String fmt, Object... args) {
String tid = "[tid: " + Thread.currentThread().getId() + "] ";
System.out.printf(tid + fmt.concat("\r\n"), args);
logOut.getLog();
}
public static void out(String msg) {
String tid = "[tid: " + Thread.currentThread().getId() + "] ";
System.out.print(tid + msg.concat("\r\n"));
logOut.getLog();
}
public static void err(String fmt, Object... args) {
String tid = "[tid: " + Thread.currentThread().getId() + "] ";
System.err.printf(tid + fmt.concat("\r\n"), args);
logErr.getLog();
Assert.fail(String.format(fmt, args));
}
public static void err(String msg) {
String tid = "[tid: " + Thread.currentThread().getId() + "] ";
System.err.print(tid + msg.concat("\r\n"));
logErr.getLog();
Assert.fail(msg);
}
}