-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.java
31 lines (24 loc) · 940 Bytes
/
Logger.java
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
import java.text.SimpleDateFormat;
import java.util.Date;
public class Logger {
private Class<?> caller;
private String callerName;
private SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
public static Logger getLogger(Class<?> caller) {
return new Logger(caller);
}
public Logger(Class<?> caller) {
this.caller = caller;
this.callerName = caller.getCanonicalName();
}
public void info(Object message) {
Date date = new Date();
System.out.println(sdf.format(date) + " | " + callerName + " | Thread "
+ Thread.currentThread().getId() + " | " + "INFO | " + String.valueOf(message));
}
public void err(Object message) {
Date date = new Date();
System.err.println(sdf.format(date) + " | " + callerName + " | Thread "
+ Thread.currentThread().getId() + " | " + "ERROR | " + String.valueOf(message));
}
}