TruffleLogger
public final class TruffleLogger- Inheritance
ObjectTruffleLogger
Support for logging in Truffle languages and instruments.
The logger's Level configuration is done using the Context's options. The level option key has the following format: log.languageId.className.level or log.instrumentId.className.level. The value is either the name of pre-defined Level constant or a numeric Level value. If not explicitly set in Context's options the level is inherited from the parent logger.
The TruffleLogger supports message parameters of primitive types and strings. The object parameters are converted into string value before they are passed to the Handler.
The TruffleLogger instances are safe to be used on compiled code paths as well as from multiple-threads.
Methods38
static TruffleLogger getLogger(String)
getLogger
staticsince 19.0public static TruffleLogger getLogger(String id)Find or create a root logger for a given language or instrument. If the root logger for given language or instrument already exists it's returned, otherwise a new root logger is created.
Parameters
idString- the unique id of language or instrument
Returns
Throws
NullPointerExceptionunchecked- if
idis null IllegalArgumentExceptionunchecked- if
idis not a valid language or instrument id.
static TruffleLogger getLogger(String, Class<?>)
getLogger
staticsince 19.0public static TruffleLogger getLogger(String id, Class< ?> forClass)Find or create a logger for a given language or instrument class. If a logger for the class already exists it's returned, otherwise a new logger is created.
Parameters
idString- the unique id of language or instrument
Returns
Throws
NullPointerExceptionunchecked- if
idorforClassis null IllegalArgumentExceptionunchecked- if
idis not a valid language or instrument id.
static TruffleLogger getLogger(String, String)
getLogger
staticsince 19.0public static TruffleLogger getLogger(String id, String loggerName)Find or create a logger for a given language or instrument. If a logger with given name already exists it's returned, otherwise a new logger is created.
Parameters
idString- the unique id of language or instrument
loggerNameString- the name of a
TruffleLogger, if aloggerNameis null or empty a root logger for language or instrument is returned
Returns
Throws
NullPointerExceptionunchecked- if
idis null IllegalArgumentExceptionunchecked- if
idis not a valid language or instrument id.
void config(String)
config
since 19.0public void config(String message)Logs a message with config level.
If the logger is enabled for the config level the message is sent to the Handler registered in the current Context.
Parameters
messageString- the message to log
void config(Supplier<String>)
config
since 19.0Logs a message with config level. The message is constructed only when the logger is enabled for the config level.
If the logger is enabled for the config level the message is sent to the Handler registered in the current Context.
void entering(String, String)
entering
since 19.0Logs entry into method.
This method can be used to log entry into a method. A LogRecord with message "ENTRY" and the given sourceMethod and sourceClass is logged with finer level.
void entering(String, String, Object)
entering
since 19.0Logs entry into method with single parameter.
This method can be used to log entry into a method. A LogRecord with message "ENTRY", the given sourceMethod and sourceClass and given parameter is logged with finer level.
void entering(String, String, Object[])
entering
since 19.0Logs entry into method with multiple parameters.
This method can be used to log entry into a method. A LogRecord with message "ENTRY", the given sourceMethod and sourceClass and given parameters is logged with finer level.
void exiting(String, String)
exiting
since 19.0Logs a return from method.
This method can be used to log return from a method. A LogRecord with message "RETURN" and the given sourceMethod and sourceClass is logged with finer level.
void exiting(String, String, Object)
exiting
since 19.0Logs a return from method with result.
This method can be used to log return from a method. A LogRecord with message "RETURN", the given sourceMethod and sourceClass and method result is logged with finer level.
void fine(String)
fine
since 19.0public void fine(String message)Logs a message with fine level.
If the logger is enabled for the fine level the message is sent to the Handler registered in the current Context.
Parameters
messageString- the message to log
void fine(Supplier<String>)
fine
since 19.0Logs a message with fine level. The message is constructed only when the logger is enabled for the fine level.
If the logger is enabled for the fine level the message is sent to the Handler registered in the current Context.
void finer(String)
finer
since 19.0public void finer(String message)Logs a message with finer level.
If the logger is enabled for the finer level the message is sent to the Handler registered in the current Context.
Parameters
messageString- the message to log
void finer(Supplier<String>)
finer
since 19.0Logs a message with finer level. The message is constructed only when the logger is enabled for the finer level.
If the logger is enabled for the finer level the message is sent to the Handler registered in the current Context.
void finest(String)
finest
since 19.0public void finest(String message)Logs a message with finest level.
If the logger is enabled for the finest level the message is sent to the Handler registered in the current Context.
Parameters
messageString- the message to log
void finest(Supplier<String>)
finest
since 19.0Logs a message with finest level. The message is constructed only when the logger is enabled for the finest level.
If the logger is enabled for the finest level the message is sent to the Handler registered in the current Context.
void info(String)
info
since 19.0public void info(String message)Logs a message with info level.
If the logger is enabled for the info level the message is sent to the Handler registered in the current Context.
Parameters
messageString- the message to log
void info(Supplier<String>)
info
since 19.0Logs a message with info level. The message is constructed only when the logger is enabled for the info level.
If the logger is enabled for the info level the message is sent to the Handler registered in the current Context.
void severe(String)
severe
since 19.0public void severe(String message)Logs a message with severe level.
If the logger is enabled for the severe level the message is sent to the Handler registered in the current Context.
Parameters
messageString- the message to log
void severe(Supplier<String>)
severe
since 19.0Logs a message with severe level. The message is constructed only when the logger is enabled for the severe level.
If the logger is enabled for the severe level the message is sent to the Handler registered in the current Context.
T throwing(String, String, T)
throwing
since 19.0Logs throwing an exception.
This method can be used to log exception thrown from a method. A LogRecord with message "THROW",the given sourceMethod and sourceClass and thrown is logged with finer level.
Parameters
Returns
T- No description.
void warning(String)
warning
since 19.0public void warning(String message)Logs a message with warning level.
If the logger is enabled for the warning level the message is sent to the Handler registered in the current Context.
Parameters
messageString- the message to log
void warning(Supplier<String>)
warning
since 19.0Logs a message with warning level. The message is constructed only when the logger is enabled for the warning level.
If the logger is enabled for the warning level the message is sent to the Handler registered in the current Context.
void log(Level, String)
void log(Level, Supplier<String>)
void log(Level, String, Object)
void log(Level, String, Object[])
void log(Level, String, Throwable)
void log(Level, Throwable, Supplier<String>)
void logp(Level, String, String, String)
void logp(Level, String, String, Supplier<String>)
logp
since 19.0public void logp(
Level level,
String sourceClass,
String sourceMethod,
Supplier< String> messageSupplier
)void logp(Level, String, String, String, Object)
logp
since 19.0public void logp(
Level level,
String sourceClass,
String sourceMethod,
String message,
Object parameter
)void logp(Level, String, String, String, Object[])
logp
since 19.0public void logp(
Level level,
String sourceClass,
String sourceMethod,
String message,
Object[] parameters
)void logp(Level, String, String, String, Throwable)
logp
since 19.0public void logp(
Level level,
String sourceClass,
String sourceMethod,
String message,
Throwable thrown
)void logp(Level, String, String, Throwable, Supplier<String>)
logp
since 19.0public void logp(
Level level,
String sourceClass,
String sourceMethod,
Throwable thrown,
Supplier< String> messageSupplier
)String getName()
TruffleLogger getParent()
getParent
since 19.0public TruffleLogger getParent()Returns the parent TruffleLogger.
Returns
TruffleLogger- the parent
TruffleLoggeror null when theTruffleLoggerhas no parent.
boolean isLoggable(Level)
isLoggable
since 19.0public boolean isLoggable(Level level)Checks if a message of the given level would be logged by this logger.
Parameters
levelLevel- the required logging level
Returns
boolean- true if message is loggable by this logger