@altipla/logging
TypeScript icon, indicating that this package has built-in type declarations

0.1.8 • Public • Published

logging

JSON logger with an opinionated default configuration.

Install

npm install @altipla/logging

Usage

import { logger } from '@altipla/logging'

logger.info('Log this')
logger.error('Log an error')
logger.info({
  msg: 'foo',
  field1: 'bar',
  field2: 3,
})

Log common fields

Create a custom logger to group fields common to all log messages. It can be useful for example to add the current user inside all messages.

import { logger } from '@altipla/logging'

let userLogger = logger.child({ user: 'user' })

userLogger.info('my message')
userLogger.error('other message')

Change log level

By default log level is set to debug. It can be changed creating a new child logger with a level field configured:

import { logger } from '@altipla/logging'

let traceLogger = logger.child({ level: 'trace' })
traceLogger.trace('trace message')

Readme

Keywords

none

Package Sidebar

Install

npm i @altipla/logging

Weekly Downloads

50

Version

0.1.8

License

MIT

Unpacked Size

4.62 kB

Total Files

9

Last publish

Collaborators

  • ernestoalejo