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

# benchmark(msg) → {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 Description
msg StringLike

The message to be logged.

View Source logging.ts, line 758

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 832

The same logger instance.

this

# protected createLog(level, 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

The log level for this message.

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 739

A formatted log string with all components.

string

# debug(msg) → {void}

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

Logs a message at the debug level.

Parameters:
Name Type Description
msg StringLike

The message to be logged.

View Source logging.ts, line 792

void

# error(msg, eopt) → {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 <optional>

Optional error to include in the log.

View Source logging.ts, line 801

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 728

A new logger instance for the specified method.

Logger

# info(msg) → {void}

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

Logs a message at the info level.

Parameters:
Name Type Description
msg StringLike

The message to be logged.

View Source logging.ts, line 784

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 750

void

# 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 825

void

# silly(msg, verbosityopt) → {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.

View Source logging.ts, line 767

void

# trace(msg) → {void}

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

Logs a message at the trace level.

Parameters:
Name Type Description
msg StringLike

The message to be logged.

View Source logging.ts, line 817

void

# verbose(msg, verbosityopt) → {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.

View Source logging.ts, line 776

void

# warn(msg) → {void}

Logs a message at the warning level for potential issues.

Logs a message at the warning level.

Parameters:
Name Type Description
msg StringLike

The message to be logged.

View Source logging.ts, line 809

void