0.8.2 • Published 5 years ago
@bloom42/astro v0.8.2
Astro-JS
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