2021-12-06 10:49:40 +08:00
|
|
|
package com.janetfilter.core.commons;
|
2021-11-29 14:24:13 +08:00
|
|
|
|
2021-12-06 10:49:40 +08:00
|
|
|
import com.janetfilter.core.utils.DateUtils;
|
2021-11-29 14:24:13 +08:00
|
|
|
|
|
|
|
public class DebugInfo {
|
2021-11-30 11:15:45 +08:00
|
|
|
private static final boolean DEBUG = "1".equals(System.getenv("JANF_DEBUG")) || "1".equals(System.getProperty("janf.debug"));
|
2021-11-29 14:24:13 +08:00
|
|
|
|
|
|
|
public static void output(String content) { // No logger lib required
|
|
|
|
if (!DEBUG) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
String template = "[%s] %s DEBUG : %s%n";
|
|
|
|
|
|
|
|
StackTraceElement[] traces = new Throwable().getStackTrace();
|
|
|
|
String caller = traces.length < 2 ? "UNKNOWN" : traces[1].toString();
|
|
|
|
|
|
|
|
System.out.printf(template, DateUtils.formatNow(), caller, content);
|
2021-12-27 14:16:35 +08:00
|
|
|
System.out.flush();
|
2021-11-29 14:24:13 +08:00
|
|
|
}
|
|
|
|
}
|