@ciklum/logan
v0.4.10
Published
Logging library
Downloads
12
Readme
LOGAN - extended logger service for you javascript app, or super nice guy.
Table of contents
Installation and usage
Set private registry by adding registry=http://npm.pp.ciklum.com/
to your .npmrc
file
Install LOGAN library by running
npm i @ciklum/logan
Now you can use LoggerService
class provided by RAAX:
import { LoggerService } from '@ciklum/logan'
Log levels
LoggerService supports next types of log levels:
- log
- debug
- info
- warn
- error
Current log level is provided by:
LOG_LEVEL
environment variable for Node.js applicationswindow.config.logLevel
for browser applications
Current log level determines what messages should be displayed. For example, if current log level
is set to 'info'
(window.config.logLevel = 'info'
) only info
, warn
and error
messages
will be displayed. log
and debug
messages will be ignored.
Usage and API
To start using LoggerService
:
import { LoggerService } from '@ciklum/logger'
const logger = new LoggerService()
To set global title for LogerService
(for all LoggerService
s in the application):
LoggerService.setGlobalTitle('delivery-flow-app')
To set a title for LoggerService
(for LoggerService
s instance):
logger.setTitle('@ciklum/xmess')
// Log output if global and instance titles are set:
// [delivery-flow-app::@ciklum/xmess]
There are five methods to output logs:
logger.log
logger.debug
logger.info
logger.warn
logger.error
Note: Starting with Chromium 58 loger.debug
method only appears in Chromium browser
consoles when level "Verbose" is selected (not set by default).
Message string and optional argument(s) of any type should be passed to these methods:
logger.info('Publish', { channelHeader, listeners: cbs.length, msg })
// Log output
// [delivery-flow-app::@ciklum/xmess] Publish > {channelHeader: "@ciklum-sol-js/xmess:todos/items/all-get:success", listeners: 0, msg: Array(10)}
Working with local copy of module
When you want to develop new features for module, this section will be helpful for you. Package linking is a two-step process which solves this need. You need npm link for this.
Steps:
Create global link. It will be available in folder were your npm modules are.
npm link
Links to the global installation target from your front end app.
npm link @ciklum/logan
Publish a package
Publish a package to the registry by running
npm run build
npm publish