Fast, elegant, structured, pluggable and isomorphic logging for Javascript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
examples
lib
src
.babelrc
.esdoc.json
.eslintrc.js
.gitignore
.npmignore
LICENSE
Makefile
README.md
package-lock.json
package.json

README.md

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