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
Parameter | Type |
---|---|
|
|
Returns
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
Parameter | Type |
---|---|
|
|
… |
|
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
Parameter | Type |
---|---|
|
|
… |
|
Returns
void
warn()
warn(header, ...messages): void
Defined in: package/src/utils.ts:165
Logs the message to the console as a warning.
Parameters
Parameter | Type |
---|---|
|
|
… |
|
Returns
void
panic()
panic(header, ...messages): void
Defined in: package/src/utils.ts:170
Logs the message to the console as an error.
Parameters
Parameter | Type |
---|---|
|
|
… |
|
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
Parameter | Type | Description |
---|---|---|
|
| ‐ |
|
| ‐ |
| Ansi codes for styling | |
… |
| ‐ |
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
Parameter | Type |
---|---|
|
|
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
Parameter | Type |
---|---|
|
|
Returns
Error
An Error
object representing the log entry