@thi.ng/rstream-log 4.1.100 → 5.0.0

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-02-10T08:59:57Z
3
+ - **Last updated**: 2024-02-16T20:01:44Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,17 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ # [5.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream-log@5.0.0) (2024-02-16)
13
+
14
+ #### 🛑 Breaking changes
15
+
16
+ - update Logger impl, remove obsolete types ([36c8649](https://github.com/thi-ng/umbrella/commit/36c8649))
17
+ - BREAKING CHANGE: update Logger, remove obsolete types
18
+ - Logger now a subclass of `ALogger` & implementing `ISubscriber` interface
19
+ - instead of extending rstream `StreamMerge`, now exposes a `Stream` via `.stream`
20
+ - adding child loggers now handled via `ILogger.childLogger()` or `ILogger.addChild()`
21
+ - update tests
22
+
12
23
  ### [4.1.84](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream-log@4.1.84) (2023-11-24)
13
24
 
14
25
  #### 🩹 Bug fixes
package/README.md CHANGED
@@ -61,7 +61,7 @@ filtering.
61
61
 
62
62
  ## Related packages
63
63
 
64
- - [@thi.ng/logger](https://github.com/thi-ng/umbrella/tree/develop/packages/logger) - Types & basis infrastructure for arbitrary logging (w/ default impls)
64
+ - [@thi.ng/logger](https://github.com/thi-ng/umbrella/tree/develop/packages/logger) - Basis types for arbitrary & hierarchical logging
65
65
 
66
66
  ## Installation
67
67
 
@@ -83,13 +83,12 @@ For Node.js REPL:
83
83
  const rstreamLog = await import("@thi.ng/rstream-log");
84
84
  ```
85
85
 
86
- Package sizes (brotli'd, pre-treeshake): ESM: 857 bytes
86
+ Package sizes (brotli'd, pre-treeshake): ESM: 707 bytes
87
87
 
88
88
  ## Dependencies
89
89
 
90
90
  - [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
91
91
  - [@thi.ng/checks](https://github.com/thi-ng/umbrella/tree/develop/packages/checks)
92
- - [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/develop/packages/errors)
93
92
  - [@thi.ng/logger](https://github.com/thi-ng/umbrella/tree/develop/packages/logger)
94
93
  - [@thi.ng/rstream](https://github.com/thi-ng/umbrella/tree/develop/packages/rstream)
95
94
  - [@thi.ng/strings](https://github.com/thi-ng/umbrella/tree/develop/packages/strings)
package/api.d.ts CHANGED
@@ -1,15 +1,6 @@
1
1
  import type { IID } from "@thi.ng/api";
2
- import type { ILogger as APILogger, LogLevel } from "@thi.ng/logger";
2
+ import type { ILogger as APILogger, LogEntry, LogLevel } from "@thi.ng/logger";
3
3
  import type { ISubscribable } from "@thi.ng/rstream";
4
- /**
5
- * @deprecated moved to thi.ng/logger package
6
- */
7
- export interface LogEntry extends Array<any> {
8
- [0]: LogLevel;
9
- [1]: string;
10
- [2]: number;
11
- [id: number]: any;
12
- }
13
4
  export interface LogEntryObj extends IID<string> {
14
5
  level: LogLevel;
15
6
  time: number;
package/logger.d.ts CHANGED
@@ -1,20 +1,13 @@
1
- import { LogLevel, type LogEntry } from "@thi.ng/logger/api";
2
- import { type ISubscribable } from "@thi.ng/rstream/api";
3
- import { StreamMerge } from "@thi.ng/rstream/merge";
4
- import type { ILogger } from "./api.js";
5
- export declare class Logger extends StreamMerge<LogEntry, LogEntry> implements ILogger {
6
- level: LogLevel;
7
- constructor();
8
- constructor(id: string);
9
- constructor(id: string, level: LogLevel);
10
- constructor(id: string, sources: Iterable<ISubscribable<LogEntry>>, level?: LogLevel);
11
- enabled(level: LogLevel): boolean;
1
+ import { ALogger } from "@thi.ng/logger/alogger";
2
+ import { LogLevel, type ILogger, type LogEntry } from "@thi.ng/logger/api";
3
+ import { Stream, type ISubscriber } from "@thi.ng/rstream";
4
+ export declare class Logger extends ALogger implements ISubscriber<LogEntry> {
5
+ stream: Stream<LogEntry>;
6
+ constructor(id: string, level?: LogLevel, parent?: ILogger);
12
7
  next(x: LogEntry): void;
13
- fine(...args: any[]): void;
14
- debug(...args: any[]): void;
15
- info(...args: any[]): void;
16
- warn(...args: any[]): void;
17
- severe(...args: any[]): void;
18
- protected log(level: LogLevel, args: any[]): void;
8
+ done(): void;
9
+ error(e: Error): boolean;
10
+ logEntry(e: LogEntry): void;
11
+ childLogger(id: string, level?: LogLevel): ILogger;
19
12
  }
20
13
  //# sourceMappingURL=logger.d.ts.map
package/logger.js CHANGED
@@ -1,57 +1,30 @@
1
- import { illegalArity } from "@thi.ng/errors/illegal-arity";
1
+ import { ALogger } from "@thi.ng/logger/alogger";
2
2
  import { LogLevel } from "@thi.ng/logger/api";
3
- import { CloseMode } from "@thi.ng/rstream/api";
4
- import { __nextID } from "@thi.ng/rstream/idgen";
5
- import { StreamMerge } from "@thi.ng/rstream/merge";
6
- class Logger extends StreamMerge {
7
- level;
8
- constructor(...args) {
9
- let id;
10
- let level = LogLevel.FINE;
11
- let src;
12
- switch (args.length) {
13
- case 0:
14
- break;
15
- case 1:
16
- id = args[0];
17
- break;
18
- case 2:
19
- [id, level] = args;
20
- break;
21
- case 3:
22
- [id, src, level] = args;
23
- src = [...src];
24
- break;
25
- default:
26
- illegalArity(args.length);
27
- }
28
- id = id || `logger-${__nextID()}`;
29
- super({ src, id, closeIn: CloseMode.NEVER, closeOut: CloseMode.NEVER });
30
- this.level = level;
31
- }
32
- enabled(level) {
33
- return this.level <= level;
3
+ import { Stream, CloseMode } from "@thi.ng/rstream";
4
+ class Logger extends ALogger {
5
+ stream;
6
+ constructor(id, level, parent) {
7
+ super(id, level, parent);
8
+ this.stream = new Stream({
9
+ id: this.id,
10
+ closeOut: CloseMode.NEVER
11
+ });
34
12
  }
35
13
  next(x) {
36
- x[0] >= this.level && super.next(x);
37
- }
38
- fine(...args) {
39
- this.log(LogLevel.FINE, args);
40
- }
41
- debug(...args) {
42
- this.log(LogLevel.DEBUG, args);
14
+ x[0] >= this.level && this.stream.next(x);
43
15
  }
44
- info(...args) {
45
- this.log(LogLevel.INFO, args);
16
+ done() {
17
+ this.stream.done();
46
18
  }
47
- warn(...args) {
48
- this.log(LogLevel.WARN, args);
19
+ error(e) {
20
+ return this.stream.error(e);
49
21
  }
50
- severe(...args) {
51
- this.log(LogLevel.SEVERE, args);
22
+ logEntry(e) {
23
+ if (this.level <= e[0])
24
+ this.stream.next(e);
52
25
  }
53
- log(level, args) {
54
- this.level <= level && super.next([level, this.id, Date.now(), ...args]);
26
+ childLogger(id, level) {
27
+ return new Logger(id, level ?? this.level, this.parent);
55
28
  }
56
29
  }
57
30
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/rstream-log",
3
- "version": "4.1.100",
3
+ "version": "5.0.0",
4
4
  "description": "Structured, multilevel & hierarchical loggers based on @thi.ng/rstream",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -37,11 +37,10 @@
37
37
  "dependencies": {
38
38
  "@thi.ng/api": "^8.9.23",
39
39
  "@thi.ng/checks": "^3.4.23",
40
- "@thi.ng/errors": "^2.4.16",
41
- "@thi.ng/logger": "^2.1.10",
42
- "@thi.ng/rstream": "^8.3.1",
40
+ "@thi.ng/logger": "^3.0.0",
41
+ "@thi.ng/rstream": "^8.3.3",
43
42
  "@thi.ng/strings": "^3.7.14",
44
- "@thi.ng/transducers": "^8.9.1"
43
+ "@thi.ng/transducers": "^8.9.2"
45
44
  },
46
45
  "devDependencies": {
47
46
  "@microsoft/api-extractor": "^7.40.1",
@@ -98,5 +97,5 @@
98
97
  ],
99
98
  "year": 2017
100
99
  },
101
- "gitHead": "e5e7d5c6ed2eadee7a91d59cbd0c86ce880ab1c5\n"
100
+ "gitHead": "25ee18f7db6d03f0b76787267ab071d16df94888\n"
102
101
  }