-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDebug.java
More file actions
53 lines (50 loc) · 1.68 KB
/
Copy pathDebug.java
File metadata and controls
53 lines (50 loc) · 1.68 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
package javagameengine.msc;
import javagameengine.components.Component;
public class Debug {
static float a = 0;
public static boolean shouldLog = true;
/**
* This is a handy tool to find where you have placed your logging
* It will make it log from what file and line the log is coming from
*/
public static boolean showWhere = false;
public static void startCount(){
a = System.nanoTime();
}
/***
* this function will print the amount of time in nanosecunds since the startcound function was called
*/
public static void endCount(){
logPriv(String.valueOf((System.nanoTime()-a)));
}
public static void endCountMiliSeconds(){
logPriv(String.valueOf((System.nanoTime()-a)/1000000));
}
public static void endCount(int devide){
logPriv(String.valueOf((System.nanoTime()-a)/devide));
}
public static void log(Component log){
logPriv((log.toString()));
}
public static void log(String log){
logPriv((log));
}
public static void log(int log){
logPriv(String.valueOf(log));
}
public static void log(float log){
logPriv(String.valueOf(log));
}
public static void log(Vector2 log){
logPriv(log.toString());
}
public static void log(Double log){logPriv(String.valueOf(log));}
private static void logPriv(String log)
{
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
if(shouldLog&&showWhere)
System.out.println(stackTraceElements[3]+log);
else if(shouldLog)
System.out.println(log);
}
}