Logger

Logging Service Class.

This class provides a unified interface for logging messages to different targets:

  • Console (default): Logs messages directly to the terminal.
  • CSV: Appends log messages in CSV format to a text file.
  • SQLite: Inserts log messages into a SQLite database for advanced querying using Bun's built-in API.

Constructor

new Logger(options)

Creates an instance of the Logger.

Creates an instance of the Logger.

Parameters:
NameTypeDescription
optionsLoggerOptions

Configuration options for the logger.

Methods

close()

Closes any resources used by the logger.

Closes any resources used by the logger.

For SQLite logging, this method ensures the database connection is properly terminated.

close()

Closes any resources used by the logger.

Closes any resources used by the logger.

For SQLite logging, this method ensures the database connection is properly terminated.

log(level, message)

Logs a message with a specified severity level.

Logs a message with a specified severity level.

Parameters:
NameTypeDescription
levelstring

The severity level (e.g., 'info', 'warn', 'error', 'debug').

messagestring

The log message to be recorded.

log(level, message)

Logs a message with a specified severity level.

Logs a message with a specified severity level.

Parameters:
NameTypeDescription
levelstring

The severity level (e.g., 'info', 'warn', 'error', 'debug').

messagestring

The log message to be recorded.

Logger

Logging Service Class.

This class provides a unified interface for logging messages to different targets:

  • Console (default): Logs messages directly to the terminal.
  • CSV: Appends log messages in CSV format to a text file.
  • SQLite: Inserts log messages into a SQLite database for advanced querying using Bun's built-in API.

Constructor

new Logger(options)

Creates an instance of the Logger.

Creates an instance of the Logger.

Parameters:
NameTypeDescription
optionsLoggerOptions

Configuration options for the logger.

Methods

close()

Closes any resources used by the logger.

Closes any resources used by the logger.

For SQLite logging, this method ensures the database connection is properly terminated.

close()

Closes any resources used by the logger.

Closes any resources used by the logger.

For SQLite logging, this method ensures the database connection is properly terminated.

log(level, message)

Logs a message with a specified severity level.

Logs a message with a specified severity level.

Parameters:
NameTypeDescription
levelstring

The severity level (e.g., 'info', 'warn', 'error', 'debug').

messagestring

The log message to be recorded.

log(level, message)

Logs a message with a specified severity level.

Logs a message with a specified severity level.

Parameters:
NameTypeDescription
levelstring

The severity level (e.g., 'info', 'warn', 'error', 'debug').

messagestring

The log message to be recorded.