@thi.ng/rstream-log 5.0.0 → 5.0.1
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 +7 -1
- package/README.md +21 -25
- package/logger.d.ts +3 -3
- package/logger.js +9 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-02-16T20:
|
|
3
|
+
- **Last updated**: 2024-02-16T20:48:02Z
|
|
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,12 @@ 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.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream-log@5.0.1) (2024-02-16)
|
|
13
|
+
|
|
14
|
+
#### 🩹 Bug fixes
|
|
15
|
+
|
|
16
|
+
- fix Logger.logEntry() & .childLogger() impls ([3484617](https://github.com/thi-ng/umbrella/commit/3484617))
|
|
17
|
+
|
|
12
18
|
# [5.0.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/rstream-log@5.0.0) (2024-02-16)
|
|
13
19
|
|
|
14
20
|
#### 🛑 Breaking changes
|
package/README.md
CHANGED
|
@@ -44,10 +44,10 @@ infrastructure, with logged values transformable via
|
|
|
44
44
|
[@thi.ng/transducers](https://github.com/thi-ng/umbrella/tree/develop/packages/transducers).
|
|
45
45
|
Several built-in transformers are provided.
|
|
46
46
|
|
|
47
|
-
The `Logger` class
|
|
48
|
-
[@thi.ng/
|
|
47
|
+
The `Logger` class in this package implements the
|
|
48
|
+
[@thi.ng/logger](https://github.com/thi-ng/umbrella/tree/develop/packages/logger)
|
|
49
49
|
`ILogger` interface and uses `LogLevel` enums to configure levels /
|
|
50
|
-
filtering.
|
|
50
|
+
filtering. See that package for more details.
|
|
51
51
|
|
|
52
52
|
## Status
|
|
53
53
|
|
|
@@ -83,7 +83,7 @@ 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:
|
|
86
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 715 bytes
|
|
87
87
|
|
|
88
88
|
## Dependencies
|
|
89
89
|
|
|
@@ -98,42 +98,38 @@ Package sizes (brotli'd, pre-treeshake): ESM: 707 bytes
|
|
|
98
98
|
|
|
99
99
|
[Generated API docs](https://docs.thi.ng/umbrella/rstream-log/)
|
|
100
100
|
|
|
101
|
-
```ts
|
|
102
|
-
import { LogLevel } from "@thi.ng/
|
|
103
|
-
import
|
|
101
|
+
```ts tangle:export/readme.ts
|
|
102
|
+
import { LogLevel } from "@thi.ng/logger";
|
|
103
|
+
import { Logger, formatString, writeConsole } from "@thi.ng/rstream-log";
|
|
104
104
|
|
|
105
|
-
const logger = new
|
|
105
|
+
const logger = new Logger("main");
|
|
106
106
|
// or with min level
|
|
107
|
-
const logger = new
|
|
107
|
+
const logger = new Logger("main", LogLevel.DEBUG);
|
|
108
|
+
// or min level given as string
|
|
109
|
+
const logger = new Logger("main", "DEBUG");
|
|
108
110
|
|
|
109
111
|
// add console output w/ string formatter (a transducer)
|
|
110
|
-
logger
|
|
112
|
+
// each logger instance has a rstream Stream instance
|
|
113
|
+
// allowing for downstream processing
|
|
114
|
+
logger.stream.transform(formatString()).subscribe(writeConsole());
|
|
111
115
|
|
|
112
116
|
logger.debug("hello world");
|
|
113
|
-
// [DEBUG]
|
|
117
|
+
// [DEBUG] main: 2024-02-16T20:38:11.143Z hello world
|
|
114
118
|
|
|
115
119
|
logger.warn("eek");
|
|
116
|
-
// [WARN]
|
|
120
|
+
// [WARN] main: 2024-02-16T20:38:11.144Z eek
|
|
117
121
|
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const mod1 = new log.Logger("module-1", LogLevel.INFO);
|
|
122
|
-
// pipe mod1 into main logger
|
|
123
|
-
logger.add(mod1);
|
|
122
|
+
// loggers can form hierarchies by creating/attaching child loggers
|
|
123
|
+
const child = logger.childLogger("child", LogLevel.INFO);
|
|
124
124
|
|
|
125
125
|
import { postWorker } from "@thi.ng/rstream";
|
|
126
126
|
// additionally send messages from this logger to worker
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
mod1.info("hi from sub-module");
|
|
127
|
+
child.stream.subscribe(postWorker("log-worker.js"));
|
|
130
128
|
|
|
131
|
-
|
|
132
|
-
// [INFO]
|
|
129
|
+
child.info("hi from submodule");
|
|
130
|
+
// [INFO] child: 2024-02-16T20:38:11.145Z hi from submodule
|
|
133
131
|
```
|
|
134
132
|
|
|
135
|
-
TODO
|
|
136
|
-
|
|
137
133
|
## Authors
|
|
138
134
|
|
|
139
135
|
- [Karsten Schmidt](https://thi.ng)
|
package/logger.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ALogger } from "@thi.ng/logger/alogger";
|
|
2
|
-
import { LogLevel, type ILogger, type LogEntry } from "@thi.ng/logger/api";
|
|
2
|
+
import { LogLevel, type ILogger, type LogEntry, type LogLevelName } from "@thi.ng/logger/api";
|
|
3
3
|
import { Stream, type ISubscriber } from "@thi.ng/rstream";
|
|
4
4
|
export declare class Logger extends ALogger implements ISubscriber<LogEntry> {
|
|
5
5
|
stream: Stream<LogEntry>;
|
|
6
|
-
constructor(id: string, level?: LogLevel, parent?: ILogger);
|
|
6
|
+
constructor(id: string, level?: LogLevel | LogLevelName, parent?: ILogger);
|
|
7
7
|
next(x: LogEntry): void;
|
|
8
8
|
done(): void;
|
|
9
9
|
error(e: Error): boolean;
|
|
10
10
|
logEntry(e: LogEntry): void;
|
|
11
|
-
childLogger(id: string, level?: LogLevel):
|
|
11
|
+
childLogger(id: string, level?: LogLevel): Logger;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=logger.d.ts.map
|
package/logger.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ALogger } from "@thi.ng/logger/alogger";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
LogLevel
|
|
4
|
+
} from "@thi.ng/logger/api";
|
|
5
|
+
import { CloseMode, Stream } from "@thi.ng/rstream";
|
|
4
6
|
class Logger extends ALogger {
|
|
5
7
|
stream;
|
|
6
8
|
constructor(id, level, parent) {
|
|
@@ -11,7 +13,7 @@ class Logger extends ALogger {
|
|
|
11
13
|
});
|
|
12
14
|
}
|
|
13
15
|
next(x) {
|
|
14
|
-
|
|
16
|
+
this.logEntry(x);
|
|
15
17
|
}
|
|
16
18
|
done() {
|
|
17
19
|
this.stream.done();
|
|
@@ -20,11 +22,13 @@ class Logger extends ALogger {
|
|
|
20
22
|
return this.stream.error(e);
|
|
21
23
|
}
|
|
22
24
|
logEntry(e) {
|
|
23
|
-
if (
|
|
25
|
+
if (e[0] >= this.level) {
|
|
24
26
|
this.stream.next(e);
|
|
27
|
+
this.parent && this.parent.logEntry(e);
|
|
28
|
+
}
|
|
25
29
|
}
|
|
26
30
|
childLogger(id, level) {
|
|
27
|
-
return new Logger(id, level ?? this.level, this
|
|
31
|
+
return new Logger(id, level ?? this.level, this);
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/rstream-log",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Structured, multilevel & hierarchical loggers based on @thi.ng/rstream",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
],
|
|
98
98
|
"year": 2017
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "31173a8ccccdc296c104602d8d9db8b6553fd305\n"
|
|
101
101
|
}
|