0.1.1 • Published 5 years ago
@amjs/logger v0.1.1
@amjs/logger 0.1.0
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:
Option | Description | Type | Default |
---|---|---|---|
date | Log traces fixed date | String | Instance creation date, as ISO string |
destFolder | Destination folder to write logFile | String | ".tmp" |
logFile | File to write | String | ".tmp/{date}.log" |
name | App that is running the logger | String | "@amjs/logger" |
template | Log record template | String | "{{date}} {{name}} {{level}} {{message}}" |
trace | Whether to log messages into console or not | Boolean | false |
stack | Whether to stack messages or not | Boolean | false |
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.