diff --git a/docs/source/en/core/logger.md b/docs/source/en/core/logger.md index 252b254ced..46a21030c6 100644 --- a/docs/source/en/core/logger.md +++ b/docs/source/en/core/logger.md @@ -91,7 +91,7 @@ module.exports = app => { }; ``` -`app.coreLogger` in app is similar to `ctx.coreLogger` in context: +`app.coreLogger` in app is similar to `ctx.coreLogger` in context: ```js // app.js @@ -180,7 +180,7 @@ exports.logger = { ### Customized -For common scenarios, **it's unnecessary to create new logger**, because too many loggers will make them hard to be managed for later debugging. +For common scenarios, **it's unnecessary to create new logger**, because too many loggers will make them hard to be managed for later debugging. The logger you create can be declared in config: @@ -225,12 +225,10 @@ class RemoteErrorTransport extends Transport { } else { log = util.format(...args); } - const that = this; - co(function* () { - yield that.options.app.curl('http://url/to/remote/error/log/service/logs', { - data: log, - method: 'POST', - }); + + this.options.app.curl('http://url/to/remote/error/log/service/logs', { + data: log, + method: 'POST', }).catch(console.error); } } diff --git a/docs/source/zh-cn/core/logger.md b/docs/source/zh-cn/core/logger.md index 6199c08d9d..67c8c395d6 100644 --- a/docs/source/zh-cn/core/logger.md +++ b/docs/source/zh-cn/core/logger.md @@ -227,7 +227,6 @@ Transport 是一种传输通道,一个 logger 可包含多个传输通道。 首先我们定义一个日志的 transport,代表第三方日志服务。 ```js -const co = require('co'); const util = require('util'); const Transport = require('egg-logger').Transport; @@ -242,12 +241,10 @@ class RemoteErrorTransport extends Transport { } else { log = util.format(...args); } - const that = this; - co(function* () { - yield that.options.app.curl('http://url/to/remote/error/log/service/logs', { - data: log, - method: 'POST', - }); + + this.options.app.curl('http://url/to/remote/error/log/service/logs', { + data: log, + method: 'POST', }).catch(console.error); } } @@ -321,6 +318,4 @@ module.exports = appInfo => { > 日志同步写入内存,异步每隔一段时间(默认 1 秒)刷盘 - - 更多详细请参考 [egg-logger](https://github.com/eggjs/egg-logger) 和 [egg-logrotator](https://github.com/eggjs/egg-logrotator)。