Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

egg-logger

Package Overview
Dependencies
Maintainers
5
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-logger - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

7

History.md
2.0.1 / 2018-10-09
==================
**others**
* [[`7a33960`](http://github.com/eggjs/egg-logger/commit/7a33960e9a87de5d693d4628f2f3a7a8de649a33)] - chore: change commemts in english (dead-horse <<dead_horse@qq.com>>)
* [[`44bd5fa`](http://github.com/eggjs/egg-logger/commit/44bd5fa72fb482dc57f57e2d46150bfa3d72c3cb)] - chore(typings): add LoggerOptions['allowDebugAtProd']: boolean (#28) (waiting <<waiting@xiaozhong.biz>>)
2.0.0 / 2018-10-08

@@ -3,0 +10,0 @@ ==================

1

index.d.ts

@@ -17,2 +17,3 @@ interface ILoggerLevel {

consoleLevel?: LoggerLevel;
allowDebugAtProd?: boolean;
}

@@ -19,0 +20,0 @@

17

lib/transports/console.js

@@ -9,4 +9,4 @@ 'use strict';

/**
* 将日志输出到终端的 {@link Transport}。
* 如果指定 EGG_LOG 则是优先级最高的 level。
* output log to console {@link Transport}。
* specifical level by EGG_LOG has the highest priority
*/

@@ -18,3 +18,3 @@ class ConsoleTransport extends Transport {

* @param {Object} options
* - {Array} [stderrLevel = ERROR] - 输出到 stderr 的打印级别,必须高于 level
* - {Array} [stderrLevel = ERROR] - output to stderr level, must higher than options.level
*/

@@ -24,3 +24,3 @@ constructor(options) {

this.options.stderrLevel = utils.normalizeLevel(this.options.stderrLevel);
// EGG_LOG 优先级最高
// EGG_LOG has the highest priority
if (process.env.EGG_LOG) {

@@ -38,6 +38,7 @@ this.options.level = utils.normalizeLevel(process.env.EGG_LOG);

/**
* 输出日志,见 {@link Transport#log},如果指定了 stderrLevel 会将日志转到 stderr
* @param {String} level - 日志级别,必须大写
* @param {Array} args - 所有的参数
* @param {Object} meta - 元信息
* output log, see {@link Transport#log}
* if stderrLevel presents, will output log to stderr
* @param {String} level - log level, in upper case
* @param {Array} args - all arguments
* @param {Object} meta - meta infomations
*/

@@ -44,0 +45,0 @@ log(level, args, meta) {

@@ -8,3 +8,4 @@ 'use strict';

/**
* 继承自 {@link FileTransport},将日志写入内存中,一定时间内统一写入文件来提高性能
* extends from {@link FileTransport}
* save log in memory and flush to log file at intervals
*/

@@ -16,6 +17,6 @@ class FileBufferTransport extends FileTransport {

* @param {Object} options
* - {String} file - 日志的文件路径
* - {Number} [flushInterval = 1000] - 日志写入频率,一定时间后写入文件
* - {Number} [maxBufferLength = 1000] - 日志写入缓存队列最大长度
* - {String} [level = INFO] - 日志级别
* - {String} file - log file path
* - {Number} [flushInterval = 1000] - interval for flush to file
* - {Number} [maxBufferLength = 1000] - max buffer queue length
* - {String} [level = INFO] - log level
*/

@@ -38,3 +39,3 @@ constructor(options) {

/**
* 关闭 stream 和定时器
* close stream and interval
*/

@@ -55,3 +56,3 @@ close() {

/**
* 将内存中的字符写入文件中
* flush log into file
*/

@@ -71,3 +72,3 @@ flush() {

/**
* 覆盖父类,在关闭 stream 之前先 flush 下
* override, flush before close stream
* @private

@@ -84,4 +85,4 @@ */

/**
* 覆盖父类,写入内存
* @param {Buffer} buf - 日志内容
* override, save in memory temporary
* @param {Buffer} buf - log buffer
* @private

@@ -98,3 +99,3 @@ */

/**
* 创建定时器,一定时间内写入文件
* create interval to flush log into file
* @return {Interval} 定时器

@@ -108,3 +109,3 @@ * @private

/**
* 关闭定时器
* close interval
* @private

@@ -111,0 +112,0 @@ */

@@ -14,3 +14,3 @@ 'use strict';

/**
* 将日志输出到文件的 {@link Transport}。
* ouput log into file {@link Transport}。
*/

@@ -22,4 +22,4 @@ class FileTransport extends Transport {

* @param {Object} options
* - {String} file - 日志的文件路径
* - {String} [level = INFO] - 日志级别
* - {String} file - file path
* - {String} [level = INFO] - log level
*/

@@ -42,8 +42,6 @@ constructor(options) {

/**
* 重新载入日志文件
* reload file stream
*/
reload() {
// 关闭原来的 stream
this._closeStream();
// 新创建一个 stream
this._stream = this._createStream();

@@ -53,6 +51,6 @@ }

/**
* 输出日志,见 {@link Transport#log}
* @param {String} level - 日志级别
* @param {Array} args - 所有的参数
* @param {Object} meta - 元信息
* output log, see {@link Transport#log}
* @param {String} level - log level
* @param {Array} args - all arguments
* @param {Object} meta - meta infomations
*/

@@ -72,3 +70,3 @@ log(level, args, meta) {

/**
* 关闭 stream
* close stream
*/

@@ -88,4 +86,4 @@ close() {

/**
* 直接写入 stream
* @param {Buffer|String} buf - 日志内容
* write stream directly
* @param {Buffer|String} buf - log content
* @private

@@ -106,4 +104,4 @@ */

/**
* 创建一个 stream
* @return {Stream} 返回一个 writeStream
* create stream
* @return {Stream} return writeStream
* @private

@@ -128,3 +126,3 @@ */

/**
* 关闭 stream
* close stream
* @private

@@ -131,0 +129,0 @@ */

@@ -10,4 +10,5 @@ 'use strict';

/**
* Transport 是日志的一种输出通道,可以输出到文件,终端或服务等。
* 一个 {@link Logger} 可以配置多个 Transport 来满足各种复杂的需求
* Transport is an output channel of the log that can be output to a file, console or service.
* A {@link Logger} can configure multiple Transports to meet a variety of complex needs
*/

@@ -19,7 +20,7 @@ class Transport {

* @param {Object} options
* - {String} [level = NONE] - 日志打印级别,打印的方法必须高于此配置方法。如配置了 info,debug 不会打印。
* - {Function} formatter - 格式化函数
* - {Boolean} [json = false] - 日志内容是否为 json 格式
* - {String} [encoding = utf8] - 文件编码,可选编码 {@link https://github.com/ashtuchkin/iconv-lite#supported-encodings}
* - {String} [eol = os.EOL] - 换行符
* - {String} [level = NONE] - log level. ouput method must higher than this option. if level is `info`, `debug` will disabled
* - {Function} formatter - format function
* - {Boolean} [json = false] - log format is json or not
* - {String} [encoding = utf8] - log encodeing, see {@link https://github.com/ashtuchkin/iconv-lite#supported-encodings}
* - {String} [eol = os.EOL] - end of line
*/

@@ -46,3 +47,3 @@ constructor(options) {

/**
* 是否开启,如果关闭则不会输出日志
* enable or not
* @return {[type]} [description]

@@ -55,3 +56,3 @@ */

/**
* 开启 transport
* enable transport
*/

@@ -63,3 +64,3 @@ enable() {

/**
* 关闭 transport,关闭后不会写入日志
* disable transport
*/

@@ -79,5 +80,5 @@ disable() {

/**
* 是否应该打印日志
* @param {String} level 日志级别,必须大写
* @return {Boolean} 返回打印状态
* should output log or not
* @param {String} level log level, must in upper case
* @return {Boolean} should or not
*/

@@ -89,3 +90,2 @@ shouldLog(level) {

// 如果指定了 NONE 就不打印
if (this.options.level === levels['NONE']) {

@@ -99,7 +99,10 @@ return false;

/**
* Transport 统一的记录日志的方法,会根据配置输出不同格式
* @param {String} level - 日志级别
* @param {Array} args - 所有的参数
* @param {Object} meta - 元信息
* @return {Buffer|String} 日志信息 - 如果无内容会返回空字符串, utf8编码返回 String, 其他编码返回 Buffer
* Transport log method
* @param {String} level - log level
* @param {Array} args - all methods
* @param {Object} meta - meta infomations
* @return {Buffer|String} log message
* - empty string means no log
* - utf8 encoding return String
* - other encoding return Buffer
*/

@@ -111,3 +114,3 @@ log(level, args, meta) {

/**
* 重载 Transport,无特殊情况可不覆盖
* reload Transport
*/

@@ -117,3 +120,3 @@ reload() {}

/**
* 关闭 Transport,无特殊情况可不覆盖
* close Transport
*/

@@ -120,0 +123,0 @@ close() {}

{
"name": "egg-logger",
"version": "2.0.0",
"version": "2.0.1",
"description": "egg logger",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc