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 class
Log.LogLevel
Enumeration for setting log levels.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
debug(Object... messageParts)
Logs one or more message parts at level debug.void
debug(Throwable throwable, Object... messageParts)
Logs a Throwable and optional message parts at level debug.void
error(Object... messageParts)
Logs one or more message parts at level error.void
error(Throwable throwable, Object... messageParts)
Logs a Throwable and optional message parts at level error.static Log.LogLevel
getGlobalLogLevel()
Get the log level.static PrintStream
getGlobalPrintStream()
Get thePrintStream
for writing.static Log
getInstance(Class<?> clazz)
Get a Log instance to perform logging within the Class specified.protected String
getTimestamp()
Creates a date string for insertion into the log.void
info(Object... messageParts)
Logs one or more message parts at level info.void
info(Throwable throwable, Object... messageParts)
Logs a Throwable and optional message parts at level info.static boolean
isEnabled(Log.LogLevel level)
Returns true if the specified log level is enabled otherwise false.static void
setGlobalLogLevel(Log.LogLevel logLevel)
Set the log level.static void
setGlobalPrintStream(PrintStream stream)
Set thePrintStream
for writing.void
warn(Object... messageParts)
Logs one or more message parts at level warn.void
warn(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 thePrintStream
for writing.- Parameters:
stream
-PrintStream
to write to.
-
getGlobalPrintStream
public static PrintStream getGlobalPrintStream()
Get thePrintStream
for writing.- Returns:
PrintStream
to 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.
-
-