aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper/Log.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/helper/Log.java')
-rw-r--r--src/org/traccar/helper/Log.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/org/traccar/helper/Log.java b/src/org/traccar/helper/Log.java
index ce99f959a..69eea6579 100644
--- a/src/org/traccar/helper/Log.java
+++ b/src/org/traccar/helper/Log.java
@@ -15,6 +15,7 @@
*/
package org.traccar.helper;
+import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -28,21 +29,30 @@ public class Log {
public static Logger getLogger() {
return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
}
+
+ private static void write(Level level, String msg) {
+ StackTraceElement[] stack = Thread.currentThread().getStackTrace();
+ if (stack != null && stack.length > 3) {
+ getLogger().logp(level, stack[3].getClassName(), stack[3].getMethodName(), msg);
+ } else {
+ getLogger().log(level, msg);
+ }
+ }
public static void severe(String msg) {
- getLogger().severe(msg);
+ write(Level.SEVERE, msg);
}
public static void warning(String msg) {
- getLogger().warning(msg);
+ write(Level.WARNING, msg);
}
public static void info(String msg) {
- getLogger().info(msg);
+ write(Level.INFO, msg);
}
public static void fine(String msg) {
- getLogger().fine(msg);
+ write(Level.FINE, msg);
}
}