logger

Namespace

logger

Description:
  • Logging utility
Source:

Classes

LoggerModule

Methods

(static) exports.colourise(str, colourFunc) → {String}

Description:
  • Colours an input string using a chalk function or colour name
Source:
Parameters:
Name Type Description
str String The string to colourise
colourFunc String | function A chalk colour function or string name of a chalk colour
Returns:
The colourised string
Type
String

(static) exports.getDateStamp(config) → {String}

Description:
  • Returns a formatted date stamp string based on config
Source:
Parameters:
Name Type Description
config Object Logger configuration object
Properties
Name Type Description
timestamp Boolean Whether to include a timestamp
dateFormat String Date format ('iso' or 'short')
Returns:
The formatted date stamp (empty string if timestamps disabled)
Type
String

(static) exports.getModuleOverrides(levelsConfig, level) → {Array.<String>}

Description:
  • Returns a list of module-specific log level overrides from the levels config
Source:
Parameters:
Name Type Description
levelsConfig Array.<String> Array of level configuration strings
level String The log level to find overrides for
Returns:
Array of override strings (e.g. ['debug.mymod', '!debug.other'])
Type
Array.<String>

(static) exports.isLevelEnabled(levelsConfig, level) → {Boolean}

Description:
  • Determines whether a specific log level is enabled in the levels config
Source:
Parameters:
Name Type Description
levelsConfig Array.<String> Array of level configuration strings
level String The log level to check (e.g. 'error', 'warn', 'debug')
Returns:
Whether the level is enabled
Type
Boolean

(static) exports.isLoggingEnabled(configLevels, level, id) → {Boolean}

Description:
  • Returns whether a message should be logged based on the resolved config
Source:
Parameters:
Name Type Description
configLevels Object The resolved levels config object (e.g. { error: { enable, moduleOverrides }, ... })
level String Logging level (e.g. 'error', 'warn', 'debug')
id String Id of log caller (module name)
Returns:
Whether logging is enabled for this level and caller
Type
Boolean