use of org.syncany.config.LogFormatter in project syncany by syncany.
the class CommandLineClient method initLogHandlers.
private void initLogHandlers(OptionSet options, OptionSpec<String> optionLog, OptionSpec<Void> optionLogPrint, OptionSpec<Void> optionDebug) throws SecurityException, IOException {
// --log=<file>
String logFilePattern = null;
if (options.has(optionLog)) {
if (!"-".equals(options.valueOf(optionLog))) {
logFilePattern = options.valueOf(optionLog);
}
} else if (config != null && config.getLogDir().exists()) {
logFilePattern = config.getLogDir() + File.separator + LOG_FILE_PATTERN;
} else {
logFilePattern = UserConfig.getUserLogDir() + File.separator + LOG_FILE_PATTERN;
}
if (logFilePattern != null) {
Handler fileLogHandler = new FileHandler(logFilePattern, LOG_FILE_LIMIT, LOG_FILE_COUNT, true);
fileLogHandler.setFormatter(new LogFormatter());
Logging.addGlobalHandler(fileLogHandler);
}
// --debug, add console handler
if (options.has(optionDebug) || options.has(optionLogPrint) || (options.has(optionLog) && "-".equals(options.valueOf(optionLog)))) {
Handler consoleLogHandler = new ConsoleHandler();
consoleLogHandler.setFormatter(new LogFormatter());
Logging.addGlobalHandler(consoleLogHandler);
}
}
Aggregations