-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.java
More file actions
80 lines (63 loc) · 1.73 KB
/
Utils.java
File metadata and controls
80 lines (63 loc) · 1.73 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
69
70
71
72
73
74
75
76
77
78
79
80
package MMS.Project.BCodeGen;
import java.time.LocalTime;
import java.util.Arrays;
import java.util.logging.Level;
/**
* Created by x19de on 27.05.2017.
*/
public class Utils {
public static void log(String msg, Level level, Object source){
String scr = source
.getClass()
.getName()
.substring(
source
.getClass()
.getName()
.lastIndexOf('.') + 1);
System.out.printf("[%s][%s][%s]: %s%n",
LocalTime.now().toString(),
scr,
level.toString(),
msg);
}
public static void logErr(String msg, Level level, Object source){
String scr = source
.getClass()
.getName()
.substring(
source
.getClass()
.getName()
.lastIndexOf('.') + 1);
System.err.printf("[%s][%s][%s]: %s%n",
LocalTime.now().toString(),
scr,
level.toString(),
msg);
}
public static void logEx(Exception ex, Level level, Object source){
String scr = source
.getClass()
.getName()
.substring(
source
.getClass()
.getName()
.lastIndexOf('.') + 1);
String time = LocalTime.now().toString();
System.err.printf("[%s][%s][%s]: %s - %s%n",
time,
scr,
level.toString(),
ex.toString(),
ex.getMessage());
String off = " > ";
for(int i = 0; i < (time.length() + 2 + scr.length() + 2 + level.toString().length() + 2 + 1 + 1) - 3; i++ ){
off += " ";
}
for(int i = 0; i < ex.getStackTrace().length; i++){
System.err.println(off + ex.getStackTrace()[i]);
}
}
}