@bloom42/astro

0.8.2 • Public • Published

Astro-JS

Make logging great again

NPM Package NPM Release

NPM

  1. Quickstart
  2. Configuration
  3. Log usage
  4. Examples

Quickstart

$ npm i @bloom42/astro
const { log } = require('@bloom42/astro');

const log2 = log.with({ num: 2 });

log.info('hello world');
log2.info('hello world');
log.with({ lol: 42 }).error('fatal knock out');
log2.with({ num: 3, pi: 3.14 }).info('hello world');
log2.info('hello world');
log2.track({ description: 'event without message nor level' });

Configuration

// default configuration
const options = {
  level: Level.DEBUG,
  fields: {},
  writer: isBrowser ? console : stdout,
  insert_timestamp: true,
  timestamp_field_name: 'timestamp',
  message_field_name: 'message',
  level_field_name: 'level',
  hooks: [],
};

log.config(options);

Log usage

log.config(options: any)
log.with(fields: any): Logger
log.debug(message: string)
log.info(message: string)
log.warn(message: string)
log.error(message: string)
log.fatal(message: string) // log with the "fatal" level then exit(1)
log.track(fields: any) // log an event without level nor message

Examples

See the examples folder

Readme

Keywords

Package Sidebar

Install

npm i @bloom42/astro

Weekly Downloads

1

Version

0.8.2

License

Apache-2.0

Unpacked Size

34.4 kB

Total Files

26

Last publish

Collaborators

  • z0mbie42