diff options
author | Chris Knight <cknight1234@gmail.com> | 2020-06-06 04:39:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-05 23:39:49 -0400 |
commit | c137b11abfb946ef72a5fcb27e11e0b286a33be3 (patch) | |
tree | 3034ec105668d543ac8dda541718760d693d529a | |
parent | 93175b7a79e09381ea556539f10cde9eaa61af89 (diff) |
fix: revert setInterval log flushing as it prevents process completion (#6127)
-rw-r--r-- | std/log/README.md | 16 | ||||
-rw-r--r-- | std/log/handlers.ts | 5 |
2 files changed, 8 insertions, 13 deletions
diff --git a/std/log/README.md b/std/log/README.md index 4c69784f9..3989d1fb7 100644 --- a/std/log/README.md +++ b/std/log/README.md @@ -107,10 +107,10 @@ interface HandlerOptions { #### `FileHandler` This handler will output to a file using an optional mode (default is `a`, e.g. -append). The file will grow indefinitely. It uses a buffer for writing to file -and will automatically flush every 30 seconds, though you can trigger this -yourself with `fileHandler.flush()`. Log messages with a log level greater than -error are immediately flushed. This logger takes `FileOptions`: +append). The file will grow indefinitely. It uses a buffer for writing to file. +Logs can be manually flushed with `fileHandler.flush()`. Log messages with a log +level greater than error are immediately flushed. Logs are also flushed on +process completion. This logger takes `FileOptions`: ```typescript interface FileHandlerOptions { @@ -151,10 +151,10 @@ backups to keep), `log.txt.1` would be renamed to `log.txt.2`, `log.txt` would be renamed to `log.txt.1` and finally `log.txt` would be created from scratch where the new log message would be written. -This handler uses a buffer for writing to file and will automatically flush -every 30 seconds, though you can trigger this yourself with -`fileHandler.flush()`. Log messages with a log level greater than error are -immediately flushed. +This handler uses a buffer for writing log messages to file. Logs can be +manually flushed with `fileHandler.flush()`. Log messages with a log level +greater than ERROR are immediately flushed. Logs are also flushed on process +completion. Options for this handler are: diff --git a/std/log/handlers.ts b/std/log/handlers.ts index b7a8c9cae..5e72ff582 100644 --- a/std/log/handlers.ts +++ b/std/log/handlers.ts @@ -106,7 +106,6 @@ export class FileHandler extends WriterHandler { protected _mode: LogMode; protected _openOptions: OpenOptions; protected _encoder = new TextEncoder(); - #intervalId = -1; #unloadCallback = (): Promise<void> => this.destroy(); constructor(levelName: LevelName, options: FileHandlerOptions) { @@ -129,9 +128,6 @@ export class FileHandler extends WriterHandler { this._buf = new BufWriterSync(this._file); addEventListener("unload", this.#unloadCallback); - - // flush the buffer every 30 seconds - this.#intervalId = setInterval(() => this.flush(), 30 * 1000); } handle(logRecord: LogRecord): void { @@ -158,7 +154,6 @@ export class FileHandler extends WriterHandler { this._file?.close(); this._file = undefined; removeEventListener("unload", this.#unloadCallback); - clearInterval(this.#intervalId); return Promise.resolve(); } } |