1.0.23082703 • Published 9 months ago

@spacepumpkin/log v1.0.23082703

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

Log

This is a simple logging module for Node.js that provides a way to log messages with different levels of severity. Optionally provides an in-memory record for debugging purposes

Installation

To install the module, run the following command:

npm install @spacepumpkin/log

Usage

The module provides two ways of usage, a static log that can be used in place of console.log and makeLogger which returns a callable where all log messages are tied the alias supplifed

log

log(level: LEVEL, alias: string, str: string, persist = true)

  • level: The severity level of the message (one of LEVEL.INFO, LEVEL.DEBUG, LEVEL.WARN, or LEVEL.ERROR)

  • alias: Arbitrary name associated with the log message

  • message: The actual contents of the log

makeLogger

makeLogger(alias: string): Logger

Returns a logger function that logs messages with the specified alias.

  • alias: Arbitrary name associated with the log message

Configuration

The module provides some configuration via environment variables.

  • LOG_IN_MEMORY: Will disable the in-memory log when set to "false"
  • LOG_IN_MEMORY_CLEANUP_INTERVAL: Time (in ms) to run a cleanup on in memory logs (defaults to 1 day)
  • LOG_RETENTION_DEBUG: Time (in ms) to persist debug log messages in memory (defaults to 1 day)
  • LOG_RETENTION_INFO: Time (in ms) to persist debug log messages in memory (defaults to 3 days)
  • LOG_RETENTION_WARN: Time (in ms) to persist debug log messages in memory (defaults to 7 days)
  • LOG_RETENTION_ERROR: Time (in ms) to persist debug log messages in memory (defaults to 14 days)
1.0.23082703

9 months ago

1.0.23082702

9 months ago

1.0.0

9 months ago