aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper/Log.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-10-31 23:50:02 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2012-10-31 23:50:02 +1300
commit14c4caea141405eb7d378079d9b1b69f92d6c2c7 (patch)
treeeec7eb1a4309bed70bf53e773164dc9a8f5f2902 /src/org/traccar/helper/Log.java
parente2a855c53cad32d38a53ed65c0b899f59c99e646 (diff)
downloadtrackermap-server-14c4caea141405eb7d378079d9b1b69f92d6c2c7.tar.gz
trackermap-server-14c4caea141405eb7d378079d9b1b69f92d6c2c7.tar.bz2
trackermap-server-14c4caea141405eb7d378079d9b1b69f92d6c2c7.zip
Improve logging methods
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);
}
}