@lemoncloud/lemon-logger-lib
v1.0.0
Published
lemon logger library
Downloads
4
Readme
lemon-logger-lib
TypeScript console logger for LemonCloud
Install
$ npm install lemon-logger-lib
Usage
default
import { Logger } from 'lemon-logger-lib';
const logger = new Logger('LEMON');
const logger2 = new Logger('LEMON2', { showTimestamp: false, showLogType: false });
logger.log('this is log', 'extra params: ', { type: 'debug'});
logger.debug('this is debug', 'extra params: ', { type: 'debug'});
logger2.info('this is info', 'extra params: ', { type: 'info'});
logger2.warn('this is warn', 'extra params: ', { type: 'warn'});
logger2.error('this is error', 'extra params: ', { type: 'error'}, 'test');
http
const logger = new Logger('LEMON', {
shouldSend: true,
httpHost: 'http://localhost:8333',
httpMethod: 'POST',
httpPath: '/mock/log',
});
socket
const logger = new Logger('LEMON', {
useSocket: true,
socketHost: 'http://localhost:5555',
socketEvent: 'LOG',
});
Options
Logger([namespace], [options])
showTimestamp
Type: boolean
Default: true
showLogType
Type: boolean
Default: true
shouldSend
Type: boolean
Default: false
httpHost
Type: string
Default: ''
httpMethod
Type: string
Default: ''
httpPath
Type: string
Default: ''
useSocket
Type: boolean
Default: false
socketHost
Type: string
Default: ''
socketEvent
Type: string
Default: ''
Methods
logger.log('test message')
logger.debug('test message')
logger.info('test message')
logger.warn('test message')
logger.error('test message')
logger.setOptions({ shouldSend: false })
logger.closeSocket()
Sample
A quick sample is provided as example.js