API: logging
Source:
log/logging.ts
Provides a wrapper for the underlying logging facility, allowing for categorized and leveled logging messages with support for variable arguments, including error objects.
Usage
import { logging } from "sdk/log";
let logger = logging.getLogger("org.eclipse.dirigible.mylogger");
logger.debug("Hello from {}!", "MyLogger");
logger.error("Oops", new Error("Something wrong happened"));
logger.error("Oops! Param 1: {}, param 2: {}", "param1Value", "param2Value", new Error("Something wrong happened"));Classes
Logging
The main entry point for the logging API. Use this class to obtain a named
logger instance.
Methods
getLogger
getLogger (loggerName:string):LoggerRetrieves or creates a Logger instance associated with a specific name.
The logger name is typically used to categorize log messages (e.g., 'com.app.service').
@param loggerName The name of the logger.
@returns A {@link Logger} instance.
Logger
Represents a named logger instance used for emitting log messages at various levels.
Methods
setLevel
setLevel (level:string):LoggerSets the logging level for this specific logger instance.
Messages below this threshold will be ignored.
@param level The desired logging level (e.g., 'TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR').
@returns The Logger instance for method chaining.
isDebugEnabled
isDebugEnabled ():booleanChecks if the DEBUG level is currently enabled for this logger.
@returns True if DEBUG logging is enabled, false otherwise.
isErrorEnabled
isErrorEnabled ():booleanChecks if the ERROR level is currently enabled for this logger.
@returns True if ERROR logging is enabled, false otherwise.
isWarnEnabled
isWarnEnabled ():booleanChecks if the WARN level is currently enabled for this logger.
@returns True if WARN logging is enabled, false otherwise.
isInfoEnabled
isInfoEnabled ():booleanChecks if the INFO level is currently enabled for this logger.
@returns True if INFO logging is enabled, false otherwise.
isTraceEnabled
isTraceEnabled ():booleanChecks if the TRACE level is currently enabled for this logger.
@returns True if TRACE logging is enabled, false otherwise.
log
log (msg:string, level:string):voidThe core logging method. Logs a message at the specified level, optionally
supporting parameters for message formatting and a final Error object for stack trace logging.
@param msg The log message template (e.g., "User {0} failed to connect: {1}").
@param level The logging level (e.g., 'DEBUG', 'ERROR').
@param [args] Optional arguments for message formatting. The last argument can be an Error object.
debug
debug (msg:string, ..._:any[]):voidLogs a message at the DEBUG level.
@param msg The log message template.
@param [args] Optional arguments for message formatting. The last argument can be an Error object.
info
info (msg:string, ..._:any[]):voidLogs a message at the INFO level.
@param msg The log message template.
@param [args] Optional arguments for message formatting. The last argument can be an Error object.
trace
trace (msg:string, ..._:any[]):voidLogs a message at the TRACE level.
@param msg The log message template.
@param [args] Optional arguments for message formatting. The last argument can be an Error object.
warn
warn (msg:string, ..._:any[]):voidLogs a message at the WARN level.
@param msg The log message template.
@param [args] Optional arguments for message formatting. The last argument can be an Error object.
error
error (msg:string, ..._:any[]):voidLogs a message at the ERROR level.
@param msg The log message template.
@param [args] Optional arguments for message formatting. The last argument can be an Error object.