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 TypeMethodDescriptionvoid
Logs a message withconfig level
.void
Logs a message withconfig level
.void
Logs entry into method.void
Logs entry into method with single parameter.void
Logs entry into method with multiple parameters.void
Logs a return from method.void
Logs a return from method with result.void
Logs a message withfine level
.void
Logs a message withfine level
.void
Logs a message withfiner level
.void
Logs a message withfiner level
.void
Logs a message withfinest level
.void
Logs a message withfinest level
.static TruffleLogger
Find or create a root logger for a given language or instrument.static TruffleLogger
Find or create a logger for a given language or instrument class.static TruffleLogger
Find or create a logger for a given language or instrument.getName()
Returns the name of the logger.Returns the parentTruffleLogger
.void
Logs a message withinfo level
.void
Logs a message withinfo level
.boolean
isLoggable
(Level level) Checks if a message of the given level would be logged by this logger.void
Logs a message.void
Logs a message with single parameter.void
Logs a message with multiple parameters.void
Logs a message with an exception.void
Logs a message with an exception.void
Logs a message.void
Logs a message, specifying source class and source method.void
Logs a message with single parameter, specifying source class and source method.void
Log a message with multiple parameters, specifying source class and source method.void
Logs a message with an exception, specifying source class and source method.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.void
Logs a message, specifying source class and source method.void
Logs a message withsevere level
.void
Logs a message withsevere level
.<T extends Throwable>
TLogs throwing an exception.void
Logs a message withwarning level
.void
Logs 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
- ifid
is nullIllegalArgumentException
- ifid
is 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
- theClass
to create a logger for- Returns:
- a
TruffleLogger
- Throws:
NullPointerException
- ifid
orforClass
is nullIllegalArgumentException
- ifid
is 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 aloggerName
is null or empty a root logger for language or instrument is returned- Returns:
- a
TruffleLogger
- Throws:
NullPointerException
- ifid
is nullIllegalArgumentException
- ifid
is not a valid language or instrument id.- Since:
- 19.0
-
config
Logs a message withconfig level
.If the logger is enabled for the
config level
the message is sent to theHandler
registered 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 level
the message is sent to theHandler
registered in the currentContext
.- Parameters:
messageSupplier
- theSupplier
called 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
LogRecord
with message "ENTRY" and the givensourceMethod
andsourceClass
is 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
LogRecord
with message "ENTRY", the givensourceMethod
andsourceClass
and 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
LogRecord
with message "ENTRY", the givensourceMethod
andsourceClass
and 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
LogRecord
with message "RETURN" and the givensourceMethod
andsourceClass
is 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
LogRecord
with message "RETURN", the givensourceMethod
andsourceClass
and 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 level
the message is sent to theHandler
registered 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 level
the message is sent to theHandler
registered in the currentContext
.- Parameters:
messageSupplier
- theSupplier
called to produce the message to log- Since:
- 19.0
-
finer
Logs a message withfiner level
.If the logger is enabled for the
finer level
the message is sent to theHandler
registered 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 level
the message is sent to theHandler
registered in the currentContext
.- Parameters:
messageSupplier
- theSupplier
called to produce the message to log- Since:
- 19.0
-
finest
Logs a message withfinest level
.If the logger is enabled for the
finest level
the message is sent to theHandler
registered 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 level
the message is sent to theHandler
registered in the currentContext
.- Parameters:
messageSupplier
- theSupplier
called to produce the message to log- Since:
- 19.0
-
info
Logs a message withinfo level
.If the logger is enabled for the
info level
the message is sent to theHandler
registered 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 level
the message is sent to theHandler
registered in the currentContext
.- Parameters:
messageSupplier
- theSupplier
called to produce the message to log- Since:
- 19.0
-
severe
Logs a message withsevere level
.If the logger is enabled for the
severe level
the message is sent to theHandler
registered 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 level
the message is sent to theHandler
registered in the currentContext
.- Parameters:
messageSupplier
- theSupplier
called 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
LogRecord
with message "THROW",the givensourceMethod
andsourceClass
andthrown
is 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 level
the message is sent to theHandler
registered 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 level
the message is sent to theHandler
registered in the currentContext
.- Parameters:
messageSupplier
- theSupplier
called to produce the message to log- Since:
- 19.0
-
log
-
log
-
log
-
log
-
log
-
log
-
logp
Logs a message, specifying source class and source method.If the logger is enabled for the given
level
the message is sent to theHandler
registered in the currentContext
.- Parameters:
level
- the requiredLevel
sourceClass
- 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) -
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
level
the message is sent to theHandler
registered in the currentContext
.- Parameters:
level
- the requiredLevel
sourceClass
- 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
level
the message is sent to theHandler
registered in the currentContext
.- Parameters:
level
- the requiredLevel
sourceClass
- 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
level
the message is sent to theHandler
registered in the currentContext
.- Parameters:
level
- the requiredLevel
sourceClass
- 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) -
getName
-
getParent
Returns the parentTruffleLogger
.- Returns:
- the parent
TruffleLogger
or null when theTruffleLogger
has 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
-