Package tripleplay.util
Class Logger
java.lang.Object
tripleplay.util.Logger
Provides logging services that are routed to the appropriate logging destination on the client
or server. A useful usage pattern is for a library or game to define a shared
Log
class
like so:
import tripleplay.util.Logger;
public class Log {
public static final Logger log = new Logger("libident");
}
and then import Log.log
statically into classes so that they can invoke
log.info
, etc.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Wires the logging front-end to the logging back-end.static enum
Tags a log message with a particular severity level.static class
Manages the target log levels for a given ident.static class
A logging back-end that writes to PlayN. -
Field Summary
Modifier and TypeFieldDescriptionstatic Logger.Levels
Log levels can be configured via this instance. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Logs a debug message.void
Logs an error message.static String
Formats and returns the supplied message and key/value arguments asmessage [key=value, key=value, ...]
.static StringBuilder
format
(StringBuilder into, Object... args) Formats the supplied key/value arguments into the supplied string builder askey=value, key=value, ...
.void
Logs an info message.static void
setImpl
(Logger.Impl impl) Configures the logging back-end.boolean
shouldLog
(Logger.Level level) Tests if this logger will output messages of the given level.void
Logs a warning message.
-
Field Details
-
levels
Log levels can be configured via this instance.
-
-
Constructor Details
-
Logger
Creates a logger with the specified ident string.
-
-
Method Details
-
setImpl
Configures the logging back-end. This should be called before any code that makes use of the logging services. The default back-end logs tostderr
, which is useful when running in unit tests.null
may be supplied to restore the default (stderr) back-end. -
format
Formats and returns the supplied message and key/value arguments asmessage [key=value, key=value, ...]
. -
format
Formats the supplied key/value arguments into the supplied string builder askey=value, key=value, ...
.- Returns:
- the supplied string builder.
-
shouldLog
Tests if this logger will output messages of the given level. -
debug
Logs a debug message.- Parameters:
message
- the text of the message.args
- a series of zero or more key/value pairs followed by an optionalThrowable
cause.
-
info
Logs an info message.- Parameters:
message
- the text of the message.args
- a series of zero or more key/value pairs followed by an optionalThrowable
cause.
-
warning
Logs a warning message.- Parameters:
message
- the text of the message.args
- a series of zero or more key/value pairs followed by an optionalThrowable
cause.
-
error
Logs an error message.- Parameters:
message
- the text of the message.args
- a series of zero or more key/value pairs followed by an optionalThrowable
cause.
-