Simple configurable logging module.
This package is part of quark
framework but it can be used independently.
Features
- Levels : Defaults (
log
,info
,warn
,error
) and custom - Plugins : Defaults and custom
- Styling : Per level/plugin
- More : Timer, group, reset...
Installation
npm install quark-log --save
Usage
Basic
const logger = loggerloggerlogger
Enable/disable logging
const logger = loggerloggerlogger
Grouping
const logger = loggerloggerlogger
Timer
const logger = logger// ...logger
Handler
const logger = logger logger
Reset
Reset levels and plugins.
const logger = logger logger // [15:00:00] Testloggerlogger // Test
Line break
const logger = logger
Levels
Defaults levels
const logger = loggerloggerloggerlogger
Add a custom level
const logger = logger logger
Configure level options
const logger = logger logger // Will be logged in blue
Plugins
Defaults plugins list
- time : Append current time before user message
- namespace : Append a custom namespace before user message
Use a default plugin
const logger = logger logger // [15:00:00] Test
Configure plugin options
const logger = loggerlogger // [test] Test loggerlogger // Test
Create a custom plugin
/** * Plugin callback signature * * @param * @param * @param * @param * @param */const myPlugin = { return before: `:` msgs after: '' styles: {} } const logger = logger // This plugin append a custom string before each message logger // My plugin: Test
API
See https://fm-ph.github.io/quark-log/
Build
To build the sources with babel
in ./lib
directory :
npm run build
Documentation
To generate the JSDoc
:
npm run docs
To generate the documentation and deploy on gh-pages
branch :
npm run docs:deploy
To serve the JSDoc
:
npm run docs:serve
Testing
To run the tests, first clone the repository and install its dependencies :
git clone https://github.com/fm_ph/quark-log.gitcd quark-lognpm install
Then, run the tests :
npm test
To watch (test-driven development) :
npm run test:watch
For coverage :
npm run test:coverage
License
MIT License © Patrick Heng Fabien Motte