LogoPear Docs

bare-logger

Low-level logger for Bare

stable

bare-logger — Low-level logger for Bare. It is a native addon.

npm i bare-logger

Usage

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

ParameterTypeDefaultDescription
options?LogOptionsLogger 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

ParameterTypeDefaultDescription
dataunknown[]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

ParameterTypeDefaultDescription
dataunknown[]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

ParameterTypeDefaultDescription
dataunknown[]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

ParameterTypeDefaultDescription
dataunknown[]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

ParameterTypeDefaultDescription
dataunknown[]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

ParameterTypeDefaultDescription
dataunknown[]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

ParameterTypeDefaultDescription
logsLog[]The loggers to forward every call to, in order.

Types

LogOptions

interface LogOptions {
  colors?: boolean
}
Source

Options for Log. colors forces ANSI color styling on or off in formatted output.

See also

On this page