Class TruffleLogger
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.
- Since:
- 19.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidLogs a message withconfig level.voidLogs a message withconfig level.voidLogs entry into method.voidLogs entry into method with single parameter.voidLogs entry into method with multiple parameters.voidLogs a return from method.voidLogs a return from method with result.voidLogs a message withfine level.voidLogs a message withfine level.voidLogs a message withfiner level.voidLogs a message withfiner level.voidLogs a message withfinest level.voidLogs a message withfinest level.static TruffleLoggerFind or create a root logger for a given language or instrument.static TruffleLoggerFind or create a logger for a given language or instrument class.static TruffleLoggerFind or create a logger for a given language or instrument.getName()Returns the name of the logger.Returns the parentTruffleLogger.voidLogs a message withinfo level.voidLogs a message withinfo level.booleanisLoggable(Level level) Checks if a message of the given level would be logged by this logger.voidLogs a message.voidLogs a message with single parameter.voidLogs a message with multiple parameters.voidLogs a message with an exception.voidLogs a message with an exception.voidLogs a message.voidLogs a message, specifying source class and source method.voidLogs a message with single parameter, specifying source class and source method.voidLog a message with multiple parameters, specifying source class and source method.voidLogs a message with an exception, specifying source class and source method.voidlogp(Level level, String sourceClass, String sourceMethod, Throwable thrown, Supplier<String> messageSupplier) Logs a message with an exception, specifying source class and source method.voidLogs a message, specifying source class and source method.voidLogs a message withsevere level.voidLogs a message withsevere level.<T extends Throwable>
TLogs throwing an exception.voidLogs a message withwarning level.voidLogs a message withwarning level.
-
Method Details
-
getLogger
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:
id- the unique id of language or instrument- Returns:
- a
TruffleLogger - Throws:
NullPointerException- ifidis nullIllegalArgumentException- ifidis not a valid language or instrument id.- Since:
- 19.0
-
getLogger
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:
id- the unique id of language or instrumentforClass- theClassto create a logger for- Returns:
- a
TruffleLogger - Throws:
NullPointerException- ifidorforClassis nullIllegalArgumentException- ifidis not a valid language or instrument id.- Since:
- 19.0
-
getLogger
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:
id- the unique id of language or instrumentloggerName- the the name of aTruffleLogger, if aloggerNameis null or empty a root logger for language or instrument is returned- Returns:
- a
TruffleLogger - Throws:
NullPointerException- ifidis nullIllegalArgumentException- ifidis not a valid language or instrument id.- Since:
- 19.0
-
config
Logs a message withconfig level.If the logger is enabled for the
config levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
message- the message to log- Since:
- 19.0
-
config
Logs a message withconfig level. The message is constructed only when the logger is enabled for theconfig level.If the logger is enabled for the
config levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
messageSupplier- theSuppliercalled to produce the message to log- Since:
- 19.0
-
entering
Logs entry into method.This method can be used to log entry into a method. A
LogRecordwith message "ENTRY" and the givensourceMethodandsourceClassis logged withfiner level.- Parameters:
sourceClass- the entered classsourceMethod- the entered method- Since:
- 19.0
-
entering
Logs entry into method with single parameter.This method can be used to log entry into a method. A
LogRecordwith message "ENTRY", the givensourceMethodandsourceClassand given parameter is logged withfiner level.- Parameters:
sourceClass- the entered classsourceMethod- the entered methodparameter- the method parameter- Since:
- 19.0
-
entering
Logs entry into method with multiple parameters.This method can be used to log entry into a method. A
LogRecordwith message "ENTRY", the givensourceMethodandsourceClassand given parameters is logged withfiner level.- Parameters:
sourceClass- the entered classsourceMethod- the entered methodparameters- the method parameters- Since:
- 19.0
-
exiting
Logs a return from method.This method can be used to log return from a method. A
LogRecordwith message "RETURN" and the givensourceMethodandsourceClassis logged withfiner level.- Parameters:
sourceClass- the exiting classsourceMethod- the exiting method- Since:
- 19.0
-
exiting
Logs a return from method with result.This method can be used to log return from a method. A
LogRecordwith message "RETURN", the givensourceMethodandsourceClassand method result is logged withfiner level.- Parameters:
sourceClass- the exiting classsourceMethod- the exiting methodresult- the return value- Since:
- 19.0
-
fine
Logs a message withfine level.If the logger is enabled for the
fine levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
message- the message to log- Since:
- 19.0
-
fine
Logs a message withfine level. The message is constructed only when the logger is enabled for thefine level.If the logger is enabled for the
fine levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
messageSupplier- theSuppliercalled to produce the message to log- Since:
- 19.0
-
finer
Logs a message withfiner level.If the logger is enabled for the
finer levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
message- the message to log- Since:
- 19.0
-
finer
Logs a message withfiner level. The message is constructed only when the logger is enabled for thefiner level.If the logger is enabled for the
finer levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
messageSupplier- theSuppliercalled to produce the message to log- Since:
- 19.0
-
finest
Logs a message withfinest level.If the logger is enabled for the
finest levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
message- the message to log- Since:
- 19.0
-
finest
Logs a message withfinest level. The message is constructed only when the logger is enabled for thefinest level.If the logger is enabled for the
finest levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
messageSupplier- theSuppliercalled to produce the message to log- Since:
- 19.0
-
info
Logs a message withinfo level.If the logger is enabled for the
info levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
message- the message to log- Since:
- 19.0
-
info
Logs a message withinfo level. The message is constructed only when the logger is enabled for theinfo level.If the logger is enabled for the
info levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
messageSupplier- theSuppliercalled to produce the message to log- Since:
- 19.0
-
severe
Logs a message withsevere level.If the logger is enabled for the
severe levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
message- the message to log- Since:
- 19.0
-
severe
Logs a message withsevere level. The message is constructed only when the logger is enabled for thesevere level.If the logger is enabled for the
severe levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
messageSupplier- theSuppliercalled to produce the message to log- Since:
- 19.0
-
throwing
Logs throwing an exception.This method can be used to log exception thrown from a method. A
LogRecordwith message "THROW",the givensourceMethodandsourceClassandthrownis logged withfiner level.- Parameters:
sourceClass- the class throwing an exceptionsourceMethod- the method throwing an exceptionthrown- the thrown exception- Since:
- 19.0
-
warning
Logs a message withwarning level.If the logger is enabled for the
warning levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
message- the message to log- Since:
- 19.0
-
warning
Logs a message withwarning level. The message is constructed only when the logger is enabled for thewarning level.If the logger is enabled for the
warning levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
messageSupplier- theSuppliercalled to produce the message to log- Since:
- 19.0
-
log
-
log
Logs a message. The message is constructed only when the logger is enabled for the givenlevel.If the logger is enabled for the given
levelthe message is sent to theHandlerregistered in the currentContext. -
log
-
log
-
log
-
log
Logs a message with an exception. The message is constructed only when the logger is enabled for the givenlevel.If the logger is enabled for the given
levelthe message is sent to theHandlerregistered in the currentContext. -
logp
Logs a message, specifying source class and source method.If the logger is enabled for the given
levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
level- the requiredLevelsourceClass- the class issued the logging requestsourceMethod- the method issued the logging requestmessage- the message to log- Since:
- 19.0
-
logp
public void logp(Level level, String sourceClass, String sourceMethod, Supplier<String> messageSupplier) Logs a message, specifying source class and source method. The message is constructed only when the logger is enabled for the givenlevel.If the logger is enabled for the given
levelthe message is sent to theHandlerregistered in the currentContext. -
logp
public void logp(Level level, String sourceClass, String sourceMethod, String message, Object parameter) Logs a message with single parameter, specifying source class and source method.If the logger is enabled for the given
levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
level- the requiredLevelsourceClass- the class issued the logging requestsourceMethod- the method issued the logging requestmessage- the message to logparameter- the log message parameter- Since:
- 19.0
-
logp
public void logp(Level level, String sourceClass, String sourceMethod, String message, Object[] parameters) Log a message with multiple parameters, specifying source class and source method.If the logger is enabled for the given
levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
level- the requiredLevelsourceClass- the class issued the logging requestsourceMethod- the method issued the logging requestmessage- the message to logparameters- the log message parameters- Since:
- 19.0
-
logp
public void logp(Level level, String sourceClass, String sourceMethod, String message, Throwable thrown) Logs a message with an exception, specifying source class and source method.If the logger is enabled for the given
levelthe message is sent to theHandlerregistered in the currentContext.- Parameters:
level- the requiredLevelsourceClass- the class issued the logging requestsourceMethod- the method issued the logging requestmessage- the message to logthrown- the exception to log- Since:
- 19.0
-
logp
public void logp(Level level, String sourceClass, String sourceMethod, Throwable thrown, Supplier<String> messageSupplier) Logs a message with an exception, specifying source class and source method. The message is constructed only when the logger is enabled for the givenlevel.If the logger is enabled for the given
levelthe message is sent to theHandlerregistered in the currentContext. -
getName
-
getParent
Returns the parentTruffleLogger.- Returns:
- the parent
TruffleLoggeror null when theTruffleLoggerhas no parent. - Since:
- 19.0
-
isLoggable
Checks if a message of the given level would be logged by this logger.- Parameters:
level- the required logging level- Returns:
- true if message is loggable by this logger
- Since:
- 19.0
-