📄 log.java
字号:
try { target.rotate(); } catch (IOException e) { System.err.println("Warning: There was an error rotating the Jive debug log file. " + "Logging may not work correctly until a restart happens."); } } public static void info(String s) { if (isInfoEnabled()) { infoLog.info(s); } } public static void info(Throwable throwable) { if (isInfoEnabled()) { infoLog.info("", throwable); } } public static void info(String s, Throwable throwable) { if (isInfoEnabled()) { infoLog.info(s, throwable); } } public static void markInfoLogFile(String username) { RotatingFileTarget target = (RotatingFileTarget) infoLog.getLogTargets()[0]; markLogFile(username, target); } public static void rotateInfoLogFile() { RotatingFileTarget target = (RotatingFileTarget) infoLog.getLogTargets()[0]; try { target.rotate(); } catch (IOException e) { System.err.println("Warning: There was an error rotating the Jive info log file. " + "Logging may not work correctly until a restart happens."); } } public static void warn(String s) { if (isWarnEnabled()) { warnLog.warn(s); } } public static void warn(Throwable throwable) { if (isWarnEnabled()) { warnLog.warn("", throwable); } } public static void warn(String s, Throwable throwable) { if (isWarnEnabled()) { warnLog.warn(s, throwable); } } public static void markWarnLogFile(String username) { RotatingFileTarget target = (RotatingFileTarget) warnLog.getLogTargets()[0]; markLogFile(username, target); } public static void rotateWarnLogFile() { RotatingFileTarget target = (RotatingFileTarget) warnLog.getLogTargets()[0]; try { target.rotate(); } catch (IOException e) { System.err.println("Warning: There was an error rotating the Jive warn log file. " + "Logging may not work correctly until a restart happens."); } } public static void error(String s) { if (isErrorEnabled()) { errorLog.error(s); if (isDebugEnabled()) { printToStdErr(s, null); } } } public static void error(Throwable throwable) { if (isErrorEnabled()) { errorLog.error("", throwable); if (isDebugEnabled()) { printToStdErr(null, throwable); } } } public static void error(String s, Throwable throwable) { if (isErrorEnabled()) { errorLog.error(s, throwable); if (isDebugEnabled()) { printToStdErr(s, throwable); } } } public static void markErrorLogFile(String username) { RotatingFileTarget target = (RotatingFileTarget) errorLog.getLogTargets()[0]; markLogFile(username, target); } public static void rotateErrorLogFile() { RotatingFileTarget target = (RotatingFileTarget) errorLog.getLogTargets()[0]; try { target.rotate(); } catch (IOException e) { System.err.println("Warning: There was an error rotating the Jive error log file. " + "Logging may not work correctly until a restart happens."); } } public static void fatal(String s) { if (isFatalEnabled()) { errorLog.fatalError(s); if (isDebugEnabled()) { printToStdErr(s, null); } } } public static void fatal(Throwable throwable) { if (isFatalEnabled()) { errorLog.fatalError("", throwable); if (isDebugEnabled()) { printToStdErr(null, throwable); } } } public static void fatal(String s, Throwable throwable) { if (isFatalEnabled()) { errorLog.fatalError(s, throwable); if (isDebugEnabled()) { printToStdErr(s, throwable); } } } /** * Returns the directory that log files exist in. The directory name will * have a File.separator as the last character in the string. * * @return the directory that log files exist in. */ public static String getLogDirectory() { return logDirectory; } private static void markLogFile(String username, RotatingFileTarget target) { List args = new ArrayList(); args.add(username); args.add(JiveGlobals.formatDateTime(new java.util.Date())); target.write(LocaleUtils.getLocalizedString("log.marker_inserted_by", args) + "\n"); } private static void printToStdErr(String s, Throwable throwable) { if (s != null) { System.err.println(s); } if (throwable != null) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); throwable.printStackTrace(pw); System.err.print(sw.toString()); System.err.print("\n"); } } private static final class JiveLogHandler extends Handler { public void publish(LogRecord record) { Level level = record.getLevel(); Throwable throwable = record.getThrown(); if (Level.SEVERE.equals(level)) { if (throwable != null) { Log.error(record.getMessage(), throwable); } else { Log.error(record.getMessage()); } } else if (Level.WARNING.equals(level)) { if (throwable != null) { Log.warn(record.getMessage(), throwable); } else { Log.warn(record.getMessage()); } } else if (Level.INFO.equals(level)) { if (throwable != null) { Log.info(record.getMessage(), throwable); } else { Log.info(record.getMessage()); } } else { // else FINE,FINER,FINEST if (throwable != null) { Log.debug(record.getMessage(), throwable); } else { Log.debug(record.getMessage()); } } } public void flush() { // do nothing } public void close() throws SecurityException { // do nothing } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -