This is a simple Logger class for both NodeJS and Browser use.
It uses colours to easily distinguish message logging levels.
It is a work in progress.
npm i ask-logger
const logger = Logger.getLogger('Main program')
logger.set_level(LogLevel.DEBUG)
logger.debug('This is an example', 123, {
name: 'Joe',
age: 25
})
const logger = Logger.getLogger('Main program')
logger.set_level(LogLevel.DEBUG)
logger.info('This is an example', 123, {
name: 'Joe',
age: 25
})
const logger = Logger.getLogger('Main program')
logger.set_level(LogLevel.DEBUG)
logger.warn('This is an example', 123, {
name: 'Joe',
age: 25
})
const logger = Logger.getLogger('Main program')
logger.set_level(LogLevel.DEBUG)
logger.error('This is an example', 123, {
name: 'Joe',
age: 25
})
To prevent all output, simply set the logging level to LogLevel.NONE
const logger = Logger.getLogger('Main program')
logger.set_level(LogLevel.NONE)
logger.error('This is an example', 123, {
name: 'Joe',
age: 25
})