1.0.3 • Published 3 months ago

brook-logger v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
3 months ago

brook-logger

A simple logger based on filesystem module.

Version npm npm Downloads

NPM

Motivation

brook-logger is just a simple logging library with fs (filesystem) nodejs module. For example, using fs one may want output and error logs to be stored in a persistent local file.

brook-logger aims to follow the development path to make each log a single message unit.

Usage

The recommended way to use brook-logger is to create an Instance of the Logger Class; i.e using brook-logger.Logger Class.

const brook = require('brook-logger');

const logger = new brook.Logger();

Table of contents

Logging

A logger accepts the following parameters:

NameDefaultDescription
preserveLogsfalseTo save logs in created Log Files
pathlogs/Log Files path
errorPathlogs/Error Log Files path
rotationbrook-logger.Rotation.DAILYWhen to rotate Log Files
logFileExtensionfalseExtensions for generated Log Files
initLogfalseLog when Logger is initialised
const { Rotation, Level } = require('brook-logger');

Logging Levels

Currently the following Logging levels are present in brook-logger.

{
  ERROR = 'ERROR',
  WARN = 'WARN',
  INFO = 'INFO',
  VERBOSE = 'VERBOSE',
  DEBUG = 'DEBUG',
}

Using Logging Levels

To log at a specific level, just call the same method from the logger instance.

//
// Any logger instance
//
logger.log("this is a simple log text.");
logger.warn("this is a simple log text.");
logger.error("this is a simple log text.");

brook-logger will support customizable logging levels in future versions.

Installation

npm install brook-logger

Run Tests

All of the tests are written with jest. They can be run with npm.

npm test

Author: Jkan1

Contributors: -