1.0.0 • Published 6 years ago

clear-logs v1.0.0

Weekly downloads
50
License
-
Repository
github
Last release
6 years ago

Clear logs

alt text

A lib to provide more context around logs, making them clear and easy to display.

1. Install & import

npm install clear-logs

const logger = require('clear-logs');

2. Just use it

logger.log( 'Something', 'something 2', 'something 3');

Where the methods are the same as the ol' good console:

  • log
  • error
  • info
  • warn
  • debug

3. Done!


Advanced config (Hey, maybe you need something else)

You can setup some aditional configurations to shape the logger for your needs. Just set using the config method:

logger.config( { /* opts */ } );

Where your options are:

propdefaultdescr
consoleconsoleThis is the node console, used to stdout the stuff. You can pass your own console here, if you need. Just dont forget to have the same methods as the normal console (log info, warn, error, debug)
appendixnullInfo to prepend to all your logs
stackUp4How much going thru the Error.stack to get the line, file and fn name for logging. Don't mess with this unless you really need too.
envs.production 'error', 'log', 'warn' What methods will actually output when NODE_ENV === 'production'
envs.staging 'error', 'log', 'warn' What methods will actually output in when NODE_ENV === 'staging'
envs.test 'error' What methods will actually output when NODE_ENV === 'test'
envs.development 'error', 'log', 'warn', 'debug', 'info' What methods will actually output when NODE_ENV === 'development'

So, lets say you dont want to polute your tests with logs, but want those in the production version of your app, you can config as following:

logger.config( { 
  envs: {
    test: [] 
  } 
});

So now, no stdout will be made in this environment.

Enjoy!

1.0.0

6 years ago

0.1.0

6 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago