bare-logger
Low-level logger for Bare
bare-logger — Low-level logger for Bare. It is a native addon.
npm i bare-loggerUsage
const Log = require('bare-logger')
const log = new Log()
log.info('Hello %s', 'world!')API
Log
new Log(options?: LogOptions)
Source
Create a logger. colors defaults to whether the current stream is a TTY.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
options? | LogOptions | — | Logger options; colors forces ANSI color styling on or off, defaulting to whether the output stream is a TTY. |
clear(): void
Source
Clears the log output. A no-op on the base Log.
colors: boolean
Source
Whether this logger applies ANSI color styling to formatted output. Read-only.
debug(...data: unknown[]): void
Source
Logs data at debug level.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
data | unknown[] | — | Values to format and log; the first may be a printf-style format string (e.g. %s, %d, %o) with the remaining values as substitutions. |
error(...data: unknown[]): void
Source
Logs data at error level.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
data | unknown[] | — | Values to format and log; the first may be a printf-style format string (e.g. %s, %d, %o) with the remaining values as substitutions. |
fatal(...data: unknown[]): void
Source
Logs data at fatal level.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
data | unknown[] | — | Values to format and log; the first may be a printf-style format string (e.g. %s, %d, %o) with the remaining values as substitutions. |
format(...data: unknown[]): string
Source
Formats data the same way debug, info, warn, error, and fatal do, and returns the resulting string without logging it.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
data | unknown[] | — | Values to format and log; the first may be a printf-style format string (e.g. %s, %d, %o) with the remaining values as substitutions. |
info(...data: unknown[]): void
Source
Logs data at info level.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
data | unknown[] | — | Values to format and log; the first may be a printf-style format string (e.g. %s, %d, %o) with the remaining values as substitutions. |
warn(...data: unknown[]): void
Source
Logs data at warn level.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
data | unknown[] | — | Values to format and log; the first may be a printf-style format string (e.g. %s, %d, %o) with the remaining values as substitutions. |
CompositeLog
new CompositeLog(logs: Log[])
Source
Create a logger that forwards every call to each logger in logs, so a single log call can write to, for example, both the console and a file.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
logs | Log[] | — | The loggers to forward every call to, in order. |
Types
LogOptions
interface LogOptions {
colors?: boolean
}Options for Log. colors forces ANSI color styling on or off in formatted output.
See also
- Bare modules — the full
bare-*catalog. - Bare runtime API — the runtime these modules extend.