0.1.1 • Published 5 years ago

@amjs/logger v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@amjs/logger 0.1.0

Statements Branches Functions Lines

Handles log/trace/debug information

Installation

$ npm i @amjs/logger

Usage

Default use

const AmjsLogger = require('@amjs/logger');
const logger = new AmjsLogger();
logger.log('My log message is {{info}}', { info : 'logged!' }); //*

*: Available methods are: 'log', 'error', 'debug', 'warn' and 'info'

Stacked messages:

In this way of behaviour, messages can be stacked into a pile and through method dump will be written into log file.

const AmjsLogger = require('@amjs/logger');
const logger = new AmjsLogger({ stack : true });
logger.log('My log message');
logger.error('My error message');
logger.debug('My debug message');
logger.warn('My warning message');
logger.info('My info message');
logger.dump();

Configuration

@amjs/logger accepts following configuration options:

OptionDescriptionTypeDefault
dateLog traces fixed dateStringInstance creation date, as ISO string
destFolderDestination folder to write logFileString".tmp"
logFileFile to writeString".tmp/{date}.log"
nameApp that is running the loggerString"@amjs/logger"
templateLog record templateString"{{date}} {{name}} {{level}} {{message}}"
traceWhether to log messages into console or notBooleanfalse
stackWhether to stack messages or notBooleanfalse

By default, all paths are relative to @amsj/logger installation path.

date configuration property is ony used for creating log file, records will have their own timestamp.