static void init() { CONFIG_PARAMS = new SimpleLoggerConfiguration(); CONFIG_PARAMS.init(); }
void init() { loadProperties(); String defaultLogLevelString = getStringProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, null); if (defaultLogLevelString != null) defaultLogLevel = stringToLevel(defaultLogLevelString); showLogName = getBooleanProperty(SimpleLogger.SHOW_LOG_NAME_KEY, SimpleLoggerConfiguration.SHOW_LOG_NAME_DEFAULT); showShortLogName = getBooleanProperty(SimpleLogger.SHOW_SHORT_LOG_NAME_KEY, SHOW_SHORT_LOG_NAME_DEFAULT); showDateTime = getBooleanProperty(SimpleLogger.SHOW_DATE_TIME_KEY, SHOW_DATE_TIME_DEFAULT); showThreadName = getBooleanProperty(SimpleLogger.SHOW_THREAD_NAME_KEY, SHOW_THREAD_NAME_DEFAULT); dateTimeFormatStr = getStringProperty(SimpleLogger.DATE_TIME_FORMAT_KEY, DATE_TIME_FORMAT_STR_DEFAULT); levelInBrackets = getBooleanProperty(SimpleLogger.LEVEL_IN_BRACKETS_KEY, LEVEL_IN_BRACKETS_DEFAULT); warnLevelString = getStringProperty(SimpleLogger.WARN_LEVEL_STRING_KEY, WARN_LEVELS_STRING_DEFAULT); logFile = getStringProperty(SimpleLogger.LOG_FILE_KEY, logFile); cacheOutputStream = getBooleanProperty(SimpleLogger.CACHE_OUTPUT_STREAM_STRING_KEY, CACHE_OUTPUT_STREAM_DEFAULT); outputChoice = computeOutputChoice(logFile, cacheOutputStream); if (dateTimeFormatStr != null) { try { dateFormatter = new SimpleDateFormat(dateTimeFormatStr); } catch (IllegalArgumentException e) { Util.report("Bad date format in " + CONFIGURATION_FILE + "; will output relative time", e); } } }
void init() { loadProperties(); String defaultLogLevelString = getStringProp(Constant.ROOT_LEVEL_KEY, null); if (defaultLogLevelString != null) { defaultLogLevel = stringToLevel(defaultLogLevelString); this.showLogName = getBoolProp(Constant.SHOW_LOG_NAME_KEY, showLogName); this.showShortLogName = getBoolProp(Constant.SHOW_SHORT_NAME_KEY, showShortLogName); this.showDateTime = getBoolProp(Constant.SHOW_DATE_TIME_KEY, showDateTime); this.showThreadName = getBoolProp(Constant.SHOW_THREAD_NAME_KEY, showThreadName); this.showConsole = getBoolProp(Constant.SHOW_CONSOLE_KEY, showConsole); this.disableColor = getBoolProp(Constant.DISABLE_COLOR, disableColor); String dateTimeFormatStr = getStringProp(Constant.DATE_TIME_FORMAT_KEY, DATE_TIME_FORMAT_STR_DEFAULT); this.levelInBrackets = getBoolProp(Constant.LEVEL_IN_BRACKETS_KEY, levelInBrackets); boolean cacheOutputStream = getBoolProp(Constant.CACHE_OUTPUT_STREAM_STRING_KEY, false); String logDir = getStringProp(Constant.LOG_DIR_KEY, ""); if (LogUtils.isEmpty(logDir)) { this.outputChoice = computeOutputChoice(logDir, cacheOutputStream); } else { String logName = getStringProp(Constant.LOG_NAME_KEY, ""); if (logName.isEmpty()) { logName = getStringProp(Constant.APP_NAME_KEY, logName); long maxSize = getLongProp(Constant.MAX_SIZE_KEY, 1024 * 1024 * 100);
public void init() { // lets set the initialised flag so we don't get replaced later on SimpleLogger.lazyInit(); SimpleLogger.CONFIG_PARAMS = this; super.init(); this.outputChoice = new OutputChoice(out); this.showThreadName = false; } }
/** * Package access allows only {@link SimpleLoggerFactory} to instantiate * SimpleLogger instances. */ SimpleLogger(String name) { this.name = name; String levelString = recursivelyComputeLevelString(); if (levelString != null) { this.currentLogLevel = SimpleLoggerConfiguration.stringToLevel(levelString); } else { this.currentLogLevel = CONFIG_PARAMS.defaultLogLevel; } }
String getStringProp(String name, String defaultValue) { String prop = getStringProp(name); return (prop == null) ? defaultValue : prop; }
/** * Package access allows only {@link SimpleLoggerFactory} to instantiate * SimpleLogger instances. */ SimpleLogger(String name) { this.name = name; String levelString = recursivelyComputeLevelString(); if (levelString != null) { this.rootLevel = SimpleLoggerConfiguration.stringToLevel(levelString); } else { this.rootLevel = CONFIG_PARAMS.defaultLogLevel; } }
private boolean getBoolProp(String name, boolean defaultValue) { String prop = getStringProp(name); return (prop == null) ? defaultValue : "true".equalsIgnoreCase(prop); }
/** * external software might be invoking this method directly. Do not rename or change its semantics. */ static void init() { CONFIG_PARAMS = new SimpleLoggerConfiguration(); CONFIG_PARAMS.init(); }
private Long getLongProp(String name, long defaultValue) { String val = getStringProp(name); if (null == val || val.isEmpty()) { return defaultValue; } return Long.parseLong(val); }
private String recursivelyComputeLevelString() { String tempName = name; String levelString = null; int indexOfLastDot = tempName.length(); while ((levelString == null) && (indexOfLastDot > -1)) { tempName = tempName.substring(0, indexOfLastDot); levelString = CONFIG_PARAMS.getStringProp(Constant.LOG_KEY_PREFIX + tempName, null); indexOfLastDot = String.valueOf(tempName).lastIndexOf("."); } return levelString; }