Package me.legrange.log
Class Log
- java.lang.Object
-
- me.legrange.log.Log
-
public final class Log extends Object
The log interface. Use this class to add logging to your code.- Author:
- gideon
-
-
Constructor Summary
Constructors Constructor Description Log()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcritical(String fmt, Object... args)Log critical event.static voidcritical(Throwable ex)Log an exception as a critical error.static voidcritical(Throwable ex, String fmt, Object... args)Log an exception as a critical error.static voiddebug(String fmt, Object... args)Log debug event.static voiddebug(Supplier<String> msg)Log a debug event, while avoiding any expensive code unless the logging occurs.static voiderror(String fmt, Object... args)Log error event.static voiderror(Throwable ex)Log an exception as an error.static voiderror(Throwable ex, String fmt, Object... args)Log an exception as an error.static voidinfo(String fmt, Object... args)Log informational event.static voidsetDefaultLevel(Level level)Set the default logging level.static voidsetDefaultLogger(Logger logger)Set the default application logger.static voidsetLevel(String name, Level level)Set the log level for the given name.static voidsetLevel(Level level)Set the log level for the package calling the logger.static voidsetLogger(String name, Logger logger)Set the logger for the given name.static voidsetLogger(Logger logger)Set the logger for the package calling the logger.static voidwarning(String fmt, Object... args)Log warning event.static voidwarning(Throwable ex)Log an exception as a warning.static voidwarning(Throwable ex, String fmt, Object... args)Log an exception as a warning.
-
-
-
Method Detail
-
critical
public static void critical(String fmt, Object... args)
Log critical event.- Parameters:
fmt- The message format stringargs- The message arguments
-
critical
public static void critical(Throwable ex)
Log an exception as a critical error.- Parameters:
ex- The exception
-
critical
public static void critical(Throwable ex, String fmt, Object... args)
Log an exception as a critical error.- Parameters:
ex- The exceptionfmt- The message format stringargs- The message arguments
-
error
public static void error(String fmt, Object... args)
Log error event.- Parameters:
fmt- The message format stringargs- The message arguments
-
error
public static void error(Throwable ex)
Log an exception as an error.- Parameters:
ex- The exception
-
error
public static void error(Throwable ex, String fmt, Object... args)
Log an exception as an error.- Parameters:
ex- The exceptionfmt- The message format stringargs- The message arguments
-
warning
public static void warning(String fmt, Object... args)
Log warning event.- Parameters:
fmt- The message format stringargs- The message arguments
-
warning
public static void warning(Throwable ex)
Log an exception as a warning.- Parameters:
ex- The exception
-
warning
public static void warning(Throwable ex, String fmt, Object... args)
Log an exception as a warning.- Parameters:
ex- The exceptionfmt- The message format stringargs- The message arguments
-
info
public static void info(String fmt, Object... args)
Log informational event.- Parameters:
fmt- The message format stringargs- The message arguments
-
debug
public static void debug(String fmt, Object... args)
Log debug event.- Parameters:
fmt- The message format stringargs- The message arguments
-
debug
public static void debug(Supplier<String> msg)
Log a debug event, while avoiding any expensive code unless the logging occurs. Use this when part of the building is expensive operations.- Parameters:
msg- A supplier that will provide the debug message when required.
-
setDefaultLogger
public static void setDefaultLogger(Logger logger)
Set the default application logger. Only call this from your application's main code. This must not be called by libraries.- Parameters:
logger- The logger to use as default
-
setDefaultLevel
public static void setDefaultLevel(Level level)
Set the default logging level. Only call this from your application's main code. This must not be called by libraries.- Parameters:
level- The default level to set.
-
setLogger
public static void setLogger(Logger logger)
Set the logger for the package calling the logger.- Parameters:
logger- The logger to use for the package calling the method
-
setLogger
public static void setLogger(String name, Logger logger)
Set the logger for the given name.- Parameters:
logger- The logger to use for the package calling the given name
-
setLevel
public static void setLevel(Level level)
Set the log level for the package calling the logger.- Parameters:
level- The log level
-
-