📄 log.java
字号:
} //-- WARNING --// /** * Logs a warning message and a throwable object. * * <p>Since warning messages are rarely disabled, * there is no method like infoable or debuggable. */ public final void warning(String msg, Throwable t) { log(WARNING, msg, t); } /** * Logs a warning message. */ public final void warning(String msg) { log(WARNING, msg, null); } /** * Logs an object, whose toString returns the warning message, * and a throwable object. * * @param obj the object whose toString method is called to get the message */ public final void warning(Object obj, Throwable t) { log(WARNING, obj, t); } /** * Logs an object, whose toString returns the warning message. * * @param obj the object whose toString method is called to get the message */ public final void warning(Object obj) { log(WARNING, obj, null); } /** * Logs a warning throwable object. */ public final void warning(Throwable t) { log(WARNING, "", t); } /** * Logs a warning message and a throwable object by giving message code. */ public final void warning(int code, Object[] fmtArgs, Throwable t) { log(WARNING, code, fmtArgs, t); } /** * Logs a warning message and a throwable object by giving message code. */ public final void warning(int code, Object fmtArg, Throwable t) { log(WARNING, code, fmtArg, t); } /** * Logs a warning message and a throwable object by giving message code. */ public final void warning(int code, Throwable t) { log(WARNING, code, t); } /** * Logs a warning message by giving message code. */ public final void warning(int code, Object[] fmtArgs) { log(WARNING, code, fmtArgs, null); } /** * Logs a warning message by giving message code. */ public final void warning(int code, Object fmtArg) { log(WARNING, code, fmtArg, null); } /** * Logs a warning message by giving message code. */ public final void warning(int code) { log(WARNING, code, null); } //-- INFO --// /** * Logs an info message and a throwable object. * * <p>Since info messages are rarely disabled, * there is no method like infoable or debuggable. */ public final void info(String msg, Throwable t) { log(INFO, msg, t); } /** * Logs an info message. */ public final void info(String msg) { log(INFO, msg, null); } /** * Logs an object, whose toString returns the info message, * and a throwable object. * * @param obj the object whose toString method is called to get the message */ public final void info(Object obj, Throwable t) { log(INFO, obj, t); } /** * Logs an object, whose toString returns the info message. * * @param obj the object whose toString method is called to get the message */ public final void info(Object obj) { log(INFO, obj, null); } /** * Logs an info throwable object. */ public final void info(Throwable t) { log(INFO, "", t); } /** * Logs an info message and a throwable object by giving message code. */ public final void info(int code, Object[] fmtArgs, Throwable t) { log(INFO, code, fmtArgs, t); } /** * Logs an info message and a throwable object by giving message code. */ public final void info(int code, Object fmtArg, Throwable t) { log(INFO, code, fmtArg, t); } /** * Logs an info message and a throwable object by giving message code. */ public final void info(int code, Throwable t) { log(INFO, code, t); } /** * Logs an info message by giving message code. */ public final void info(int code, Object[] fmtArgs) { log(INFO, code, fmtArgs, null); } /** * Logs an info message by giving message code. */ public final void info(int code, Object fmtArg) { log(INFO, code, fmtArg, null); } /** * Logs an info message by giving message code. */ public final void info(int code) { log(INFO, code, null); } //-- DEBUG --// /** * Logs a debug message and a throwable object. * * <p>Since debug messages are rarely disabled, * there is no method like infoable or debuggable. */ public final void debug(String msg, Throwable t) { log(DEBUG, msg, t); } /** * Logs a debug message. */ public final void debug(String msg) { log(DEBUG, msg, null); } /** * Logs an object, whose toString returns the debug message, * and a throwable object. * * @param obj the object whose toString method is called to get the message */ public final void debug(Object obj, Throwable t) { log(DEBUG, obj, t); } /** * Logs an object, whose toString returns the debug message. * * @param obj the object whose toString method is called to get the message */ public final void debug(Object obj) { log(DEBUG, obj, null); } /** * Logs a debug throwable object. */ public final void debug(Throwable t) { log(DEBUG, "", t); } /** * Logs a debug message and a throwable object by giving message code. */ public final void debug(int code, Object[] fmtArgs, Throwable t) { log(DEBUG, code, fmtArgs, t); } /** * Logs a debug message and a throwable object by giving message code. */ public final void debug(int code, Object fmtArg, Throwable t) { log(DEBUG, code, fmtArg, t); } /** * Logs a debug message and a throwable object by giving message code. */ public final void debug(int code, Throwable t) { log(DEBUG, code, t); } /** * Logs a debug message by giving message code. */ public final void debug(int code, Object[] fmtArgs) { log(DEBUG, code, fmtArgs, null); } /** * Logs a debug message by giving message code. */ public final void debug(int code, Object fmtArg) { log(DEBUG, code, fmtArg, null); } /** * Logs a debug message by giving message code. */ public final void debug(int code) { log(DEBUG, code, null); } //-- FINER --// /** * Logs a finer message and a throwable object. */ public final void finer(String msg, Throwable t) { log(FINER, msg, t); } /** * Logs a finer message. */ public final void finer(String msg) { log(FINER, msg, null); } /** * Logs an object, whose toString returns the finer message, * and a throwable object. * * @param obj the object whose toString method is called to get the message */ public final void finer(Object obj, Throwable t) { log(FINER, obj, t); } /** * Logs an object, whose toString returns the finer message. * * @param obj the object whose toString method is called to get the message */ public final void finer(Object obj) { log(FINER, obj, null); } /** * Logs a finer throwable object. */ public final void finer(Throwable t) { log(FINER, "", t); } /** * Logs a finer message and a throwable object by giving message code. */ public final void finer(int code, Object[] fmtArgs, Throwable t) { log(FINER, code, fmtArgs, t); } /** * Logs a finer message and a throwable object by giving message code. */ public final void finer(int code, Object fmtArg, Throwable t) { log(FINER, code, fmtArg, t); } /** * Logs a finer message and a throwable object by giving message code. */ public final void finer(int code, Throwable t) { log(FINER, code, t); } /** * Logs a finer message by giving message code. */ public final void finer(int code, Object[] fmtArgs) { log(FINER, code, fmtArgs, null); } /** * Logs a finer message by giving message code. */ public final void finer(int code, Object fmtArg) { log(FINER, code, fmtArg, null); } /** * Logs a finer message by giving message code. */ public final void finer(int code) { log(FINER, code, null); } /** Logs only the real cause of the specified exception. * It is useful because sometimes the stack trace is too big. */ public final void realCause(Throwable ex) { realCause(null, ex); } /** Logs only the real cause of the specified exception with an extra * message as an error message. */ public final void realCause(String message, Throwable ex) { realCause0(message, ex, true, 0); } /** Logs only the first few lines of the real cause as an error message. */ public final void realCauseBriefly(String message, Throwable ex) { realCause0(message, ex, true, 5); } /** Lo only the first few lines of the real cause as an error message. */ public final void realCauseBriefly(Throwable ex) { realCauseBriefly(null, ex); } private final void realCause0(String message, Throwable ex, boolean err, int maxcnt) { final StringBuffer sb = new StringBuffer(1024); if (message != null) sb.append(message).append('\n'); while (true) { Throwable cause = Exceptions.getCause(ex); if (cause == null) break; sb.append(">>").append(ex.getClass().getName()) .append(": ").append(ex.getMessage()).append('\n'); ex = cause; } String s = Exceptions.getExtraMessage(ex); if (s != null) sb.append(s).append('\n'); message = Exceptions.formatStackTrace(sb, ex, ">>", maxcnt).toString(); if (err) error(message); else warning(message); } /** Logs only the first few lines of the real cause as an warning message. */ public final void warningBriefly(String message, Throwable ex) { realCause0(message, ex, true, 3); } /** Lo only the first few lines of the real cause. */ public final void warningBriefly(Throwable ex) { warningBriefly(null, ex); } /** Logs an exception as an warning message about being eaten * (rather than thrown). */ public final void eat(String message, Throwable ex) { if (debugable()) { warningBriefly(message, ex); } else { warning(Objects.BAR1_STRING+(message != null ? "\n"+message: "")+"\n"+"The exception:\n"+Exceptions.getMessage(ex)+"\n"+"If you want to see the stack trace, turn the DEBUG level on for "+_name+"\n"+Objects.BAR1_STRING); } } /** Logs an exception as an warning message about being eaten * (rather than thrown). */ public final void eat(Throwable ex) { eat(null, ex); } public int hashCode() { return _name.hashCode(); } public boolean equals(Object o) { return o instanceof Log && ((Log)o)._name.equals(_name); } public String toString() { return _name; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -