0.4.10 • Published 5 years ago

@ciklum/logan v0.4.10

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
5 years ago

LOGAN - extended logger service for you javascript app, or super nice guy.

Table of contents

  1. Installation and usage
  2. Log levels
  3. Usage and API
  4. Working with local copy of module
  5. Publish a package

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 applications

  • window.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 LoggerServices in the application):

LoggerService.setGlobalTitle('delivery-flow-app')

To set a title for LoggerService (for LoggerServices 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
0.4.10

5 years ago

0.4.0

5 years ago

0.4.9

5 years ago

0.4.8

6 years ago