Skip to content

Loggable

Defined in: package/src/utils.ts:150

Provides a lightweight, extensible logging mechanism with customizable formatting.

The Loggable class is designed to be extended and used for temporary logging purposes, avoiding the memory overhead of persistent logger instances. Each instance is created when needed and goes out of scope once used, improving performance.

(Class unmodified except for five original source functions).

Constructors

new Loggable()

new Loggable(PACKAGE): Loggable

Defined in: package/src/utils.ts:151

Parameters

ParameterType

PACKAGE

string

Returns

Loggable

Properties

PACKAGE

PACKAGE: string;

Defined in: package/src/utils.ts:151

Methods

note()

note(header, ...messages): void

Defined in: package/src/utils.ts:153

Logs the message to the console as a standard note.

Parameters

ParameterType

header

string

messages

string[]

Returns

void


trace()

trace(header, ...messages): void

Defined in: package/src/utils.ts:158

Logs the message to the console with a debug level.

Parameters

ParameterType

header

string

messages

string[]

Returns

void


warn()

warn(header, ...messages): void

Defined in: package/src/utils.ts:165

Logs the message to the console as a warning.

Parameters

ParameterType

header

string

messages

string[]

Returns

void


panic()

panic(header, ...messages): void

Defined in: package/src/utils.ts:170

Logs the message to the console as an error.

Parameters

ParameterType

header

string

messages

string[]

Returns

void


format()

format(
header,
level,
codes, ...
message): string

Defined in: package/src/utils.ts:184

Formats the log into a styled string suitable for console output.

The format includes the log header, timestamp, and a separator.

Modified to give the ansi codes of the background

Parameters

ParameterTypeDescription

header

string

level

string

codes

ANSICodes[]

Ansi codes for styling

message

string[]

Returns

string

A formatted log string


formatLines()

formatLines(lines): string

Defined in: package/src/utils.ts:209

Formats the individual lines of the log with a consistent style.

Each line is prefixed with a vertical bar (|) for clarity.

Parameters

ParameterType

lines

string[]

Returns

string

A formatted string containing all log lines


toError()

toError(lines): Error

Defined in: package/src/utils.ts:223

Converts the log entry into an Error object.

The resulting Error will contain the concatenated lines of the log as its message.

Parameters

ParameterType

lines

string[]

Returns

Error

An Error object representing the log entry