1.0.7 • Published 1 year ago

node-logger-npm v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Node-Logger-Npm

A simple logger class for writing log messages to a file in Node.js.

Installation

You can install the package using npm:

npm install node-logger-npm

Usage

To use the logger, you first need to import it:

import { Loggers, LogLevel } from 'loggers'; 

Next, create a new instance of the Logger class:

const logger = new Loggers('./logs',{
    filename: 'test',
    level: 'INFO',
    newLogDaily: true,
    maxLogSize: 1000000, // 1MB
});

The first parameter is the path to the directory where the log files will be saved. The second parameter is an optional options object that can contain a log level (default is DEBUG) and a filename. The third parameter is an optional boolean that indicates whether a new log file should be created every day (default is false). The Fourth parameter is an optional number that indicates the maximum size of the log file in bytes (default is 1000000).

To write a log message, simply call the appropriate log-level method:

logger.debug('Debug message');
logger.info('Info message');
logger.warning('Warning message');
logger.error('Error message');
logger.critical('Critical message');

The log message will be written to a file in the specified directory with a filename based on the current date.

LogLevel

An enum is representing the log levels. The possible values are:

DEBUG
INFO
WARNING
ERROR
CRITICAL

LoggerOptions

An interface representing the logger options. It can contain:

level - The log level to use. filename - The filename to use for the log file.

License

This package is licensed under the MIT License.

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago