Skip to content

Commit

Permalink
docs(logger): use async (#1719)
Browse files Browse the repository at this point in the history
  • Loading branch information
atian25 authored and popomore committed Nov 29, 2017
1 parent f39c105 commit 6741999
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
14 changes: 6 additions & 8 deletions docs/source/en/core/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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);
}
}
Expand Down
13 changes: 4 additions & 9 deletions docs/source/zh-cn/core/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ Transport 是一种传输通道,一个 logger 可包含多个传输通道。
首先我们定义一个日志的 transport,代表第三方日志服务。

```js
const co = require('co');
const util = require('util');
const Transport = require('egg-logger').Transport;

Expand All @@ -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);
}
}
Expand Down Expand Up @@ -321,6 +318,4 @@ module.exports = appInfo => {

> 日志同步写入内存,异步每隔一段时间(默认 1 秒)刷盘


更多详细请参考 [egg-logger](https://github.com/eggjs/egg-logger)[egg-logrotator](https://github.com/eggjs/egg-logrotator)

0 comments on commit 6741999

Please sign in to comment.