Class

MiniLogger

MiniLogger(contextopt, confopt, baseContextopt)

Constructor

# new MiniLogger(contextopt, confopt, baseContextopt)

MiniLogger is a lightweight logging class that implements the Logger interface. It provides basic logging functionality with support for different log levels, verbosity, context-aware logging, and customizable formatting.

A minimal logger implementation.

Parameters:
Name Type Attributes Default Description
context string <optional>

The context (typically class name) this logger is associated with.

conf Partial.<LoggingConfig> <optional>

Optional configuration to override global settings.

baseContext Array.<string> <optional>
[]

The base context for the logger.

View Source logging.ts, line 8

Example
// Create a new logger for a class
const logger = new MiniLogger('MyClass');

// Log messages at different levels
logger.info('This is an info message');
logger.debug('This is a debug message');
logger.error('Something went wrong');

// Create a child logger for a specific method
const methodLogger = logger.for('myMethod');
methodLogger.verbose('Detailed information', 2);

// Log with custom configuration
logger.for('specialMethod', { style: true }).info('Styled message');

Methods

# action(action, codeopt, metaopt) → {void}

Action entries are a separate, more controlled channel from the rest of the Logger API - they carry no message, are not tied to any LogLevel, and always print regardless of the configured minimum level. The action name (plus its optional numeric code) is rendered where the level would otherwise appear, and the structured meta is always rendered too, regardless of the meta display setting. An entry's payload is exactly: the action string, an optional code, and meta - nothing else.

Logs an action: a discrete, named event carrying its own metadata rather than a severity level or a message.

Parameters:
Name Type Attributes Description
action string

The action name/identifier.

code number <optional>

An optional numeric classification code for the action.

meta LogMeta <optional>

Optional structured metadata, always rendered regardless of the meta display setting.

View Source logging.ts, line 1011

void

# benchmark(msg, metaopt) → {void}

Logs a message at the benchmark level if the current verbosity setting allows it.

Logs a message at the benchmark level.

Parameters:
Name Type Attributes Description
msg StringLike

The message to be logged.

meta object <optional>

Optional metadata to include with the entry.

View Source logging.ts, line 1001

void

# clear() → {this}

Returns the same logger instance so more contexts can be chained afterwards.

Clears any contextual overrides applied by for.

View Source logging.ts, line 1112

The same logger instance.

this

# protected createLog(levelopt, message, erroropt) → {string}

Generates a log string with timestamp, colored log level, context, and message.

Creates a formatted log string.

Parameters:
Name Type Attributes Description
level LogLevel <optional>

The log level for this message. Omitted (undefined) for action entries, which carry no severity level.

message StringLike | Error

The message to log or an Error object.

error Error <optional>

Optional error to extract stack trace to include in the log.

View Source logging.ts, line 962

A formatted log string with all components.

string

# critical(msg, eopt, metaopt) → {void}

Logs a message at the critical level for severe failures that need immediate attention.

Logs a message at the critical level.

Parameters:
Name Type Attributes Description
msg StringLike | Error

The message to be logged or an Error object.

e Error | object <optional>

Optional error or metadata to include in the log.

meta object <optional>

Optional metadata to include with the entry when an error is supplied.

View Source logging.ts, line 1031

void

# debug(msg, metaopt) → {void}

Logs a message at the debug level for detailed troubleshooting information.

Logs a message at the debug level.

Parameters:
Name Type Attributes Description
msg StringLike

The message to be logged.

meta object <optional>

Optional metadata to include with the entry.

View Source logging.ts, line 1069

void

# error(msg, eopt, metaopt) → {void}

Logs a message at the error level for errors and exceptions.

Logs a message at the error level.

Parameters:
Name Type Attributes Description
msg StringLike | Error

The message to be logged or an Error object.

e Error | object <optional>

Optional error or metadata to include in the log.

meta object <optional>

Optional metadata to include with the entry when an error is supplied.

View Source logging.ts, line 1079

void

# fatal(msg, eopt, metaopt) → {void}

Logs a message at the fatal level for unrecoverable failures.

Logs a message at the fatal level.

Parameters:
Name Type Attributes Description
msg StringLike | Error

The message to be logged or an Error object.

e Error | object <optional>

Optional error or metadata to include in the log.

meta object <optional>

Optional metadata to include with the entry when an error is supplied.

View Source logging.ts, line 1021

void

# for(methodopt, configopt, …args) → {Logger}

Returns a new logger instance with the current context extended by the specified method name.

Creates a child logger for a specific method or context.

Parameters:
Name Type Attributes Description
method string | function | object | Partial.<LoggingConfig> <optional>

The method name, function, or configuration to create a logger for.

config Partial.<LoggingConfig> <optional>

Optional configuration to override settings.

args Array.<any> <repeatable>

Additional arguments to pass to the logger factory.

View Source logging.ts, line 951

A new logger instance for the specified method.

Logger

# info(msg, metaopt) → {void}

Logs a message at the info level for general application information.

Logs a message at the info level.

Parameters:
Name Type Attributes Description
msg StringLike

The message to be logged.

meta object <optional>

Optional metadata to include with the entry.

View Source logging.ts, line 1060

void

# protected log(level, msg, erroropt) → {void}

Checks if the message should be logged based on the current log level, then uses the appropriate console method to output the formatted log.

Logs a message with the specified log level.

Parameters:
Name Type Attributes Description
level LogLevel

The log level of the message.

msg StringLike | Error

The message to be logged or an Error object.

error Error <optional>

Optional stack trace to include in the log.

View Source logging.ts, line 992

void

# protected methodFor(level)

Maps each LogLevel to the console method that should carry it (error levels to console.error, warn to console.warn, etc).

Resolves the console method used to emit a given log level.

Parameters:
Name Type Description
level LogLevel

The log level to resolve a console method for.

View Source logging.ts, line 971

The console method for that level.

# setConfig(config) → {void}

Merges the provided configuration with the existing configuration.

Updates the logger configuration.

Parameters:
Name Type Description
config Partial.<LoggingConfig>

The configuration options to apply.

View Source logging.ts, line 1105

void

# silly(msg, verbosityopt, metaopt) → {void}

Logs a message at the silly level if the current verbosity setting allows it.

Logs a message at the silly level.

Parameters:
Name Type Attributes Default Description
msg StringLike

The message to be logged.

verbosity number <optional>
0

The verbosity level of the message.

meta object <optional>

Optional metadata to include with the entry.

View Source logging.ts, line 1041

void

# trace(msg, metaopt) → {void}

Logs a message at the trace level for tracing code execution.

Logs a message at the trace level.

Parameters:
Name Type Attributes Description
msg StringLike

The message to be logged.

meta object <optional>

Optional metadata to include with the entry.

View Source logging.ts, line 1097

void

# verbose(msg, verbosityopt, metaopt) → {void}

Logs a message at the verbose level if the current verbosity setting allows it.

Logs a message at the verbose level.

Parameters:
Name Type Attributes Default Description
msg StringLike

The message to be logged.

verbosity number <optional>
0

The verbosity level of the message.

meta object <optional>

Optional metadata to include with the entry.

View Source logging.ts, line 1051

void

# warn(msg, metaopt) → {void}

Logs a message at the warning level for potential issues.

Logs a message at the warning level.

Parameters:
Name Type Attributes Description
msg StringLike

The message to be logged.

meta object <optional>

Optional metadata to include with the entry.

View Source logging.ts, line 1088

void

# protected write(method, formatted) → {void}

The single place every logging method funnels through to actually write output, so console access stays in one spot.

Emits an already-formatted log line.

Parameters:
Name Type Description
method

The console method to invoke (e.g. console.log, console.error).

formatted string

The fully formatted log line, as produced by createLog.

View Source logging.ts, line 981

void