Package htsjdk.samtools.util
Class Log
- java.lang.Object
-
- htsjdk.samtools.util.Log
-
public final class Log extends Object
A wafer thin wrapper around System.err that uses var-args to make it much more efficient to call the logging methods in without having to surround every call site with calls to Log.isXXXEnabled(). All the methods on this class take a variable length list of arguments and, only if logging is enabled for the level and channel being logged to, will those arguments be toString()'d and appended together.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLog.LogLevelEnumeration for setting log levels.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddebug(Object... messageParts)Logs one or more message parts at level debug.voiddebug(Throwable throwable, Object... messageParts)Logs a Throwable and optional message parts at level debug.voiderror(Object... messageParts)Logs one or more message parts at level error.voiderror(Throwable throwable, Object... messageParts)Logs a Throwable and optional message parts at level error.static Log.LogLevelgetGlobalLogLevel()Get the log level.static PrintStreamgetGlobalPrintStream()Get thePrintStreamfor writing.static LoggetInstance(Class<?> clazz)Get a Log instance to perform logging within the Class specified.protected StringgetTimestamp()Creates a date string for insertion into the log.voidinfo(Object... messageParts)Logs one or more message parts at level info.voidinfo(Throwable throwable, Object... messageParts)Logs a Throwable and optional message parts at level info.static booleanisEnabled(Log.LogLevel level)Returns true if the specified log level is enabled otherwise false.static voidsetGlobalLogLevel(Log.LogLevel logLevel)Set the log level.static voidsetGlobalPrintStream(PrintStream stream)Set thePrintStreamfor writing.voidwarn(Object... messageParts)Logs one or more message parts at level warn.voidwarn(Throwable throwable, Object... messageParts)Logs a Throwable and optional message parts at level warn.
-
-
-
Method Detail
-
getInstance
public static Log getInstance(Class<?> clazz)
Get a Log instance to perform logging within the Class specified. Returns an instance of this class which wraps an instance of the commons logging Log class.- Parameters:
clazz- the Class which is going to be doing the logging- Returns:
- a Log instance with which to log
-
setGlobalLogLevel
public static void setGlobalLogLevel(Log.LogLevel logLevel)
Set the log level.- Parameters:
logLevel- The log level enumeration
-
getGlobalLogLevel
public static Log.LogLevel getGlobalLogLevel()
Get the log level.- Returns:
- The enumeration for setting log levels.
-
setGlobalPrintStream
public static void setGlobalPrintStream(PrintStream stream)
Set thePrintStreamfor writing.- Parameters:
stream-PrintStreamto write to.
-
getGlobalPrintStream
public static PrintStream getGlobalPrintStream()
Get thePrintStreamfor writing.- Returns:
PrintStreamto write to.
-
isEnabled
public static final boolean isEnabled(Log.LogLevel level)
Returns true if the specified log level is enabled otherwise false.
-
getTimestamp
protected String getTimestamp()
Creates a date string for insertion into the log. Given that logs are sometimes held statically and SimpleDateFormat is not thread safe, currently creates an instance each time :/
-
error
public final void error(Throwable throwable, Object... messageParts)
Logs a Throwable and optional message parts at level error.- Parameters:
throwable- an instance of Throwable that should be logged with stack tracemessageParts- zero or more objects which should be combined, by calling toString() to form the log message.
-
warn
public final void warn(Throwable throwable, Object... messageParts)
Logs a Throwable and optional message parts at level warn.- Parameters:
throwable- an instance of Throwable that should be logged with stack tracemessageParts- zero or more objects which should be combined, by calling toString() to form the log message.
-
info
public final void info(Throwable throwable, Object... messageParts)
Logs a Throwable and optional message parts at level info.- Parameters:
throwable- an instance of Throwable that should be logged with stack tracemessageParts- zero or more objects which should be combined, by calling toString() to form the log message.
-
debug
public final void debug(Throwable throwable, Object... messageParts)
Logs a Throwable and optional message parts at level debug.- Parameters:
throwable- an instance of Throwable that should be logged with stack tracemessageParts- zero or more objects which should be combined, by calling toString() to form the log message.
-
error
public final void error(Object... messageParts)
Logs one or more message parts at level error.- Parameters:
messageParts- one or more objects which should be combined, by calling toString() to form the log message.
-
warn
public final void warn(Object... messageParts)
Logs one or more message parts at level warn.- Parameters:
messageParts- one or more objects which should be combined, by calling toString() to form the log message.
-
info
public final void info(Object... messageParts)
Logs one or more message parts at level info.- Parameters:
messageParts- one or more objects which should be combined, by calling toString() to form the log message.
-
debug
public final void debug(Object... messageParts)
Logs one or more message parts at level debug.- Parameters:
messageParts- one or more objects which should be combined, by calling toString() to form the log message.
-
-