1.1.0 • Published 10 months ago

node-chroma-logger v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

node-chroma-logger

colors

Table of Contents

Presentation

A zero-dependency minimalist asynchronous Node.js chromatic logger. When you want colors, don't want to use mainly synchronous logging methods of Console and get rid of a complex logger.

Installation

npm install --save node-chroma-logger

Technical information

Stack

  • Language: JavaScript ES6/ES7
  • Node.js >= Dubnium (10.22.1)

Code quality

Code style follows Airbnb JavaScript Best Practices using ESLint.

Tests

Mocha and Chai for unit testing.

Security

  • Code security and most precisely module dependencies can be audited running npm audit.

Requirements

Usage

Environment variables

namedescriptionrequireddefault
NODE_CHROMA_LOGGER_DISABLE_COLORWether to disable setting color (escape sequences). It is especially needed if the terminal does not have the feature to display colors at all or you just don't want any color. It is always set to false so that terminals that are not detected as able to display colors like for Gitlab CI pipelines for an example can always have colors displayed. Accepted values: true or 1.false
NODE_CHROMA_LOGGER_DISABLE_DATE_FORMATWether to disable showing date in the log format. Accepted values: true or 1.false
NODE_CHROMA_LOGGER_DISABLE_SEVERITY_FORMATWether to disable showing severity in the log format. Accepted values: true or 1.false
NODE_CHROMA_LOGGER_SEVERITYLogger severity selected. See logger severities. Higher severities, if any, are activated.trace

Severities

Sorted by highest to lowest severity.

severitydescriptioncolordata stream
fatalThe service/app is going to stop or become unusable now. An operator should definitely look into this soon.background light redstderr
errorFatal for a particular request, but the service/app continues servicing other requests. An operator should look at this soon(ish).redstderr
warnA note on something that should probably be looked at by an operator eventually.yellowstderr
infoDetail on regular operation.cyanstdout
logDetail on regular operation. Same severity rank as info.defaultstdout
successDetail on a successful operation. Same severity rank as info.greenstdout
debugAnything else, i.e. too verbose to be included in info severity.light magentastdout
traceLogging from external libraries used by the app or very detailed application logging.dark graystdout
disableLogging is disabled.nonenone

Import

const logger = require('node-chroma-logger');

Lib

  • logger <Object> with the following properties.

fatal

  • fatal(args) <Function>
    • args <Any>

Example:

logger.fatal('this was fatal, this has to stop!');

error

  • error(args) <Function>
    • args <Any>

Example:

logger.error('this was an error!', new Error('bad stuff'));

warn

  • warn(args) <Function>
    • args <Any>

Example:

logger.warn('ooooooops, be careful');

info

  • info(args) <Function>
    • args <Any>

Example:

logger.info('this is so helpful thanks');

log

  • log(args) <Function>
    • args <Any>

Example:

logger.log('log is at same level as info but without any specific color');

success

  • success(args) <Function>
    • args <Any>

Example:

logger.success('same as above, let\'s go!!');

debug

  • debug(args) <Function>
    • args <Any>

Example:

logger.debug({ hello: 'world' }, 'hi', 'this is just to have this info with some more details');

trace

  • trace(args) <Function>
    • args <Any>

Example:

logger.trace('this is a very detailed log', { details: 100 }, ['details', 'details']);

Errors

None.

Development

Linting

npm run lint

Unit test

npm test

Known issues

/

Code of Conduct

This project has a Code of Conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

Contributing

Please take a moment to read our Contributing Guidelines if you haven't done so yet.

Support

Please see our Support page if you have any questions or for any help needed.

Security

For any security concerns or issues, please visit our Security Policy page.

License

MIT.

1.1.0

10 months ago

1.0.1

11 months ago

1.0.0

11 months ago