@xylabs/logger
Advanced tools
+6
-6
| { | ||
| "name": "@xylabs/logger", | ||
| "version": "5.0.84", | ||
| "version": "5.0.86", | ||
| "description": "XYLabs Logger Library", | ||
@@ -45,10 +45,10 @@ "keywords": [ | ||
| "dependencies": { | ||
| "@xylabs/enum": "~5.0.84", | ||
| "@xylabs/error": "~5.0.84", | ||
| "@xylabs/typeof": "~5.0.84" | ||
| "@xylabs/enum": "~5.0.86", | ||
| "@xylabs/error": "~5.0.86", | ||
| "@xylabs/typeof": "~5.0.86" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "~25.4.0", | ||
| "@xylabs/ts-scripts-yarn3": "~7.4.13", | ||
| "@xylabs/tsconfig": "~7.4.13", | ||
| "@xylabs/ts-scripts-yarn3": "~7.4.16", | ||
| "@xylabs/tsconfig": "~7.4.16", | ||
| "typescript": "~5.9.3", | ||
@@ -55,0 +55,0 @@ "vitest": "~4.0.18" |
+102
-294
@@ -18,2 +18,4 @@ # @xylabs/logger | ||
| ## Reference | ||
@@ -27,26 +29,36 @@ | ||
| - [ConsoleLogger](#classes/ConsoleLogger) | ||
| - [IdLogger](#classes/IdLogger) | ||
| - [LevelLogger](#classes/LevelLogger) | ||
| - [SilentLogger](#classes/SilentLogger) | ||
| | Class | Description | | ||
| | ------ | ------ | | ||
| | [ConsoleLogger](#classes/ConsoleLogger) | A LevelLogger that delegates to the global `console` object. | | ||
| | [IdLogger](#classes/IdLogger) | A logger wrapper that prefixes every log message with a bracketed identifier. Useful for distinguishing log output from different components or instances. | | ||
| | [LevelLogger](#classes/LevelLogger) | A logger that filters messages based on a configured log level. Methods for levels above the configured threshold return a no-op function. | | ||
| | [SilentLogger](#classes/SilentLogger) | A 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. | | ||
| ## Interfaces | ||
| - [Logger](#interfaces/Logger) | ||
| | Interface | Description | | ||
| | ------ | ------ | | ||
| | [Logger](#interfaces/Logger) | Interface to handle overlap between Winston & `console` with as much congruency as possible. | | ||
| ## Type Aliases | ||
| - [LogFunction](#type-aliases/LogFunction) | ||
| - [LogLevelKey](#type-aliases/LogLevelKey) | ||
| - [LogVerbosity](#type-aliases/LogVerbosity) | ||
| - [LogLevelValue](#type-aliases/LogLevelValue) | ||
| | Type Alias | Description | | ||
| | ------ | ------ | | ||
| | [LogFunction](#type-aliases/LogFunction) | A generic logging function that accepts any number of arguments. | | ||
| | [LogLevelKey](#type-aliases/LogLevelKey) | String key for a log level (e.g. 'error', 'warn', 'info'). | | ||
| | [LogVerbosity](#type-aliases/LogVerbosity) | Alias for LogLevelKey, representing the verbosity setting as a string. | | ||
| | [LogLevelValue](#type-aliases/LogLevelValue) | Numeric value of a log level (1 through 6). | | ||
| ## Variables | ||
| - [LogLevel](#variables/LogLevel) | ||
| | Variable | Description | | ||
| | ------ | ------ | | ||
| | [LogLevel](#variables/LogLevel) | Numeric log level values, from least verbose (error=1) to most verbose (trace=6). | | ||
| ## Functions | ||
| - [NoOpLogFunction](#functions/NoOpLogFunction) | ||
| - [getFunctionName](#functions/getFunctionName) | ||
| | Function | Description | | ||
| | ------ | ------ | | ||
| | [NoOpLogFunction](#functions/NoOpLogFunction) | A log function that silently discards all arguments. | | ||
| | [getFunctionName](#functions/getFunctionName) | Retrieves the name of the calling function by inspecting the stack trace. | | ||
@@ -72,3 +84,3 @@ ### classes | ||
| ```ts | ||
| new ConsoleLogger(level?): ConsoleLogger; | ||
| new ConsoleLogger(level?: LogLevelValue): ConsoleLogger; | ||
| ``` | ||
@@ -78,6 +90,6 @@ | ||
| #### level? | ||
| | Parameter | Type | Default value | | ||
| | ------ | ------ | ------ | | ||
| | `level` | [`LogLevelValue`](#../type-aliases/LogLevelValue) | `LogLevel.warn` | | ||
| [`LogLevelValue`](#../type-aliases/LogLevelValue) = `LogLevel.warn` | ||
| ### Returns | ||
@@ -93,24 +105,7 @@ | ||
| ### level | ||
| | Property | Modifier | Type | Inherited from | | ||
| | ------ | ------ | ------ | ------ | | ||
| | <a id="level"></a> `level` | `readonly` | [`LogLevelValue`](#../type-aliases/LogLevelValue) | [`LevelLogger`](#LevelLogger).[`level`](LevelLogger.md#level) | | ||
| | <a id="logger"></a> `logger` | `readonly` | [`Logger`](#../interfaces/Logger) | [`LevelLogger`](#LevelLogger).[`logger`](LevelLogger.md#logger) | | ||
| ```ts | ||
| readonly level: LogLevelValue; | ||
| ``` | ||
| ### Inherited from | ||
| [`LevelLogger`](#LevelLogger).[`level`](LevelLogger.md#level) | ||
| *** | ||
| ### logger | ||
| ```ts | ||
| readonly logger: Logger; | ||
| ``` | ||
| ### Inherited from | ||
| [`LevelLogger`](#LevelLogger).[`logger`](LevelLogger.md#logger) | ||
| ## Accessors | ||
@@ -242,3 +237,3 @@ | ||
| ```ts | ||
| new IdLogger(logger, id?): IdLogger; | ||
| new IdLogger(logger: Logger, id?: () => string): IdLogger; | ||
| ``` | ||
@@ -248,10 +243,7 @@ | ||
| #### logger | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `logger` | [`Logger`](#../interfaces/Logger) | | ||
| | `id?` | () => `string` | | ||
| [`Logger`](#../interfaces/Logger) | ||
| #### id? | ||
| () => `string` | ||
| ### Returns | ||
@@ -268,3 +260,3 @@ | ||
| ```ts | ||
| set id(id): void; | ||
| set id(id: string): void; | ||
| ``` | ||
@@ -274,6 +266,6 @@ | ||
| ##### id | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | `id` | `string` | | ||
| `string` | ||
| #### Returns | ||
@@ -288,3 +280,3 @@ | ||
| ```ts | ||
| debug(...data): void; | ||
| debug(...data: unknown[]): void; | ||
| ``` | ||
@@ -294,6 +286,6 @@ | ||
| #### data | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | ...`data` | `unknown`[] | | ||
| ...`unknown`[] | ||
| ### Returns | ||
@@ -314,3 +306,3 @@ | ||
| ```ts | ||
| error(...data): void; | ||
| error(...data: unknown[]): void; | ||
| ``` | ||
@@ -320,6 +312,6 @@ | ||
| #### data | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | ...`data` | `unknown`[] | | ||
| ...`unknown`[] | ||
| ### Returns | ||
@@ -340,3 +332,3 @@ | ||
| ```ts | ||
| info(...data): void; | ||
| info(...data: unknown[]): void; | ||
| ``` | ||
@@ -346,6 +338,6 @@ | ||
| #### data | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | ...`data` | `unknown`[] | | ||
| ...`unknown`[] | ||
| ### Returns | ||
@@ -366,3 +358,3 @@ | ||
| ```ts | ||
| log(...data): void; | ||
| log(...data: unknown[]): void; | ||
| ``` | ||
@@ -372,6 +364,6 @@ | ||
| #### data | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | ...`data` | `unknown`[] | | ||
| ...`unknown`[] | ||
| ### Returns | ||
@@ -392,3 +384,3 @@ | ||
| ```ts | ||
| trace(...data): void; | ||
| trace(...data: unknown[]): void; | ||
| ``` | ||
@@ -398,6 +390,6 @@ | ||
| #### data | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | ...`data` | `unknown`[] | | ||
| ...`unknown`[] | ||
| ### Returns | ||
@@ -418,3 +410,3 @@ | ||
| ```ts | ||
| warn(...data): void; | ||
| warn(...data: unknown[]): void; | ||
| ``` | ||
@@ -424,6 +416,6 @@ | ||
| #### data | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | ...`data` | `unknown`[] | | ||
| ...`unknown`[] | ||
| ### Returns | ||
@@ -461,3 +453,3 @@ | ||
| ```ts | ||
| new LevelLogger(logger, level?): LevelLogger; | ||
| new LevelLogger(logger: Logger, level?: LogLevelValue): LevelLogger; | ||
| ``` | ||
@@ -467,10 +459,7 @@ | ||
| #### logger | ||
| | Parameter | Type | Default value | | ||
| | ------ | ------ | ------ | | ||
| | `logger` | [`Logger`](#../interfaces/Logger) | `undefined` | | ||
| | `level` | [`LogLevelValue`](#../type-aliases/LogLevelValue) | `LogLevel.warn` | | ||
| [`Logger`](#../interfaces/Logger) | ||
| #### level? | ||
| [`LogLevelValue`](#../type-aliases/LogLevelValue) = `LogLevel.warn` | ||
| ### Returns | ||
@@ -482,16 +471,7 @@ | ||
| ### level | ||
| | Property | Modifier | Type | | ||
| | ------ | ------ | ------ | | ||
| | <a id="level"></a> `level` | `readonly` | [`LogLevelValue`](#../type-aliases/LogLevelValue) | | ||
| | <a id="logger"></a> `logger` | `readonly` | [`Logger`](#../interfaces/Logger) | | ||
| ```ts | ||
| readonly level: LogLevelValue; | ||
| ``` | ||
| *** | ||
| ### logger | ||
| ```ts | ||
| readonly logger: Logger; | ||
| ``` | ||
| ## Accessors | ||
@@ -635,144 +615,11 @@ | ||
| ### debug() | ||
| | Property | Modifier | Type | Default value | | ||
| | ------ | ------ | ------ | ------ | | ||
| | <a id="debug"></a> `debug` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` | | ||
| | <a id="error"></a> `error` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` | | ||
| | <a id="info"></a> `info` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` | | ||
| | <a id="log"></a> `log` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` | | ||
| | <a id="trace"></a> `trace` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` | | ||
| | <a id="warn"></a> `warn` | `readonly` | (...`_data`: `unknown`[]) => `undefined` | `NoOpLogFunction` | | ||
| ```ts | ||
| readonly debug: (..._data) => undefined = NoOpLogFunction; | ||
| ``` | ||
| A log function that silently discards all arguments. | ||
| ### Parameters | ||
| #### \_data | ||
| ...`unknown`[] | ||
| ### Returns | ||
| `undefined` | ||
| ### Implementation of | ||
| [`Logger`](#../interfaces/Logger).[`debug`](../interfaces/Logger.md#debug) | ||
| *** | ||
| ### error() | ||
| ```ts | ||
| readonly error: (..._data) => undefined = NoOpLogFunction; | ||
| ``` | ||
| A log function that silently discards all arguments. | ||
| ### Parameters | ||
| #### \_data | ||
| ...`unknown`[] | ||
| ### Returns | ||
| `undefined` | ||
| ### Implementation of | ||
| [`Logger`](#../interfaces/Logger).[`error`](../interfaces/Logger.md#error) | ||
| *** | ||
| ### info() | ||
| ```ts | ||
| readonly info: (..._data) => undefined = NoOpLogFunction; | ||
| ``` | ||
| A log function that silently discards all arguments. | ||
| ### Parameters | ||
| #### \_data | ||
| ...`unknown`[] | ||
| ### Returns | ||
| `undefined` | ||
| ### Implementation of | ||
| [`Logger`](#../interfaces/Logger).[`info`](../interfaces/Logger.md#info) | ||
| *** | ||
| ### log() | ||
| ```ts | ||
| readonly log: (..._data) => undefined = NoOpLogFunction; | ||
| ``` | ||
| A log function that silently discards all arguments. | ||
| ### Parameters | ||
| #### \_data | ||
| ...`unknown`[] | ||
| ### Returns | ||
| `undefined` | ||
| ### Implementation of | ||
| [`Logger`](#../interfaces/Logger).[`log`](../interfaces/Logger.md#log) | ||
| *** | ||
| ### trace() | ||
| ```ts | ||
| readonly trace: (..._data) => undefined = NoOpLogFunction; | ||
| ``` | ||
| A log function that silently discards all arguments. | ||
| ### Parameters | ||
| #### \_data | ||
| ...`unknown`[] | ||
| ### Returns | ||
| `undefined` | ||
| ### Implementation of | ||
| [`Logger`](#../interfaces/Logger).[`trace`](../interfaces/Logger.md#trace) | ||
| *** | ||
| ### warn() | ||
| ```ts | ||
| readonly warn: (..._data) => undefined = NoOpLogFunction; | ||
| ``` | ||
| A log function that silently discards all arguments. | ||
| ### Parameters | ||
| #### \_data | ||
| ...`unknown`[] | ||
| ### Returns | ||
| `undefined` | ||
| ### Implementation of | ||
| [`Logger`](#../interfaces/Logger).[`warn`](../interfaces/Logger.md#warn) | ||
| ### functions | ||
@@ -787,3 +634,3 @@ | ||
| ```ts | ||
| function NoOpLogFunction(..._data): undefined; | ||
| function NoOpLogFunction(..._data: unknown[]): undefined; | ||
| ``` | ||
@@ -795,6 +642,6 @@ | ||
| ### \_data | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | ...`_data` | `unknown`[] | | ||
| ...`unknown`[] | ||
| ## Returns | ||
@@ -811,3 +658,3 @@ | ||
| ```ts | ||
| function getFunctionName(depth?): string; | ||
| function getFunctionName(depth?: number): string; | ||
| ``` | ||
@@ -819,8 +666,6 @@ | ||
| ### depth? | ||
| | Parameter | Type | Default value | Description | | ||
| | ------ | ------ | ------ | ------ | | ||
| | `depth` | `number` | `2` | The stack frame depth to inspect (default: 2, the caller's caller). | | ||
| `number` = `2` | ||
| The stack frame depth to inspect (default: 2, the caller's caller). | ||
| ## Returns | ||
@@ -845,48 +690,11 @@ | ||
| ### debug | ||
| | Property | Type | | ||
| | ------ | ------ | | ||
| | <a id="debug"></a> `debug` | [`LogFunction`](#../type-aliases/LogFunction) | | ||
| | <a id="error"></a> `error` | [`LogFunction`](#../type-aliases/LogFunction) | | ||
| | <a id="info"></a> `info` | [`LogFunction`](#../type-aliases/LogFunction) | | ||
| | <a id="log"></a> `log` | [`LogFunction`](#../type-aliases/LogFunction) | | ||
| | <a id="trace"></a> `trace` | [`LogFunction`](#../type-aliases/LogFunction) | | ||
| | <a id="warn"></a> `warn` | [`LogFunction`](#../type-aliases/LogFunction) | | ||
| ```ts | ||
| debug: LogFunction; | ||
| ``` | ||
| *** | ||
| ### error | ||
| ```ts | ||
| error: LogFunction; | ||
| ``` | ||
| *** | ||
| ### info | ||
| ```ts | ||
| info: LogFunction; | ||
| ``` | ||
| *** | ||
| ### log | ||
| ```ts | ||
| log: LogFunction; | ||
| ``` | ||
| *** | ||
| ### trace | ||
| ```ts | ||
| trace: LogFunction; | ||
| ``` | ||
| *** | ||
| ### warn | ||
| ```ts | ||
| warn: LogFunction; | ||
| ``` | ||
| ### type-aliases | ||
@@ -901,3 +709,3 @@ | ||
| ```ts | ||
| type LogFunction = (...data) => void; | ||
| type LogFunction = (...data: unknown[]) => void; | ||
| ``` | ||
@@ -909,6 +717,6 @@ | ||
| ### data | ||
| | Parameter | Type | | ||
| | ------ | ------ | | ||
| | ...`data` | `unknown`[] | | ||
| ...`unknown`[] | ||
| ## Returns | ||
@@ -915,0 +723,0 @@ |
41315
3.99%789
-19.57%Updated
Updated
Updated