Public Member Functions | |
abstract LogListener | makeDefaultLogListener () |
abstract void | setLogListener (LogListener listener) |
abstract void | setMinimumSeverity (Severity severity) |
abstract void | writeLog (Severity severity, boolean raw, String tag, String message) |
abstract long | getTimestamp () |
abstract double | timeSince (long timestamp) |
Static Public Member Functions | |
static native LogManager | instance () |
Manages the listener for any logging events generated by LibMuse.
To disable logging:
setLogListener(null);
To install a custom log listener for your application:
setLogListener(your_log_listener);
To restore default logging to standard error (if you have previously changed the log listener):
setLogListener(makeDefaultLogListener());
An instance of the default listener is installed unless another listener is supplied. The default log listener prints all messages to standard error as they show up, without any buffering, using the following formatting rules:
For example, suppose that these packets showed up in order: {info, false, "A", 4, "thing A"}, {info, true, "FOO", 1, "+"}, {err, true, "BAR", 3, "-"}, {warn, false, "B", 2, "thing B"} where the second parameter idicates if this is a raw log message. The log output would be formatted roughly as such:
A [I 4.000] thing A +- B [W 2.000] thing B
In order to provide this formatting without buffering or losing messages, the default log listener uses a mutex, effectively making the logging subsystem single-threaded and IO-bound.
|
abstract |
Return the current timestamp.
The returned value is in microseconds since some epoch – January 1 1970 on UNIX, but possibly other values on other systems.
|
static |
Returns the shared log manager instance.
|
abstract |
Constructs and returns a default log listener.
|
abstract |
Sets the log listener.
There is only one log listener active at a time; hence this is just a plain setter rather than a register / unregister pair.
listener | the LogListener to use. |
|
abstract |
Set the minimum log severity.
Messages at or above this severity will be passed to the configured log listener. Messages below this severity will be dropped.
severity | the minimum log severity to log. |
|
abstract |
Return the time elapsed in seconds since the passed timestamp.
timestamp | The prior timestamp. |
|
abstract |
Write a log line.
This method sends messages to the configured log listener. It is exposed here primarily so that LibMuse can access it from its own platform-specific code, but there's nothing stopping you from using it and doing all your logging through LibMuse. Except please don't, because we may change the API at any time, and why would you?
The log's timestamp is the number of seconds since this log manager was created.
severity | The severity of this log message. |
raw | true if this is a raw log message (no formatting), false otherwise |
tag | The tag for this message. |
message | The log message. |