bare-file-logger
File system logger for Bare
stable
Source
Source
Source
Source
Source
bare-file-logger — File system logger for Bare.
npm i bare-file-loggerUsage
const FileLog = require('bare-file-logger')
const log = new FileLog('my-logs.txt')
log.info('Hello %s', 'world!')API
FileLog
new FileLog(path: string, options?: FileLogOptions)
Source
Construct a new FileLog that writes to the file at path.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path to the log file; opened for appending, and created if it does not exist. |
options? | FileLogOptions | — | Options controlling log rotation; see FileLogOptions. |
append(label: string, ...data: unknown[]): void
Source
Writes a single log line: the padded label, an ISO-8601 timestamp, and the formatted data, terminated by a newline.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
label | string | — | A short severity label, right-padded to five characters (e.g. info, error), prefixed to the line ahead of an ISO-8601 timestamp. |
data | unknown[] | — | Values to format into the log message, using the same formatting as console.log. |
close(): void
Source
Closes the underlying file descriptor and stops the rotation timer. Safe to call more than once.
Types
FileLogOptions
interface FileLogOptions {
maxSize?: number
rotate?: (path: string) => string
rotateInterval?: number
}FileLogEvents
interface FileLogEvents extends EventMap {
rotate: [path: string, archived: string | null]
}See also
- Bare modules — the full
bare-*catalog. - Bare runtime API — the runtime these modules extend.