@abtnode/logger 中文文档教程

发布于 3年前 浏览 26 项目主页 更新于 3年前

logger

这是 ABT 节点的日志库。

Enable logging first

设置环境:process.env.ABT_NODE_LOG_DIR = {logging directory}

Write to files

设置环境:process.env.NODE_ENV = 'production'

Writing to console

DEBUG=@abtnode/* npm run xxx

或者,日志将写入标准输出。

Rotate log files

每天轮换日志文件,日志文件名格式为 {label}-YYYY-MM-DD.log

[!Important] Default retained log files

因为它供内部使用,所以默认日志会保留 60 天

Usage

const logger = require('@abtnode/logger')('@abtnode/cli');

// log info
logger.info('detail blocklet', { did: 'z8iZpWP3gto8RWk9UHfvAaYtqX5wZ3Mz9BrHA' });
// [2020-08-12 17:26:28] [info]  "detail blocklet" {"did":"z8iZpWP3gto8RWk9UHfvAaYtqX5wZ3Mz9BrHA"}

// log error: must pass an object
logger.info('this is an error', { error: new Error('test') });

logger

This is a log library for ABT Node.

Enable logging first

Set the environments: process.env.ABT_NODE_LOG_DIR = {logging directory}.

Write to files

Set the environments: process.env.NODE_ENV = 'production'.

Writing to console

DEBUG=@abtnode/* npm run xxx.

Or, the logs will be write to stdout.

Rotate log files

Rotate log files every day, log filename formate {label}-YYYY-MM-DD.log.

[!Important] Default retained log files

Because it is for internal use, the default log is kept for 60 days.

Usage

const logger = require('@abtnode/logger')('@abtnode/cli');

// log info
logger.info('detail blocklet', { did: 'z8iZpWP3gto8RWk9UHfvAaYtqX5wZ3Mz9BrHA' });
// [2020-08-12 17:26:28] [info]  "detail blocklet" {"did":"z8iZpWP3gto8RWk9UHfvAaYtqX5wZ3Mz9BrHA"}

// log error: must pass an object
logger.info('this is an error', { error: new Error('test') });
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文