@spacepumpkin/log
v1.0.23082703
Published
Provides a quick way to log messages and view them over http
Downloads
7
Readme
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 ofLEVEL.INFO
,LEVEL.DEBUG
,LEVEL.WARN
, orLEVEL.ERROR
)alias
: Arbitrary name associated with the log messagemessage
: 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)