@8select/strulo 中文文档教程

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

strulo

CircleCI

样式更漂亮模块格式:cjs, esm

以结构化格式记录消息

Install

使用 NPM

npm install --save @8select/strulo

How to use it

const logger = require('@8select/strulo')
logger.debug('hello')
logger.info('hello from strulo')
logger.error('some error')

DEBUG 环境变量是用于基于空格或逗号分隔的名称启用这些。 以下是一些示例:

export DEBUG=DEBUG,ERROR,ALERT

仅显示具有日志级别调试、错误和警报的日志消息

DEBUG {"message":"hello","level":"100","level_name":"DEBUG","time":1506502514498} +0ms

ERROR {"message":"some error","level":"400","level_name":"ERROR","time":1506502554430} +40s

directory structure

+-- lib - "contains the lib files (ES5) + flow definitions"
|   +-- index.js - "which is compiled with Babel and stripped of types"
|   +-- index.js.flow - "which is the original file, with types left in it"
|   +-- info.js
|   +-- info.js.flow
|   +-- ...
+-- src - "contains the source files (ES.next)"
|   +-- index.js
|   +-- info.js
|   +-- ...
+-- test - "contains unit tests to related src structure

strulo

CircleCI

styled with prettiermodule formats: cjs, esm

Log messages in a structured format

Install

using NPM

npm install --save @8select/strulo

How to use it

const logger = require('@8select/strulo')
logger.debug('hello')
logger.info('hello from strulo')
logger.error('some error')

The DEBUG environment variable is used to enable these based on space or comma-delimited names. Here are some examples:

export DEBUG=DEBUG,ERROR,ALERT

displays only log messages with log level debug, error and alert

DEBUG {"message":"hello","level":"100","level_name":"DEBUG","time":1506502514498} +0ms

ERROR {"message":"some error","level":"400","level_name":"ERROR","time":1506502554430} +40s

directory structure

+-- lib - "contains the lib files (ES5) + flow definitions"
|   +-- index.js - "which is compiled with Babel and stripped of types"
|   +-- index.js.flow - "which is the original file, with types left in it"
|   +-- info.js
|   +-- info.js.flow
|   +-- ...
+-- src - "contains the source files (ES.next)"
|   +-- index.js
|   +-- info.js
|   +-- ...
+-- test - "contains unit tests to related src structure
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文