@dxos/log 0.8.4-staging.ac66bdf99f → 0.9.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/LICENSE +102 -5
- package/dist/lib/browser/{chunk-DTUPLFUN.mjs → chunk-V7FYKT4H.mjs} +1 -1
- package/dist/lib/browser/index.mjs +118 -72
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/platform/node/index.mjs.map +2 -2
- package/dist/lib/browser/processors/console-processor.mjs +1 -1
- package/dist/lib/browser/processors/file-processor.mjs +75 -0
- package/dist/lib/browser/processors/file-processor.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-KOTHKRYW.mjs → chunk-5TBDXMQF.mjs} +1 -1
- package/dist/lib/node-esm/index.mjs +118 -72
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/platform/node/index.mjs.map +2 -2
- package/dist/lib/node-esm/processors/console-processor.mjs +1 -1
- package/dist/lib/node-esm/processors/file-processor.mjs +76 -0
- package/dist/lib/node-esm/processors/file-processor.mjs.map +7 -0
- package/dist/types/src/context.d.ts.map +1 -1
- package/dist/types/src/decorators.d.ts.map +1 -1
- package/dist/types/src/environment.d.ts +24 -0
- package/dist/types/src/environment.d.ts.map +1 -0
- package/dist/types/src/environment.test.d.ts +2 -0
- package/dist/types/src/environment.test.d.ts.map +1 -0
- package/dist/types/src/experimental/ownership.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +4 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/jsonl.d.ts +53 -0
- package/dist/types/src/jsonl.d.ts.map +1 -0
- package/dist/types/src/jsonl.test.d.ts +2 -0
- package/dist/types/src/jsonl.test.d.ts.map +1 -0
- package/dist/types/src/log-buffer.d.ts +0 -20
- package/dist/types/src/log-buffer.d.ts.map +1 -1
- package/dist/types/src/log.d.ts +41 -0
- package/dist/types/src/log.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +20 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/platform/browser/index.d.ts.map +1 -1
- package/dist/types/src/platform/node/index.d.ts.map +1 -1
- package/dist/types/src/processors/common.d.ts.map +1 -1
- package/dist/types/src/processors/console-processor.d.ts.map +1 -1
- package/dist/types/src/processors/file-processor.d.ts.map +1 -1
- package/dist/types/src/processors/index.d.ts +0 -1
- package/dist/types/src/processors/index.d.ts.map +1 -1
- package/dist/types/src/scope.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +16 -8
- package/src/environment.test.ts +222 -0
- package/src/environment.ts +129 -0
- package/src/index.ts +4 -1
- package/src/jsonl.test.ts +121 -0
- package/src/jsonl.ts +104 -0
- package/src/log-buffer.ts +1 -22
- package/src/log.ts +49 -0
- package/src/meta.ts +29 -1
- package/src/processors/index.ts +0 -1
- /package/dist/lib/browser/{chunk-DTUPLFUN.mjs.map → chunk-V7FYKT4H.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-KOTHKRYW.mjs.map → chunk-5TBDXMQF.mjs.map} +0 -0
package/src/log.ts
CHANGED
|
@@ -29,15 +29,57 @@ export interface LogMethods {
|
|
|
29
29
|
config: (options?: LogOptions) => Log;
|
|
30
30
|
addProcessor: (processor: LogProcessor, addDefault?: boolean) => () => void;
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Log at `trace` level.
|
|
34
|
+
*
|
|
35
|
+
* Generally not surfaced to the developer and not captured in a log file.
|
|
36
|
+
*/
|
|
32
37
|
trace: LogFunction;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Log at `debug` level.
|
|
41
|
+
* Generally not surfaced to the developer and captured in a log file.
|
|
42
|
+
*/
|
|
33
43
|
debug: LogFunction;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Log at `verbose` level.
|
|
47
|
+
* Generally not surfaced to the developer and not captured in a log file.
|
|
48
|
+
*/
|
|
34
49
|
verbose: LogFunction;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Log at `info` level.
|
|
53
|
+
* Generally surfaced to the developer and captured in a log file.
|
|
54
|
+
*/
|
|
35
55
|
info: LogFunction;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Log at `warn` level.
|
|
59
|
+
* Generally surfaced to the developer and captured in a log file.
|
|
60
|
+
*/
|
|
36
61
|
warn: LogFunction;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Log at `error` level.
|
|
65
|
+
* Generally surfaced to the developer and captured in a log file.
|
|
66
|
+
*/
|
|
37
67
|
error: LogFunction;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Log an error and its stack trace at an `error` level.
|
|
71
|
+
* Generally surfaced to the developer and captured in a log file.
|
|
72
|
+
*/
|
|
38
73
|
catch: (error: Error | any, context?: LogContext, meta?: CallMetadata) => void;
|
|
39
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Decorator to log method parameters and return value at the `info` level.
|
|
77
|
+
*/
|
|
40
78
|
method: (arg0?: never, arg1?: never, meta?: CallMetadata) => MethodDecorator;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Wrapper to log function parameters and return value at the `info` level.
|
|
82
|
+
*/
|
|
41
83
|
function: <F extends (...args: any[]) => any>(
|
|
42
84
|
name: string,
|
|
43
85
|
fn: F,
|
|
@@ -46,7 +88,14 @@ export interface LogMethods {
|
|
|
46
88
|
},
|
|
47
89
|
) => F;
|
|
48
90
|
|
|
91
|
+
/**
|
|
92
|
+
* Log a horizontal rule at the `info` level.
|
|
93
|
+
*/
|
|
49
94
|
break: () => void;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Log a stack trace at the `info` level.
|
|
98
|
+
*/
|
|
50
99
|
stack: (message?: string, context?: never, meta?: CallMetadata) => void;
|
|
51
100
|
}
|
|
52
101
|
|
package/src/meta.ts
CHANGED
|
@@ -3,11 +3,27 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Marker key + value injected on every {@link CallMetadata} object by the log transform plugin.
|
|
7
|
+
* Used by {@link isLogMeta} to detect a log-meta argument at runtime (e.g. for variadic
|
|
8
|
+
* `param_index: 'last'` callees that don't have a fixed meta slot).
|
|
9
|
+
*/
|
|
10
|
+
export const LOG_META_MARKER = '~LogMeta';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Metadata injected by the log transform plugin.
|
|
7
14
|
*
|
|
8
15
|
* Field names are intentionally short to reduce the size of the generated code.
|
|
9
16
|
*/
|
|
10
17
|
export interface CallMetadata {
|
|
18
|
+
/**
|
|
19
|
+
* Marker tag — when present, equal to {@link LOG_META_MARKER} ({@link `'~LogMeta'`}).
|
|
20
|
+
* Injected by the log transform plugin on every emitted meta object so that {@link isLogMeta}
|
|
21
|
+
* can distinguish a meta argument from a regular user-supplied value at runtime.
|
|
22
|
+
* Optional because hand-written `CallMetadata` literals (decorators, RPC mappers, tests)
|
|
23
|
+
* don't need the marker — they are recognized by position in the call signature.
|
|
24
|
+
*/
|
|
25
|
+
'~LogMeta'?: typeof LOG_META_MARKER;
|
|
26
|
+
|
|
11
27
|
/**
|
|
12
28
|
* File name.
|
|
13
29
|
*/
|
|
@@ -35,3 +51,15 @@ export interface CallMetadata {
|
|
|
35
51
|
*/
|
|
36
52
|
A?: string[];
|
|
37
53
|
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Type guard: `true` when `value` is a {@link CallMetadata} object emitted by the log transform plugin.
|
|
57
|
+
* Detection is based on the presence of the {@link LOG_META_MARKER} marker key/value.
|
|
58
|
+
*/
|
|
59
|
+
export const isLogMeta = (value: unknown): value is CallMetadata => {
|
|
60
|
+
return (
|
|
61
|
+
value != null &&
|
|
62
|
+
typeof value === 'object' &&
|
|
63
|
+
(value as Record<string, unknown>)[LOG_META_MARKER] === LOG_META_MARKER
|
|
64
|
+
);
|
|
65
|
+
};
|
package/src/processors/index.ts
CHANGED
|
File without changes
|
|
File without changes
|