@xylabs/logger
v5.0.97
Published
XYLabs Logger Library
Readme
@xylabs/logger
XYLabs Logger Library
Install
Using npm:
npm install {{name}}Using yarn:
yarn add {{name}}Using pnpm:
pnpm add {{name}}Using bun:
bun add {{name}}License
See the LICENSE file for license rights and limitations (LGPL-3.0-only).
Reference
packages
logger
### .temp-typedoc
### classes
### <a id="ConsoleLogger"></a>ConsoleLoggerA LevelLogger that delegates to the global console object.
Extends
Constructors
Constructor
new ConsoleLogger(level?): ConsoleLogger;Parameters
level?
LogLevelValue = LogLevel.warn
Returns
ConsoleLogger
Overrides
Properties
level
readonly level: LogLevelValue;Inherited from
logger
readonly logger: Logger;Inherited from
Accessors
debug
Get Signature
get debug(): LogFunction;Returns
Inherited from
error
Get Signature
get error(): LogFunction;Returns
Inherited from
info
Get Signature
get info(): LogFunction;Returns
Inherited from
log
Get Signature
get log(): LogFunction;Returns
Inherited from
trace
Get Signature
get trace(): LogFunction;Returns
Inherited from
warn
Get Signature
get warn(): LogFunction;Returns
Inherited from
### <a id="IdLogger"></a>IdLoggerA logger wrapper that prefixes every log message with a bracketed identifier. Useful for distinguishing log output from different components or instances.
Implements
Constructors
Constructor
new IdLogger(logger, id?): IdLogger;Parameters
logger
id?
() => string
Returns
IdLogger
Accessors
id
Set Signature
set id(id): void;Parameters
id
string
Returns
void
Methods
debug()
debug(...data): void;Parameters
data
...unknown[]
Returns
void
Implementation of
Logger.debugerror()
error(...data): void;Parameters
data
...unknown[]
Returns
void
Implementation of
Logger.errorinfo()
info(...data): void;Parameters
data
...unknown[]
Returns
void
Implementation of
Logger.infolog()
log(...data): void;Parameters
data
...unknown[]
Returns
void
Implementation of
Logger.logtrace()
trace(...data): void;Parameters
data
...unknown[]
Returns
void
Implementation of
Logger.tracewarn()
warn(...data): void;Parameters
data
...unknown[]
Returns
void
Implementation of
Logger.warn ### <a id="LevelLogger"></a>LevelLoggerA logger that filters messages based on a configured log level. Methods for levels above the configured threshold return a no-op function.
Extended by
Implements
Constructors
Constructor
new LevelLogger(logger, level?): LevelLogger;Parameters
logger
level?
LogLevelValue = LogLevel.warn
Returns
LevelLogger
Properties
level
readonly level: LogLevelValue;logger
readonly logger: Logger;Accessors
debug
Get Signature
get debug(): LogFunction;Returns
Implementation of
error
Get Signature
get error(): LogFunction;Returns
Implementation of
info
Get Signature
get info(): LogFunction;Returns
Implementation of
log
Get Signature
get log(): LogFunction;Returns
Implementation of
trace
Get Signature
get trace(): LogFunction;Returns
Implementation of
warn
Get Signature
get warn(): LogFunction;Returns
Implementation of
### <a id="SilentLogger"></a>SilentLoggerA logger that does not log anything.
This is useful when you want to disable logging
like when running unit tests or in silent mode.
It implements the Logger interface but all methods
are no-op functions.
Implements
Constructors
Constructor
new SilentLogger(): SilentLogger;Returns
SilentLogger
Properties
debug
readonly debug: (..._data) => undefined = NoOpLogFunction;A log function that silently discards all arguments.
Parameters
_data
...unknown[]
Returns
undefined
Implementation of
error
readonly error: (..._data) => undefined = NoOpLogFunction;A log function that silently discards all arguments.
Parameters
_data
...unknown[]
Returns
undefined
Implementation of
info
readonly info: (..._data) => undefined = NoOpLogFunction;A log function that silently discards all arguments.
Parameters
_data
...unknown[]
Returns
undefined
Implementation of
log
readonly log: (..._data) => undefined = NoOpLogFunction;A log function that silently discards all arguments.
Parameters
_data
...unknown[]
Returns
undefined
Implementation of
trace
readonly trace: (..._data) => undefined = NoOpLogFunction;A log function that silently discards all arguments.
Parameters
_data
...unknown[]
Returns
undefined
Implementation of
warn
readonly warn: (..._data) => undefined = NoOpLogFunction;A log function that silently discards all arguments.
Parameters
_data
...unknown[]
Returns
undefined
Implementation of
### functions
### <a id="NoOpLogFunction"></a>NoOpLogFunctionfunction NoOpLogFunction(..._data): undefined;A log function that silently discards all arguments.
Parameters
_data
...unknown[]
Returns
undefined
### <a id="getFunctionName"></a>getFunctionNamefunction getFunctionName(depth?): string;Retrieves the name of the calling function by inspecting the stack trace.
Parameters
depth?
number = 2
The stack frame depth to inspect (default: 2, the caller's caller).
Returns
string
The function name, or '' if it cannot be determined.
### interfaces
### <a id="Logger"></a>LoggerInterface to handle overlap between Winston &
console with as much congruency as possible.
Properties
debug
debug: LogFunction;error
error: LogFunction;info
info: LogFunction;log
log: LogFunction;trace
trace: LogFunction;warn
warn: LogFunction; ### type-aliases
### <a id="LogFunction"></a>LogFunctiontype LogFunction = (...data) => void;A generic logging function that accepts any number of arguments.
Parameters
data
...unknown[]
Returns
void
### <a id="LogLevelKey"></a>LogLevelKeytype LogLevelKey = EnumKey<typeof LogLevel>;String key for a log level (e.g. 'error', 'warn', 'info').
### <a id="LogLevelValue"></a>LogLevelValuetype LogLevelValue = EnumValue<typeof LogLevel>;Numeric value of a log level (1 through 6).
### <a id="LogVerbosity"></a>LogVerbositytype LogVerbosity = LogLevelKey;Alias for LogLevelKey, representing the verbosity setting as a string.
### variables
### <a id="LogLevel"></a>LogLevelconst LogLevel: Enum<{
error: 1;
warn: 2;
info: 3;
log: 4;
debug: 5;
trace: 6;
}>;Numeric log level values, from least verbose (error=1) to most verbose (trace=6).
