0.0.9 • Published 11 months ago

@chatally/logger v0.0.9

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

@chatally/logger

ChatAlly Logger Facade that can be used in libraries to use any logging framework without introducing any dependencies.

The facade can be easily implemented with popular frameworks like Pino, Winston or log4js.

The main interface of the facade is Logger, it supports typical log methods (trace, debug, info, warn, error), logging of messages, format strings and data objects including errors, and creating named child loggers.

The package contains two default implementations: BaseLogger and NoLogger.

This package is meant to be used within a ChatAlly chatbot application, but could be used anywhere.

Usage

Install the package

npm install @chatally/logger

Use the logger

// index.js
import { BaseLogger } from '@chatally/logger'

class MyClass {
  /** @param {import('@chatally/logger').Logger} log */
  constructor(log) {
    this.log = log
  }

  doSomething() {
    this.log.debug('I am about to do something')
    // do something
    this.log.info('Just did something.')
  }
}

const log = new BaseLogger({ name: 'foo' })
const foo = new MyClass(log)
// with the default settings from BaseLogger, it logs
// [<timestamp>] INFO (foo): Just did something.
foo.doSomething()

Documentation

Find the full documentation at https://chatally.org/reference/core/logger/.

0.0.9

11 months ago

0.0.8

12 months ago

0.0.5

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago