diff --git a/std/log/README.md b/std/log/README.md index 4c69784f99..3989d1fb78 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 b7a8c9cae2..5e72ff5826 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 => 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(); } }