Elide GraalVM25.6.0-elide.4
All types
Versions and modules

TruffleLogger

Javaclassin com.oracle.truffle.apisince 19.0

public final class TruffleLogger
Inheritance
  1. Object
  2. TruffleLogger

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.0
public 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

Throws

NullPointerExceptionunchecked
if id is null
IllegalArgumentExceptionunchecked
if id is not a valid language or instrument id.
static TruffleLogger getLogger(String, Class<?>)

getLogger

staticsince 19.0
public 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
forClassClass<?>
the Class to create a logger for

Throws

NullPointerExceptionunchecked
if id or forClass is null
IllegalArgumentExceptionunchecked
if id is not a valid language or instrument id.
static TruffleLogger getLogger(String, String)

getLogger

staticsince 19.0
public 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 a loggerName is null or empty a root logger for language or instrument is returned

Throws

NullPointerExceptionunchecked
if id is null
IllegalArgumentExceptionunchecked
if id is not a valid language or instrument id.
void config(String)

config

since 19.0
public 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.0
public void config(Supplier<String> messageSupplier)

Logs 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.

Parameters

messageSupplierSupplier<String>
the Supplier called to produce the message to log
void entering(String, String)

entering

since 19.0
public void entering(String sourceClass, String sourceMethod)

Logs 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.

Parameters

sourceClassString
the entered class
sourceMethodString
the entered method
void entering(String, String, Object)

entering

since 19.0
public void entering(String sourceClass, String sourceMethod, Object parameter)

Logs 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.

Parameters

sourceClassString
the entered class
sourceMethodString
the entered method
parameterObject
the method parameter
void entering(String, String, Object[])

entering

since 19.0
public void entering(String sourceClass, String sourceMethod, Object[] parameters)

Logs 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.

Parameters

sourceClassString
the entered class
sourceMethodString
the entered method
parametersObject[]
the method parameters
void exiting(String, String)

exiting

since 19.0
public void exiting(String sourceClass, String sourceMethod)

Logs 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.

Parameters

sourceClassString
the exiting class
sourceMethodString
the exiting method
void exiting(String, String, Object)

exiting

since 19.0
public void exiting(String sourceClass, String sourceMethod, Object result)

Logs 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.

Parameters

sourceClassString
the exiting class
sourceMethodString
the exiting method
resultObject
the return value
void fine(String)

fine

since 19.0
public 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.0
public void fine(Supplier<String> messageSupplier)

Logs 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.

Parameters

messageSupplierSupplier<String>
the Supplier called to produce the message to log
void finer(String)

finer

since 19.0
public 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.0
public void finer(Supplier<String> messageSupplier)

Logs 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.

Parameters

messageSupplierSupplier<String>
the Supplier called to produce the message to log
void finest(String)

finest

since 19.0
public 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.0
public void finest(Supplier<String> messageSupplier)

Logs 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.

Parameters

messageSupplierSupplier<String>
the Supplier called to produce the message to log
void info(String)

info

since 19.0
public 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.0
public void info(Supplier<String> messageSupplier)

Logs 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.

Parameters

messageSupplierSupplier<String>
the Supplier called to produce the message to log
void severe(String)

severe

since 19.0
public 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.0
public void severe(Supplier<String> messageSupplier)

Logs 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.

Parameters

messageSupplierSupplier<String>
the Supplier called to produce the message to log
T throwing(String, String, T)

throwing

since 19.0
public <T extends Throwable> T throwing(String sourceClass, String sourceMethod, T thrown)

Logs 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

sourceClassString
the class throwing an exception
sourceMethodString
the method throwing an exception
thrownT
the thrown exception

Returns

T
No description.
void warning(String)

warning

since 19.0
public 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.0
public void warning(Supplier<String> messageSupplier)

Logs 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.

Parameters

messageSupplierSupplier<String>
the Supplier called to produce the message to log
void log(Level, String)

log

since 19.0
public void log(Level level, String message)

Logs a message.

If the logger is enabled for the given level the message is sent to the Handler registered in the current Context.

Parameters

levelLevel
the required Level
messageString
the message to log
void log(Level, Supplier<String>)

log

since 19.0
public void log(Level level, Supplier<String> messageSupplier)

Logs a message. The message is constructed only when the logger is enabled for the given level.

If the logger is enabled for the given level the message is sent to the Handler registered in the current Context.

Parameters

levelLevel
the required Level
messageSupplierSupplier<String>
the Supplier called to produce the message to log
void log(Level, String, Object)

log

since 19.0
public void log(Level level, String message, Object parameter)

Logs a message with single parameter.

If the logger is enabled for the given level the message is sent to the Handler registered in the current Context.

Parameters

levelLevel
the required Level
messageString
the message to log
parameterObject
the log message parameter
void log(Level, String, Object[])

log

since 19.0
public void log(Level level, String message, Object[] parameters)

Logs a message with multiple parameters.

If the logger is enabled for the given level the message is sent to the Handler registered in the current Context.

Parameters

levelLevel
the required Level
messageString
the message to log
parametersObject[]
the log message parameters
void log(Level, String, Throwable)

log

since 19.0
public void log(Level level, String message, Throwable thrown)

Logs a message with an exception.

If the logger is enabled for the given level the message is sent to the Handler registered in the current Context.

Parameters

levelLevel
the required Level
messageString
the message to log
thrownThrowable
the exception to log
void log(Level, Throwable, Supplier<String>)

log

since 19.0
public void log(Level level, Throwable thrown, Supplier<String> messageSupplier)

Logs a message with an exception. The message is constructed only when the logger is enabled for the given level.

If the logger is enabled for the given level the message is sent to the Handler registered in the current Context.

Parameters

levelLevel
the required Level
thrownThrowable
the exception to log
messageSupplierSupplier<String>
the Supplier called to produce the message to log
void logp(Level, String, String, String)

logp

since 19.0
public void logp(Level level, String sourceClass, String sourceMethod, String message)

Logs a message, specifying source class and source method.

If the logger is enabled for the given level the message is sent to the Handler registered in the current Context.

Parameters

levelLevel
the required Level
sourceClassString
the class issued the logging request
sourceMethodString
the method issued the logging request
messageString
the message to log
void logp(Level, String, String, Supplier<String>)

logp

since 19.0
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 given level.

If the logger is enabled for the given level the message is sent to the Handler registered in the current Context.

Parameters

levelLevel
the required Level
sourceClassString
the class issued the logging request
sourceMethodString
the method issued the logging request
messageSupplierSupplier<String>
the Supplier called to produce the message to log
void logp(Level, String, String, String, Object)

logp

since 19.0
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 the Handler registered in the current Context.

Parameters

levelLevel
the required Level
sourceClassString
the class issued the logging request
sourceMethodString
the method issued the logging request
messageString
the message to log
parameterObject
the log message parameter
void logp(Level, String, String, String, Object[])

logp

since 19.0
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 the Handler registered in the current Context.

Parameters

levelLevel
the required Level
sourceClassString
the class issued the logging request
sourceMethodString
the method issued the logging request
messageString
the message to log
parametersObject[]
the log message parameters
void logp(Level, String, String, String, Throwable)

logp

since 19.0
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 the Handler registered in the current Context.

Parameters

levelLevel
the required Level
sourceClassString
the class issued the logging request
sourceMethodString
the method issued the logging request
messageString
the message to log
thrownThrowable
the exception to log
void logp(Level, String, String, Throwable, Supplier<String>)

logp

since 19.0
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 given level.

If the logger is enabled for the given level the message is sent to the Handler registered in the current Context.

Parameters

levelLevel
the required Level
sourceClassString
the class issued the logging request
sourceMethodString
the method issued the logging request
thrownThrowable
the exception to log
messageSupplierSupplier<String>
the Supplier called to produce the message to log
String getName()

getName

since 19.0
public String getName()

Returns the name of the logger.

Returns

String
the logger name
TruffleLogger getParent()

getParent

since 19.0
public TruffleLogger getParent()

Returns the parent TruffleLogger.

Returns

TruffleLogger
the parent TruffleLogger or null when the TruffleLogger has no parent.
boolean isLoggable(Level)

isLoggable

since 19.0
public 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

Inherited members