npm.io
3.4.0 • Published 2 years ago

improved-logging

Licence
MIT
Version
3.4.0
Deps
0
Size
23 kB
Vulns
0
Weekly
0

Node.js module for logging into console, file and browser (see below for more info)

Installation

Node package manager

npm i improved-logging

YARN

yarn add improved-logging

Usage:

import logging from 'improved-logging'

logging.info('This is logging example')

Log types

import logging from 'improved-logging'

logging.info('Some information')
logging.important('Some important information')
logging.success('Something is done')
logging.warn('Warning')
logging.error('Something went wrong')
logging.fatal('Critical error')

Enable logging into the files

import logging from 'improved-logging'

logging.setLogfileName(path.join(__dirname, '../', 'logs', 'main.log'))

logging.info('Now will log all to file')

logging.setSeparateLogsByDate(true)

logging.info('This log will be located in MONTH_YYYY/DD.log')

How to turn different logs on/off

import logging from 'improved-logging'

logging.verbose('You will see this in console')

logging.setLogLevel('info')

logging.verbose('This one is hidden')


logging.setLogLevel('important')

logging.important('Now info, success and verbose logs are hidden')
logging.info('You will not see this in console/log file/browser')

Keywords