@xylabs/logger 4.13.15 → 4.13.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -31
- package/{build → dist}/neutral/LevelLogger.d.ts +0 -1
- package/{build → dist}/neutral/LevelLogger.d.ts.map +1 -1
- package/dist/neutral/NoOpLogFunction.d.ts +2 -0
- package/dist/neutral/NoOpLogFunction.d.ts.map +1 -0
- package/dist/neutral/SilentLogger.d.ts +17 -0
- package/dist/neutral/SilentLogger.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +7 -67
- package/{build → dist}/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +16 -1
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/spec/IdLogger.spec.d.ts +2 -0
- package/dist/neutral/spec/IdLogger.spec.d.ts.map +1 -0
- package/package.json +7 -7
- package/src/LevelLogger.ts +2 -2
- package/src/NoOpLogFunction.ts +1 -0
- package/src/SilentLogger.ts +18 -0
- package/src/index.ts +2 -0
- package/build/neutral/index.d.ts +0 -5
- /package/{build → dist}/neutral/ConsoleLogger.d.ts +0 -0
- /package/{build → dist}/neutral/ConsoleLogger.d.ts.map +0 -0
- /package/{build → dist}/neutral/IdLogger.d.ts +0 -0
- /package/{build → dist}/neutral/IdLogger.d.ts.map +0 -0
- /package/{build → dist}/neutral/getFunctionName.d.ts +0 -0
- /package/{build → dist}/neutral/getFunctionName.d.ts.map +0 -0
package/README.md
CHANGED
|
@@ -1,63 +1,54 @@
|
|
|
1
|
-
[![logo][]](https://xylabs.com)
|
|
2
|
-
|
|
3
1
|
# @xylabs/logger
|
|
4
2
|
|
|
3
|
+
[![logo][]](https://xylabs.com)
|
|
4
|
+
|
|
5
|
+
[![main-build][]][main-build-link]
|
|
5
6
|
[![npm-badge][]][npm-link]
|
|
6
7
|
[![npm-downloads-badge][]][npm-link]
|
|
7
8
|
[![jsdelivr-badge][]][jsdelivr-link]
|
|
8
9
|
[![npm-license-badge][]](LICENSE)
|
|
10
|
+
[![codacy-badge][]][codacy-link]
|
|
11
|
+
[![codeclimate-badge][]][codeclimate-link]
|
|
12
|
+
[![snyk-badge][]][snyk-link]
|
|
9
13
|
[![socket-badge][]][socket-link]
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Table of Contents
|
|
14
|
-
|
|
15
|
-
- [Description](#description)
|
|
16
|
-
- [Install](#install)
|
|
17
|
-
- [Maintainers](#maintainers)
|
|
18
|
-
- [License](#license)
|
|
19
|
-
- [Credits](#credits)
|
|
20
|
-
|
|
21
|
-
## Description
|
|
15
|
+
Version: 4.13.15
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
XYLabs Logger Library
|
|
24
18
|
|
|
25
|
-
##
|
|
26
|
-
|
|
27
|
-
Using npm:
|
|
28
|
-
|
|
29
|
-
```sh
|
|
30
|
-
npm i --save @xylabs/logger
|
|
31
|
-
```
|
|
19
|
+
## Documentation
|
|
32
20
|
|
|
33
|
-
|
|
21
|
+
Coming Soon!
|
|
34
22
|
|
|
35
|
-
|
|
36
|
-
yarn add @xylabs/logger
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Documentation
|
|
40
|
-
[Developer Reference](https://xylabs.github.io/sdk-js)
|
|
23
|
+
Part of [sdk-js](https://www.npmjs.com/package/@xyo-network/sdk-js)
|
|
41
24
|
|
|
42
25
|
## Maintainers
|
|
43
26
|
|
|
44
27
|
- [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com))
|
|
45
|
-
- [Joel Carter](https://github.com/JoelBCarter)
|
|
46
28
|
- [Matt Jones](https://github.com/jonesmac)
|
|
29
|
+
- [Joel Carter](https://github.com/JoelBCarter)
|
|
47
30
|
- [Jordan Trouw](https://github.com/jordantrouw)
|
|
48
31
|
|
|
49
32
|
## License
|
|
50
33
|
|
|
51
|
-
See the [LICENSE](LICENSE) file for license details
|
|
34
|
+
> See the [LICENSE](LICENSE) file for license details
|
|
52
35
|
|
|
53
36
|
## Credits
|
|
54
37
|
|
|
55
|
-
[Made with 🔥and ❄️ by
|
|
38
|
+
[Made with 🔥 and ❄️ by XYLabs](https://xylabs.com)
|
|
56
39
|
|
|
57
40
|
[logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
|
|
58
41
|
|
|
42
|
+
[main-build]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml/badge.svg
|
|
43
|
+
[main-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml
|
|
59
44
|
[npm-badge]: https://img.shields.io/npm/v/@xylabs/logger.svg
|
|
60
45
|
[npm-link]: https://www.npmjs.com/package/@xylabs/logger
|
|
46
|
+
[codacy-badge]: https://app.codacy.com/project/badge/Grade/c8e15e14f37741c18cfb47ac7245c698
|
|
47
|
+
[codacy-link]: https://www.codacy.com/gh/xylabs/sdk-js/dashboard?utm_source=github.com&utm_medium=referral&utm_content=xylabs/sdk-js&utm_campaign=Badge_Grade
|
|
48
|
+
[codeclimate-badge]: https://api.codeclimate.com/v1/badges/c5eb068f806f0b047ea7/maintainability
|
|
49
|
+
[codeclimate-link]: https://codeclimate.com/github/xylabs/sdk-js/maintainability
|
|
50
|
+
[snyk-badge]: https://snyk.io/test/github/xylabs/sdk-js/badge.svg?targetFile=package.json
|
|
51
|
+
[snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json
|
|
61
52
|
|
|
62
53
|
[npm-downloads-badge]: https://img.shields.io/npm/dw/@xylabs/logger
|
|
63
54
|
[npm-license-badge]: https://img.shields.io/npm/l/@xylabs/logger
|
|
@@ -30,7 +30,6 @@ export type LogLevelValue = EnumValue<typeof LogLevel>;
|
|
|
30
30
|
* makes it confusing to import
|
|
31
31
|
*/
|
|
32
32
|
export type LogLevel = LogLevelValue;
|
|
33
|
-
export declare const NoOpLogFunction: (..._data: unknown[]) => undefined;
|
|
34
33
|
export declare class LevelLogger implements Logger {
|
|
35
34
|
readonly level: LogLevelValue;
|
|
36
35
|
readonly logger: Logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LevelLogger.d.ts","sourceRoot":"","sources":["../../src/LevelLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"LevelLogger.d.ts","sourceRoot":"","sources":["../../src/LevelLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AAInC,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;AAEtD;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,WAAW,CAAA;IAClB,KAAK,EAAE,WAAW,CAAA;IAClB,IAAI,EAAE,WAAW,CAAA;IACjB,GAAG,EAAE,WAAW,CAAA;IAChB,KAAK,EAAE,WAAW,CAAA;IAClB,IAAI,EAAE,WAAW,CAAA;CAClB;AAED,eAAO,MAAM,QAAQ;;;;;;;EAOnB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,QAAQ,CAAC,CAAA;AAClD,MAAM,MAAM,YAAY,GAAG,WAAW,CAAA;AAEtC,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,OAAO,QAAQ,CAAC,CAAA;AACtD;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,aAAa,CAAA;AAEpC,qBAAa,WAAY,YAAW,MAAM;IACxC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAA;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;gBACX,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,aAA6B;IAKhE,IAAI,KAAK,gBAER;IAED,IAAI,KAAK,gBAER;IAED,IAAI,IAAI,gBAEP;IAED,IAAI,GAAG,gBAEN;IAED,IAAI,KAAK,gBAER;IAED,IAAI,IAAI,gBAEP;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoOpLogFunction.d.ts","sourceRoot":"","sources":["../../src/NoOpLogFunction.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,GAAI,GAAG,OAAO,OAAO,EAAE,cAAY,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Logger } from './LevelLogger.ts';
|
|
2
|
+
/**
|
|
3
|
+
* A logger that does not log anything.
|
|
4
|
+
* This is useful when you want to disable logging
|
|
5
|
+
* like when running unit tests or in silent mode.
|
|
6
|
+
* It implements the `Logger` interface but all methods
|
|
7
|
+
* are no-op functions.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SilentLogger implements Logger {
|
|
10
|
+
readonly debug: (..._data: unknown[]) => undefined;
|
|
11
|
+
readonly error: (..._data: unknown[]) => undefined;
|
|
12
|
+
readonly info: (..._data: unknown[]) => undefined;
|
|
13
|
+
readonly log: (..._data: unknown[]) => undefined;
|
|
14
|
+
readonly trace: (..._data: unknown[]) => undefined;
|
|
15
|
+
readonly warn: (..._data: unknown[]) => undefined;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=SilentLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SilentLogger.d.ts","sourceRoot":"","sources":["../../src/SilentLogger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAG9C;;;;;;GAMG;AACH,qBAAa,YAAa,YAAW,MAAM;IACzC,QAAQ,CAAC,KAAK,qCAAkB;IAChC,QAAQ,CAAC,KAAK,qCAAkB;IAChC,QAAQ,CAAC,IAAI,qCAAkB;IAC/B,QAAQ,CAAC,GAAG,qCAAkB;IAC9B,QAAQ,CAAC,KAAK,qCAAkB;IAChC,QAAQ,CAAC,IAAI,qCAAkB;CAChC"}
|
package/dist/neutral/index.d.ts
CHANGED
|
@@ -1,67 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
|
|
8
|
-
interface Logger {
|
|
9
|
-
debug: LogFunction;
|
|
10
|
-
error: LogFunction;
|
|
11
|
-
info: LogFunction;
|
|
12
|
-
log: LogFunction;
|
|
13
|
-
trace: LogFunction;
|
|
14
|
-
warn: LogFunction;
|
|
15
|
-
}
|
|
16
|
-
type LogLevelKey = EnumKey<typeof LogLevel>;
|
|
17
|
-
type LogVerbosity = LogLevelKey;
|
|
18
|
-
type LogLevelValue = EnumValue<typeof LogLevel>;
|
|
19
|
-
declare const LogLevel: Enum<{
|
|
20
|
-
error: 1;
|
|
21
|
-
warn: 2;
|
|
22
|
-
info: 3;
|
|
23
|
-
log: 4;
|
|
24
|
-
debug: 5;
|
|
25
|
-
trace: 6;
|
|
26
|
-
}>;
|
|
27
|
-
/**
|
|
28
|
-
* @deprecated Use `LogLevelValue` instead.
|
|
29
|
-
* This name conflicts with the `LogLevel` enum and
|
|
30
|
-
* makes it confusing to import
|
|
31
|
-
*/
|
|
32
|
-
type LogLevel = LogLevelValue;
|
|
33
|
-
declare const NoOpLogFunction: (..._data: unknown[]) => undefined;
|
|
34
|
-
declare class LevelLogger implements Logger {
|
|
35
|
-
readonly level: LogLevelValue;
|
|
36
|
-
readonly logger: Logger;
|
|
37
|
-
constructor(logger: Logger, level?: LogLevelValue);
|
|
38
|
-
get debug(): LogFunction;
|
|
39
|
-
get error(): LogFunction;
|
|
40
|
-
get info(): LogFunction;
|
|
41
|
-
get log(): LogFunction;
|
|
42
|
-
get trace(): LogFunction;
|
|
43
|
-
get warn(): LogFunction;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare class ConsoleLogger extends LevelLogger {
|
|
47
|
-
constructor(level?: LogLevel);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
declare const getFunctionName: (depth?: number) => string;
|
|
51
|
-
|
|
52
|
-
declare class IdLogger implements Logger {
|
|
53
|
-
private _id?;
|
|
54
|
-
private _logger;
|
|
55
|
-
constructor(logger: Logger, id?: () => string);
|
|
56
|
-
set id(id: string);
|
|
57
|
-
debug(...data: unknown[]): void;
|
|
58
|
-
error(...data: unknown[]): void;
|
|
59
|
-
info(...data: unknown[]): void;
|
|
60
|
-
log(...data: unknown[]): void;
|
|
61
|
-
trace(...data: unknown[]): void;
|
|
62
|
-
warn(...data: unknown[]): void;
|
|
63
|
-
private prefix;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { ConsoleLogger, IdLogger, LevelLogger, LogLevel, NoOpLogFunction, getFunctionName };
|
|
67
|
-
export type { LogFunction, LogLevelKey, LogLevelValue, LogVerbosity, Logger };
|
|
1
|
+
export * from './ConsoleLogger.ts';
|
|
2
|
+
export * from './getFunctionName.ts';
|
|
3
|
+
export * from './IdLogger.ts';
|
|
4
|
+
export * from './LevelLogger.ts';
|
|
5
|
+
export * from './NoOpLogFunction.ts';
|
|
6
|
+
export * from './SilentLogger.ts';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,sBAAsB,CAAA;AACpC,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// src/LevelLogger.ts
|
|
2
2
|
import { Enum } from "@xylabs/enum";
|
|
3
|
+
|
|
4
|
+
// src/NoOpLogFunction.ts
|
|
5
|
+
var NoOpLogFunction = (..._data) => void {};
|
|
6
|
+
|
|
7
|
+
// src/LevelLogger.ts
|
|
3
8
|
var LogLevel = Enum({
|
|
4
9
|
error: 1,
|
|
5
10
|
warn: 2,
|
|
@@ -8,7 +13,6 @@ var LogLevel = Enum({
|
|
|
8
13
|
debug: 5,
|
|
9
14
|
trace: 6
|
|
10
15
|
});
|
|
11
|
-
var NoOpLogFunction = (..._data) => void {};
|
|
12
16
|
var LevelLogger = class {
|
|
13
17
|
level;
|
|
14
18
|
logger;
|
|
@@ -99,12 +103,23 @@ var IdLogger = class {
|
|
|
99
103
|
return `[${this._id?.()}]`;
|
|
100
104
|
}
|
|
101
105
|
};
|
|
106
|
+
|
|
107
|
+
// src/SilentLogger.ts
|
|
108
|
+
var SilentLogger = class {
|
|
109
|
+
debug = NoOpLogFunction;
|
|
110
|
+
error = NoOpLogFunction;
|
|
111
|
+
info = NoOpLogFunction;
|
|
112
|
+
log = NoOpLogFunction;
|
|
113
|
+
trace = NoOpLogFunction;
|
|
114
|
+
warn = NoOpLogFunction;
|
|
115
|
+
};
|
|
102
116
|
export {
|
|
103
117
|
ConsoleLogger,
|
|
104
118
|
IdLogger,
|
|
105
119
|
LevelLogger,
|
|
106
120
|
LogLevel,
|
|
107
121
|
NoOpLogFunction,
|
|
122
|
+
SilentLogger,
|
|
108
123
|
getFunctionName
|
|
109
124
|
};
|
|
110
125
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/LevelLogger.ts","../../src/ConsoleLogger.ts","../../src/getFunctionName.ts","../../src/IdLogger.ts"],"sourcesContent":["import type { EnumKey, EnumValue } from '@xylabs/enum'\nimport { Enum } from '@xylabs/enum'\n\nexport type LogFunction = (...data: unknown[]) => void\n\n/**\n * Interface to handle overlap between Winston &\n * `console` with as much congruency as possible.\n */\nexport interface Logger {\n debug: LogFunction\n error: LogFunction\n info: LogFunction\n log: LogFunction\n trace: LogFunction\n warn: LogFunction\n}\n\nexport const LogLevel = Enum({\n error: 1,\n warn: 2,\n info: 3,\n log: 4,\n debug: 5,\n trace: 6,\n})\n\nexport type LogLevelKey = EnumKey<typeof LogLevel>\nexport type LogVerbosity = LogLevelKey\n\nexport type LogLevelValue = EnumValue<typeof LogLevel>\n/**\n * @deprecated Use `LogLevelValue` instead.\n * This name conflicts with the `LogLevel` enum and\n * makes it confusing to import\n */\nexport type LogLevel = LogLevelValue\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../src/LevelLogger.ts","../../src/NoOpLogFunction.ts","../../src/ConsoleLogger.ts","../../src/getFunctionName.ts","../../src/IdLogger.ts","../../src/SilentLogger.ts"],"sourcesContent":["import type { EnumKey, EnumValue } from '@xylabs/enum'\nimport { Enum } from '@xylabs/enum'\n\nimport { NoOpLogFunction } from './NoOpLogFunction.ts'\n\nexport type LogFunction = (...data: unknown[]) => void\n\n/**\n * Interface to handle overlap between Winston &\n * `console` with as much congruency as possible.\n */\nexport interface Logger {\n debug: LogFunction\n error: LogFunction\n info: LogFunction\n log: LogFunction\n trace: LogFunction\n warn: LogFunction\n}\n\nexport const LogLevel = Enum({\n error: 1,\n warn: 2,\n info: 3,\n log: 4,\n debug: 5,\n trace: 6,\n})\n\nexport type LogLevelKey = EnumKey<typeof LogLevel>\nexport type LogVerbosity = LogLevelKey\n\nexport type LogLevelValue = EnumValue<typeof LogLevel>\n/**\n * @deprecated Use `LogLevelValue` instead.\n * This name conflicts with the `LogLevel` enum and\n * makes it confusing to import\n */\nexport type LogLevel = LogLevelValue\n\nexport class LevelLogger implements Logger {\n readonly level: LogLevelValue\n readonly logger: Logger\n constructor(logger: Logger, level: LogLevelValue = LogLevel.warn) {\n this.level = level\n this.logger = logger\n }\n\n get debug() {\n return this.level >= LogLevel.debug ? this.logger.debug : NoOpLogFunction\n }\n\n get error() {\n return this.level >= LogLevel.error ? this.logger.error : NoOpLogFunction\n }\n\n get info() {\n return this.level >= LogLevel.info ? this.logger.info : NoOpLogFunction\n }\n\n get log() {\n return this.level >= LogLevel.log ? this.logger.log : NoOpLogFunction\n }\n\n get trace() {\n return this.level >= LogLevel.trace ? this.logger.trace : NoOpLogFunction\n }\n\n get warn() {\n return this.level >= LogLevel.warn ? this.logger.warn : NoOpLogFunction\n }\n}\n","export const NoOpLogFunction = (..._data: unknown[]) => void {}\n","import { LevelLogger, LogLevel } from './LevelLogger.ts'\n\nexport class ConsoleLogger extends LevelLogger {\n constructor(level: LogLevel = LogLevel.warn) {\n super(console, level)\n }\n}\n","import { handleError } from '@xylabs/error'\nimport { isNumber } from '@xylabs/typeof'\n\nexport const getFunctionName = (depth = 2) => {\n try {\n throw new Error('Getting function name')\n } catch (ex) {\n return handleError(ex, (error) => {\n let newIndex: number | undefined\n const stackParts = error.stack?.split('\\n')[depth]?.split(' ')\n const funcName\n = stackParts?.find((item, index) => {\n if (item.length > 0 && item !== 'at') {\n // check if constructor\n if (item === 'new') {\n newIndex = index\n }\n return true\n }\n }) ?? '<unknown>'\n return isNumber(newIndex) ? `${funcName} ${stackParts?.[newIndex + 1]}` : funcName\n })\n }\n}\n","import type { Logger } from './LevelLogger.ts'\n\nexport class IdLogger implements Logger {\n private _id?: () => string\n private _logger: Logger\n\n constructor(logger: Logger, id?: () => string) {\n this._logger = logger\n this._id = id\n }\n\n set id(id: string) {\n this._id = () => id\n }\n\n debug(...data: unknown[]) {\n this._logger?.debug(this.prefix(), ...data)\n }\n\n error(...data: unknown[]) {\n this._logger?.error(this.prefix(), ...data)\n }\n\n info(...data: unknown[]) {\n this._logger?.info(this.prefix(), ...data)\n }\n\n log(...data: unknown[]) {\n this._logger?.log(this.prefix(), ...data)\n }\n\n trace(...data: unknown[]) {\n this._logger?.trace(this.prefix(), ...data)\n }\n\n warn(...data: unknown[]) {\n this._logger?.warn(this.prefix(), ...data)\n }\n\n private prefix() {\n return `[${this._id?.()}]`\n }\n}\n","import type { Logger } from './LevelLogger.ts'\nimport { NoOpLogFunction } from './NoOpLogFunction.ts'\n\n/**\n * A logger that does not log anything.\n * This is useful when you want to disable logging\n * like when running unit tests or in silent mode.\n * It implements the `Logger` interface but all methods\n * are no-op functions.\n */\nexport class SilentLogger implements Logger {\n readonly debug = NoOpLogFunction\n readonly error = NoOpLogFunction\n readonly info = NoOpLogFunction\n readonly log = NoOpLogFunction\n readonly trace = NoOpLogFunction\n readonly warn = NoOpLogFunction\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdLogger.spec.d.ts","sourceRoot":"","sources":["../../../src/spec/IdLogger.spec.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/logger",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.17",
|
|
4
4
|
"description": "XYLabs Logger Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logger",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"module": "dist/neutral/index.mjs",
|
|
37
37
|
"types": "dist/neutral/index.d.ts",
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xylabs/enum": "^4.13.
|
|
40
|
-
"@xylabs/error": "^4.13.
|
|
41
|
-
"@xylabs/typeof": "^4.13.
|
|
39
|
+
"@xylabs/enum": "^4.13.17",
|
|
40
|
+
"@xylabs/error": "^4.13.17",
|
|
41
|
+
"@xylabs/typeof": "^4.13.17"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/node": "^24.0.
|
|
45
|
-
"@xylabs/ts-scripts-yarn3": "^7.0.0-rc.
|
|
46
|
-
"@xylabs/tsconfig": "^7.0.0-rc.
|
|
44
|
+
"@types/node": "^24.0.14",
|
|
45
|
+
"@xylabs/ts-scripts-yarn3": "^7.0.0-rc.27",
|
|
46
|
+
"@xylabs/tsconfig": "^7.0.0-rc.27",
|
|
47
47
|
"typescript": "^5.8.3",
|
|
48
48
|
"vitest": "^3.2.4"
|
|
49
49
|
},
|
package/src/LevelLogger.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { EnumKey, EnumValue } from '@xylabs/enum'
|
|
2
2
|
import { Enum } from '@xylabs/enum'
|
|
3
3
|
|
|
4
|
+
import { NoOpLogFunction } from './NoOpLogFunction.ts'
|
|
5
|
+
|
|
4
6
|
export type LogFunction = (...data: unknown[]) => void
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -36,8 +38,6 @@ export type LogLevelValue = EnumValue<typeof LogLevel>
|
|
|
36
38
|
*/
|
|
37
39
|
export type LogLevel = LogLevelValue
|
|
38
40
|
|
|
39
|
-
export const NoOpLogFunction = (..._data: unknown[]) => void {}
|
|
40
|
-
|
|
41
41
|
export class LevelLogger implements Logger {
|
|
42
42
|
readonly level: LogLevelValue
|
|
43
43
|
readonly logger: Logger
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const NoOpLogFunction = (..._data: unknown[]) => void {}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Logger } from './LevelLogger.ts'
|
|
2
|
+
import { NoOpLogFunction } from './NoOpLogFunction.ts'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A logger that does not log anything.
|
|
6
|
+
* This is useful when you want to disable logging
|
|
7
|
+
* like when running unit tests or in silent mode.
|
|
8
|
+
* It implements the `Logger` interface but all methods
|
|
9
|
+
* are no-op functions.
|
|
10
|
+
*/
|
|
11
|
+
export class SilentLogger implements Logger {
|
|
12
|
+
readonly debug = NoOpLogFunction
|
|
13
|
+
readonly error = NoOpLogFunction
|
|
14
|
+
readonly info = NoOpLogFunction
|
|
15
|
+
readonly log = NoOpLogFunction
|
|
16
|
+
readonly trace = NoOpLogFunction
|
|
17
|
+
readonly warn = NoOpLogFunction
|
|
18
|
+
}
|
package/src/index.ts
CHANGED
package/build/neutral/index.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|