1.0.4 • Published 5 years ago

lalalogs v1.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

lalalogs

This project is created in order to standardize the logs format across all node-js projects used in lalamove

Install

npm install --save lalalogs

Features

Log format

The output of the log will be printed out to the standard output in the format below:

{
    "message": "", // string describing what happened
    "src_file": "", // file path
    "src_line": "", // line number
    "context": {}, // custom field here
    "level": "", // debug/info/warning/error/fatal
    "time": "", // ISO8601.nanoseconds+TZ (in node only support precision up to milliseconds)
    "backtrace": "" // err stack
}

Usage

'use strict'
const log = require('lalalogs')()

// info log
log.info(
    'info', // string message
    { data } // custom fields
)

// debug log
log.debug(
    'debug', // string message
    { data }, // custom fields
)

// warning log
log.warning(
    'warning', // string message
    { data }, // custom fields
)

// error log
log.error(
    'error', // string message
    { data }, // custom fields
    err.stack // error stack trace object
)

// fatal log
log.fatal(
    'fatal', // string message
    { data }, // custom fields
    err.stack // error stack trace object
)

Licensing

The code in this project is licensed under MIT license.

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago