Module jls.lang.logger

Returns the default logger implementation.

A Logger object is used to record events during the execution of Lua modules. This default implementation provides a simple way for module owner to expose debugging information and for module user to access this information. This default implementation could be configured to redirect log messages to another logging facility.

The default log level is warning. The default formatting consists in prefixing the message by the date time as ISO 8601 and the log level. The default writing consists in printing the log message to the standard error stream, adding a new line and flushing.

The JLS_LOGGER_LEVEL environment variable could be used to indicate the log level to use.

Usage:

    local logger = require('jls.lang.logger')
    logger:info('Some usefull information message')
    
    if logger:isLoggable(logger.DEBUG) then
      logger:debug('Some debug message')
    end
    

Tables

LEVEL The available log levels.

Class Logger

Logger:new (level) Creates a new logger with the specified level.
logger:getLevel () Returns the log level for this logger.
logger:setLevel (level) Sets the log level for this logger.
logger:isLoggable (level) Tells wether or not a message of the specified level will be logged by this logger.
logger:log (level, message) Logs the specified message with the specified level.
logger:error (message) Logs the specified message with the ERROR level.
logger:warn (message) Logs the specified message with the WARN level.
logger:info (message) Logs the specified message with the INFO level.
logger:config (message) Logs the specified message with the CONFIG level.
logger:debug (message) Logs the specified message with the DEBUG level.
logger:fine (message) Logs the specified message with the FINE level.
logger:finer (message) Logs the specified message with the FINER level.
logger:finest (message) Logs the specified message with the FINEST level.


Tables

LEVEL
The available log levels. The level fields are also provided as shortcut to the default implementation.

Fields:

  • ERROR The error level is the highest level
  • WARN The warning level
  • INFO The information level
  • CONFIG The configuration level
  • FINE The fine level
  • FINER The finer level
  • FINEST The finest level
  • DEBUG The debug level Do not use, shall be removed
  • ALL The all level is the lowest level

Class Logger

A Logger class. A Logger object is used to log messages for a specific system or application component.
Logger:new (level)
Creates a new logger with the specified level.

Parameters:

  • level The log level.

Returns:

    a new logger

Usage:

    local console = require('jls.lang.logger'):getClass():new()
    console:info('Some usefull information message')
logger:getLevel ()
Returns the log level for this logger.

Returns:

    the log level for this logger.
logger:setLevel (level)
Sets the log level for this logger.

Parameters:

  • level The log level.
logger:isLoggable (level)
Tells wether or not a message of the specified level will be logged by this logger.

Parameters:

  • level The log level to check.

Returns:

    true if a message of the specified level will be logged by this logger.
logger:log (level, message)
Logs the specified message with the specified level.

Parameters:

  • level The log level.
  • message The log message.
logger:error (message)
Logs the specified message with the ERROR level.

Parameters:

  • message The log message.
logger:warn (message)
Logs the specified message with the WARN level.

Parameters:

  • message The log message.
logger:info (message)
Logs the specified message with the INFO level.

Parameters:

  • message The log message.
logger:config (message)
Logs the specified message with the CONFIG level.

Parameters:

  • message The log message.
logger:debug (message)
Logs the specified message with the DEBUG level.

Parameters:

  • message The log message.
logger:fine (message)
Logs the specified message with the FINE level.

Parameters:

  • message The log message.
logger:finer (message)
Logs the specified message with the FINER level.

Parameters:

  • message The log message.
logger:finest (message)
Logs the specified message with the FINEST level.

Parameters:

  • message The log message.
generated by LDoc 1.4.6 Last updated 2022-01-22 16:32:56