/
Debug.java
110 lines (89 loc) · 3.78 KB
/
Debug.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package com.denizenscript.denizencore.utilities.debugging;
import com.denizenscript.denizencore.DenizenCore;
import com.denizenscript.denizencore.scripts.ScriptEntry;
import com.denizenscript.denizencore.scripts.containers.ScriptContainer;
import com.denizenscript.denizencore.tags.TagContext;
public class Debug {
public static boolean showScriptBuilder = false;
public static boolean showEventsTrimming = false;
/**
* Can be used with echoDebug(...) to output a header, footer,
* or a spacer.
* <p/>
* DebugElement.Header = +- string description ------+
* DebugElement.Spacer =
* DebugElement.Footer = +--------------+
* <p/>
* Also includes color.
*/
public enum DebugElement {
Header, Footer, Spacer
}
public static void echoError(String error) {
DenizenCore.implementation.debugError((String) null, error);
}
public static void echoError(TagContext context, String error) {
echoError(context, null, error);
}
public static void echoError(TagContext context, String addedContext, String error) {
if (context != null && context.entry != null) {
echoError(context.entry, addedContext, error);
}
else if (context != null && context.script != null) {
echoError(context.script.getContainer(), addedContext, error);
}
else {
DenizenCore.implementation.debugError(addedContext, error);
}
}
public static void echoError(ScriptContainer script, String error) {
echoError(script, null, error);
}
public static void echoError(ScriptContainer script, String addedContext, String error) {
if (script != null) {
addedContext = " <LR>In script '<A>" + script.getName() + "<LR>'" + (addedContext == null ? "" : addedContext);
}
if (script == null) {
DenizenCore.implementation.debugError(addedContext, error);
}
else {
DenizenCore.implementation.debugError(addedContext, error);
}
}
public static void echoError(ScriptEntry entry, String error) {
echoError(entry, null, error);
}
public static void echoError(ScriptEntry entry, String addedContext, String error) {
DenizenCore.implementation.debugError(entry, addedContext, error);
}
public static void echoError(Throwable ex) {
DenizenCore.implementation.debugException(ex);
}
public static void echoError(ScriptEntry entry, Throwable error) {
DenizenCore.implementation.debugError(entry, error);
}
public static void log(String message) {
DenizenCore.implementation.debugMessage(message);
}
public static void log(String caller, String message) {
DenizenCore.implementation.debugMessage(caller, message);
}
public static void echoApproval(String message) {
DenizenCore.implementation.debugApproval(message);
}
public static void echoDebug(Debuggable entry, String message) {
DenizenCore.implementation.debugEntry(entry, message);
}
public static void echoDebug(Debuggable entry, DebugElement element, String message) {
DenizenCore.implementation.debugEntry(entry, element, message);
}
public static void echoDebug(Debuggable entry, DebugElement element) {
DenizenCore.implementation.debugEntry(entry, element);
}
public static void report(Debuggable caller, String name, String message) {
DenizenCore.implementation.debugReport(caller, name, message);
}
public static void report(Debuggable caller, String name, Object... values) {
DenizenCore.implementation.debugReport(caller, name, values);
}
}