0.0.5 • Published 2 years ago

@mateoox600/m-logger v0.0.5

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

MLogger

Npm package for logging, works in pair with m-color.


Features

  • Logging work in pair with m-color
  • Event emitter for logs levels
  • Prefix and suffix for log levels

Installation

npm install @mateoox600/m-logger
  • Typescript is supported and types comes with the installation

Usage

const { HtmlColors } = require('@mateoox600/m-color');
const { Logger } = require('@mateoox600/m-logger');

const logger = new Logger({
    info: { },
    warn: { colors: HtmlColors.Yellow.asFore(), prefix: '[WARN] ' },
    error: { colors: HtmlColors.Red.asBack(), prefix: '[ERROR] ', suffix: ' !!!' }
}, 'info');

logger.on('warn', (str) => {
    console.log(`This logs before warns and the warn is: '${str}'`);
});

logger.log('This is an info with 0 coloring');
logger.log('This is a yellow warn', 'warn');
logger.log('This failed', 'error');

Docs

Logger

  • Takes as arguments an object describing all the log levels, and an optional string for the default log level
  • on(logLevel, listener) : The listener takes a string and is called when something of that log level is logged
  • log(string, logLevel) : Logs the string at the given log level or the default log level if none of the two exist it throw a "Parameter missing"
0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago