public final class Logging extends java.lang.Object
There are multiple log levels supported.
Modifier and Type | Class and Description |
---|---|
private static class |
Logging.RememberWarningHandler |
Modifier and Type | Field and Description |
---|---|
static java.util.logging.Level |
LEVEL_DEBUG
The josm internal log level to print debug output
|
static java.util.logging.Level |
LEVEL_ERROR
The josm internal log level indicating a severe error in the application that usually leads to a crash.
|
static java.util.logging.Level |
LEVEL_INFO
The josm internal log level to use for important events that will be useful when debugging problems
|
static java.util.logging.Level |
LEVEL_TRACE
The finest log level josm supports.
|
static java.util.logging.Level |
LEVEL_WARN
The josm internal log level to use when something that may lead to a crash or wrong behaviour has happened.
|
private static java.util.logging.Logger |
LOGGER |
private static Logging.RememberWarningHandler |
WARNINGS |
Modifier | Constructor and Description |
---|---|
private |
Logging() |
Modifier and Type | Method and Description |
---|---|
static void |
clearLastErrorAndWarnings()
Clear the list of last warnings
|
static void |
debug(java.lang.String message)
Prints a debug message if logging is on.
|
static void |
debug(java.lang.String pattern,
java.lang.Object... args)
Prints a formatted debug message if logging is on.
|
static void |
error(java.lang.String message)
Prints an error message if logging is on.
|
static void |
error(java.lang.String pattern,
java.lang.Object... args)
Prints a formatted error message if logging is on.
|
private static java.lang.String |
getErrorLog(java.lang.String message,
java.lang.Throwable t) |
private static java.lang.String |
getErrorLogWithStack(java.lang.String message,
java.lang.Throwable t) |
static java.lang.String |
getErrorMessage(java.lang.Throwable t)
Returns a human-readable message of error, also usable for developers.
|
static java.util.List<java.lang.String> |
getLastErrorAndWarnings()
Get the last error and warning messages in the order in which they were received.
|
static java.util.logging.Logger |
getLogger()
Provides direct access to the logger used.
|
static void |
info(java.lang.String message)
Prints a info message if logging is on.
|
static void |
info(java.lang.String pattern,
java.lang.Object... args)
Prints a formatted info message if logging is on.
|
static boolean |
isLoggingEnabled(java.util.logging.Level level)
Tests if a given log level is enabled.
|
static void |
log(java.util.logging.Level level,
java.lang.String message,
java.lang.Throwable t)
Logs a throwable that happened.
|
static void |
log(java.util.logging.Level level,
java.lang.Throwable t)
Logs a throwable that happened.
|
private static void |
logPrivate(java.util.logging.Level level,
java.lang.String message) |
private static void |
logPrivate(java.util.logging.Level level,
java.lang.String pattern,
java.lang.Object... args) |
private static void |
logPrivate(java.util.logging.Level level,
java.util.function.Supplier<java.lang.String> supplier) |
static void |
logWithStackTrace(java.util.logging.Level level,
java.lang.String message,
java.lang.Throwable t)
Logs a throwable that happened.
|
static void |
logWithStackTrace(java.util.logging.Level level,
java.lang.Throwable t)
Logs a throwable that happened.
|
static void |
setLogLevel(java.util.logging.Level level)
Set the global log level.
|
static void |
trace(java.lang.String message)
Prints a trace message if logging is on.
|
static void |
trace(java.lang.String pattern,
java.lang.Object... args)
Prints a formatted trace message if logging is on.
|
static void |
warn(java.lang.String message)
Prints a warning message if logging is on.
|
static void |
warn(java.lang.String pattern,
java.lang.Object... args)
Prints a formatted warning message if logging is on.
|
public static final java.util.logging.Level LEVEL_ERROR
public static final java.util.logging.Level LEVEL_WARN
public static final java.util.logging.Level LEVEL_INFO
public static final java.util.logging.Level LEVEL_DEBUG
public static final java.util.logging.Level LEVEL_TRACE
private static final java.util.logging.Logger LOGGER
private static final Logging.RememberWarningHandler WARNINGS
private Logging()
public static void setLogLevel(java.util.logging.Level level)
level
- The log level to usepublic static void error(java.lang.String message)
message
- The message to print.public static void error(java.lang.String pattern, java.lang.Object... args)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.pattern
- The formatted message to print.args
- The objects to insert into format string.public static void warn(java.lang.String message)
message
- The message to print.public static void warn(java.lang.String pattern, java.lang.Object... args)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.pattern
- The formatted message to print.args
- The objects to insert into format string.public static void info(java.lang.String message)
message
- The message to print.public static void info(java.lang.String pattern, java.lang.Object... args)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.pattern
- The formatted message to print.args
- The objects to insert into format string.public static void debug(java.lang.String message)
message
- The message to print.public static void debug(java.lang.String pattern, java.lang.Object... args)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.pattern
- The formatted message to print.args
- The objects to insert into format string.public static void trace(java.lang.String message)
message
- The message to print.public static void trace(java.lang.String pattern, java.lang.Object... args)
MessageFormat.format(java.lang.Object[], java.lang.StringBuffer, java.text.FieldPosition)
function to format text.pattern
- The formatted message to print.args
- The objects to insert into format string.public static void log(java.util.logging.Level level, java.lang.Throwable t)
level
- The level.t
- The throwable that should be logged.public static void log(java.util.logging.Level level, java.lang.String message, java.lang.Throwable t)
level
- The level.message
- An additional error messaget
- The throwable that caused the messagepublic static void logWithStackTrace(java.util.logging.Level level, java.lang.Throwable t)
level
- The level.t
- The throwable that should be logged.public static void logWithStackTrace(java.util.logging.Level level, java.lang.String message, java.lang.Throwable t)
level
- The level.message
- An additional error messaget
- The throwable that should be logged.private static void logPrivate(java.util.logging.Level level, java.lang.String pattern, java.lang.Object... args)
private static void logPrivate(java.util.logging.Level level, java.lang.String message)
private static void logPrivate(java.util.logging.Level level, java.util.function.Supplier<java.lang.String> supplier)
public static boolean isLoggingEnabled(java.util.logging.Level level)
debug(String, Object...)
messagelevel
- A lvele constant. You can e.g. use LEVEL_ERROR
true
if debug is enabled.private static java.lang.String getErrorLog(java.lang.String message, java.lang.Throwable t)
private static java.lang.String getErrorLogWithStack(java.lang.String message, java.lang.Throwable t)
public static java.lang.String getErrorMessage(java.lang.Throwable t)
t
- The errorpublic static void clearLastErrorAndWarnings()
public static java.util.List<java.lang.String> getLastErrorAndWarnings()
public static java.util.logging.Logger getLogger()
warn(String)
is prefered.