Package htsjdk.samtools.util
Class Log
java.lang.Object
htsjdk.samtools.util.Log
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
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
Logs one or more message parts at level debug.final void
Logs a Throwable and optional message parts at level debug.final void
Logs a message at level debug.final void
Logs one or more message parts at level error.final void
Logs a Throwable and optional message parts at level error.final void
Logs a message part at level error.static Log.LogLevel
Get the log level.static PrintStream
Get thePrintStream
for writing.static Log
getInstance
(Class<?> clazz) Get a Log instance to perform logging within the Class specified.protected String
Creates a date string for insertion into the log.final void
Logs one or more message parts at level info.final void
Logs a Throwable and optional message parts at level info.final void
Logs a message part at level info.static final 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.final void
Logs one or more message parts at level warn.final void
Logs a Throwable and optional message parts at level warn.final void
Logs a message part at level warn.
-
Method Details
-
getInstance
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
Set the log level.- Parameters:
logLevel
- The log level enumeration
-
getGlobalLogLevel
Get the log level.- Returns:
- The enumeration for setting log levels.
-
setGlobalPrintStream
Set thePrintStream
for writing.- Parameters:
stream
-PrintStream
to write to.
-
getGlobalPrintStream
Get thePrintStream
for writing.- Returns:
PrintStream
to write to.
-
isEnabled
Returns true if the specified log level is enabled otherwise false. -
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
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
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
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
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
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
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
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
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.
-
error
Logs a message part at level error.- Parameters:
messageParts
- a supplier of the object that will be obtained and then toString'ed to form the log message.
-
warn
Logs a message part at level warn.- Parameters:
messageParts
- a supplier of the object that will be obtained and then toString'ed to form the log message.
-
info
Logs a message part at level info.- Parameters:
messageParts
- a supplier of the object that will be obtained and then toString'ed to form the log message.
-
debug
Logs a message at level debug.- Parameters:
messageParts
- a supplier of the object that will be obtained and then toString'ed to form the log message.
-