// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package org.slf4j.impl; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.security.AccessController; import java.security.PrivilegedAction; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties; import org.slf4j.helpers.FormattingTuple; import org.slf4j.helpers.MarkerIgnoringBase; import org.slf4j.helpers.MessageFormatter; import org.slf4j.helpers.Util; public class SimpleLogger extends MarkerIgnoringBase { private static final String CONFIGURATION_FILE = "simplelogger.properties"; private static DateFormat DATE_FORMATTER = null; public static final String DATE_TIME_FORMAT_KEY = "org.slf4j.simpleLogger.dateTimeFormat"; private static String DATE_TIME_FORMAT_STR = null; private static int DEFAULT_LOG_LEVEL = 0; public static final String DEFAULT_LOG_LEVEL_KEY = "org.slf4j.simpleLogger.defaultLogLevel"; private static boolean INITIALIZED = false; private static boolean LEVEL_IN_BRACKETS = false; public static final String LEVEL_IN_BRACKETS_KEY = "org.slf4j.simpleLogger.levelInBrackets"; private static String LOG_FILE = "System.err"; public static final String LOG_FILE_KEY = "org.slf4j.simpleLogger.logFile"; public static final String LOG_KEY_PREFIX = "org.slf4j.simpleLogger.log."; private static final int LOG_LEVEL_DEBUG = 10; private static final int LOG_LEVEL_ERROR = 40; private static final int LOG_LEVEL_INFO = 20; private static final int LOG_LEVEL_TRACE = 0; private static final int LOG_LEVEL_WARN = 30; private static boolean SHOW_DATE_TIME = false; public static final String SHOW_DATE_TIME_KEY = "org.slf4j.simpleLogger.showDateTime"; private static boolean SHOW_LOG_NAME = false; public static final String SHOW_LOG_NAME_KEY = "org.slf4j.simpleLogger.showLogName"; private static boolean SHOW_SHORT_LOG_NAME = false; public static final String SHOW_SHORT_LOG_NAME_KEY = "org.slf4j.simpleLogger.showShortLogName"; private static boolean SHOW_THREAD_NAME = false; public static final String SHOW_THREAD_NAME_KEY = "org.slf4j.simpleLogger.showThreadName"; private static final Properties SIMPLE_LOGGER_PROPS = new Properties(); private static long START_TIME = 0L; public static final String SYSTEM_PREFIX = "org.slf4j.simpleLogger."; private static PrintStream TARGET_STREAM = null; private static String WARN_LEVEL_STRING = "WARN"; public static final String WARN_LEVEL_STRING_KEY = "org.slf4j.simpleLogger.warnLevelString"; private static final long serialVersionUID = 0xf737e1db29876f6cL; protected int currentLogLevel; private transient String shortLogName; SimpleLogger(String s) { currentLogLevel = 20; shortLogName = null; if (!INITIALIZED) { init(); } name = s; s = recursivelyComputeLevelString(); if (s != null) { currentLogLevel = stringToLevel(s); return; } else { currentLogLevel = DEFAULT_LOG_LEVEL; return; } } private String computeShortName() { return name.substring(name.lastIndexOf(".") + 1); } private static PrintStream computeTargetStream(String s) { if ("System.err".equalsIgnoreCase(s)) { return System.err; } if ("System.out".equalsIgnoreCase(s)) { return System.out; } PrintStream printstream; try { printstream = new PrintStream(new FileOutputStream(s)); } catch (FileNotFoundException filenotfoundexception) { Util.report((new StringBuilder()).append("Could not open [").append(s).append("]. Defaulting to System.err").toString(), filenotfoundexception); return System.err; } return printstream; } private void formatAndLog(int i, String s, Object obj, Object obj1) { if (!isLevelEnabled(i)) { return; } else { s = MessageFormatter.format(s, obj, obj1); log(i, s.getMessage(), s.getThrowable()); return; } } private transient void formatAndLog(int i, String s, Object aobj[]) { if (!isLevelEnabled(i)) { return; } else { s = MessageFormatter.arrayFormat(s, aobj); log(i, s.getMessage(), s.getThrowable()); return; } } private static boolean getBooleanProperty(String s, boolean flag) { s = getStringProperty(s); if (s == null) { return flag; } else { return "true".equalsIgnoreCase(s); } } private String getFormattedDate() { Object obj = new Date(); synchronized (DATE_FORMATTER) { obj = DATE_FORMATTER.format(((Date) (obj))); } return ((String) (obj)); exception; dateformat; JVM INSTR monitorexit ; throw exception; } private static String getStringProperty(String s) { String s1 = null; String s2 = System.getProperty(s); s1 = s2; _L2: String s3 = s1; if (s1 == null) { s3 = SIMPLE_LOGGER_PROPS.getProperty(s); } return s3; SecurityException securityexception; securityexception; if (true) goto _L2; else goto _L1 _L1: } private static String getStringProperty(String s, String s1) { s = getStringProperty(s); if (s == null) { return s1; } else { return s; } } static void init() { INITIALIZED = true; loadProperties(); String s = getStringProperty("org.slf4j.simpleLogger.defaultLogLevel", null); if (s != null) { DEFAULT_LOG_LEVEL = stringToLevel(s); } SHOW_LOG_NAME = getBooleanProperty("org.slf4j.simpleLogger.showLogName", SHOW_LOG_NAME); SHOW_SHORT_LOG_NAME = getBooleanProperty("org.slf4j.simpleLogger.showShortLogName", SHOW_SHORT_LOG_NAME); SHOW_DATE_TIME = getBooleanProperty("org.slf4j.simpleLogger.showDateTime", SHOW_DATE_TIME); SHOW_THREAD_NAME = getBooleanProperty("org.slf4j.simpleLogger.showThreadName", SHOW_THREAD_NAME); DATE_TIME_FORMAT_STR = getStringProperty("org.slf4j.simpleLogger.dateTimeFormat", DATE_TIME_FORMAT_STR); LEVEL_IN_BRACKETS = getBooleanProperty("org.slf4j.simpleLogger.levelInBrackets", LEVEL_IN_BRACKETS); WARN_LEVEL_STRING = getStringProperty("org.slf4j.simpleLogger.warnLevelString", WARN_LEVEL_STRING); LOG_FILE = getStringProperty("org.slf4j.simpleLogger.logFile", LOG_FILE); TARGET_STREAM = computeTargetStream(LOG_FILE); if (DATE_TIME_FORMAT_STR == null) { break MISSING_BLOCK_LABEL_141; } DATE_FORMATTER = new SimpleDateFormat(DATE_TIME_FORMAT_STR); return; IllegalArgumentException illegalargumentexception; illegalargumentexception; Util.report("Bad date format in simplelogger.properties; will output relative time", illegalargumentexception); return; } private static void loadProperties() { InputStream inputstream; inputstream = (InputStream)AccessController.doPrivileged(new PrivilegedAction() { public Object run() { ClassLoader classloader = Thread.currentThread().getContextClassLoader(); if (classloader != null) { return classloader.getResourceAsStream("simplelogger.properties"); } else { return ClassLoader.getSystemResourceAsStream("simplelogger.properties"); } } }); if (inputstream == null) { break MISSING_BLOCK_LABEL_29; } SIMPLE_LOGGER_PROPS.load(inputstream); inputstream.close(); return; IOException ioexception; ioexception; } private void log(int i, String s, Throwable throwable) { StringBuffer stringbuffer; if (!isLevelEnabled(i)) { return; } stringbuffer = new StringBuffer(32); if (SHOW_DATE_TIME) { if (DATE_FORMATTER != null) { stringbuffer.append(getFormattedDate()); stringbuffer.append(' '); } else { stringbuffer.append(System.currentTimeMillis() - START_TIME); stringbuffer.append(' '); } } if (SHOW_THREAD_NAME) { stringbuffer.append('['); stringbuffer.append(Thread.currentThread().getName()); stringbuffer.append("] "); } if (LEVEL_IN_BRACKETS) { stringbuffer.append('['); } i; JVM INSTR lookupswitch 5: default 152 // 0: 253 // 10: 265 // 20: 277 // 30: 289 // 40: 301; goto _L1 _L2 _L3 _L4 _L5 _L6 _L1: break; /* Loop/switch isn't completed */ _L6: break MISSING_BLOCK_LABEL_301; _L7: if (LEVEL_IN_BRACKETS) { stringbuffer.append(']'); } stringbuffer.append(' '); if (SHOW_SHORT_LOG_NAME) { if (shortLogName == null) { shortLogName = computeShortName(); } stringbuffer.append(String.valueOf(shortLogName)).append(" - "); } else if (SHOW_LOG_NAME) { stringbuffer.append(String.valueOf(name)).append(" - "); } stringbuffer.append(s); write(stringbuffer, throwable); return; _L2: stringbuffer.append("TRACE"); goto _L7 _L3: stringbuffer.append("DEBUG"); goto _L7 _L4: stringbuffer.append("INFO"); goto _L7 _L5: stringbuffer.append(WARN_LEVEL_STRING); goto _L7 stringbuffer.append("ERROR"); goto _L7 } private static int stringToLevel(String s) { byte byte0 = 20; int i; if ("trace".equalsIgnoreCase(s)) { i = 0; } else { if ("debug".equalsIgnoreCase(s)) { return 10; } i = byte0; if (!"info".equalsIgnoreCase(s)) { if ("warn".equalsIgnoreCase(s)) { return 30; } i = byte0; if ("error".equalsIgnoreCase(s)) { return 40; } } } return i; } public void debug(String s) { log(10, s, null); } public void debug(String s, Object obj) { formatAndLog(10, s, obj, null); } public void debug(String s, Object obj, Object obj1) { formatAndLog(10, s, obj, obj1); } public void debug(String s, Throwable throwable) { log(10, s, throwable); } public transient void debug(String s, Object aobj[]) { formatAndLog(10, s, aobj); } public void error(String s) { log(40, s, null); } public void error(String s, Object obj) { formatAndLog(40, s, obj, null); } public void error(String s, Object obj, Object obj1) { formatAndLog(40, s, obj, obj1); } public void error(String s, Throwable throwable) { log(40, s, throwable); } public transient void error(String s, Object aobj[]) { formatAndLog(40, s, aobj); } public void info(String s) { log(20, s, null); } public void info(String s, Object obj) { formatAndLog(20, s, obj, null); } public void info(String s, Object obj, Object obj1) { formatAndLog(20, s, obj, obj1); } public void info(String s, Throwable throwable) { log(20, s, throwable); } public transient void info(String s, Object aobj[]) { formatAndLog(20, s, aobj); } public boolean isDebugEnabled() { return isLevelEnabled(10); } public boolean isErrorEnabled() { return isLevelEnabled(40); } public boolean isInfoEnabled() { return isLevelEnabled(20); } protected boolean isLevelEnabled(int i) { return i >= currentLogLevel; } public boolean isTraceEnabled() { return isLevelEnabled(0); } public boolean isWarnEnabled() { return isLevelEnabled(30); } String recursivelyComputeLevelString() { String s1 = name; String s = null; for (int i = s1.length(); s == null && i > -1; i = String.valueOf(s1).lastIndexOf(".")) { s1 = s1.substring(0, i); s = getStringProperty((new StringBuilder()).append("org.slf4j.simpleLogger.log.").append(s1).toString(), null); } return s; } public void trace(String s) { log(0, s, null); } public void trace(String s, Object obj) { formatAndLog(0, s, obj, null); } public void trace(String s, Object obj, Object obj1) { formatAndLog(0, s, obj, obj1); } public void trace(String s, Throwable throwable) { log(0, s, throwable); } public transient void trace(String s, Object aobj[]) { formatAndLog(0, s, aobj); } public void warn(String s) { log(30, s, null); } public void warn(String s, Object obj) { formatAndLog(30, s, obj, null); } public void warn(String s, Object obj, Object obj1) { formatAndLog(30, s, obj, obj1); } public void warn(String s, Throwable throwable) { log(30, s, throwable); } public transient void warn(String s, Object aobj[]) { formatAndLog(30, s, aobj); } void write(StringBuffer stringbuffer, Throwable throwable) { TARGET_STREAM.println(stringbuffer.toString()); if (throwable != null) { throwable.printStackTrace(TARGET_STREAM); } TARGET_STREAM.flush(); } static { START_TIME = System.currentTimeMillis(); INITIALIZED = false; DEFAULT_LOG_LEVEL = 20; SHOW_DATE_TIME = false; SHOW_THREAD_NAME = true; SHOW_LOG_NAME = true; SHOW_SHORT_LOG_NAME = false; LEVEL_IN_BRACKETS = false; } }