eggjs / eggjs/egg

egg-logger 循环 reload

Open
#4,533 2 comments 0 reactions 0 assignees View on GitHub
Inactive
Dominant language
TypeScript
Stars
19k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

```
_createStream() {
mkdirp.sync(path.dirname(this.options.file));
const stream = fs.createWriteStream(this.options.file, { flags: 'a' });

const onError = err => {
console.error('%s ERROR %s [egg-logger] [%s] %s',
utility.logDate(','), process.pid, this.options.file, err.stack);
this.reload(); // 又重新调用,导致不断循环
console.warn('%s WARN %s [egg-logger] [%s] reloaded', utility.logDate(','), process.pid, this.options.file);
};
// only listen error once because stream will reload after error
stream.once('error', onError);
stream._onError = onError;
return stream;
}
```
通常情况下如果createWriteStream报错的话(权限,资源问题),一般是无法通过reload进行恢复的,而不断的reload不光不会修复问题,而且会消耗大量的硬件资源,不如抛个?
@atian25

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.