@loglayer/mixin-wide-events 1.1.1 → 1.2.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/dist/index.cjs +9 -40
- package/dist/index.d.cts +1 -2059
- package/dist/index.d.mts +1 -2059
- package/dist/index.mjs +8 -39
- package/package.json +7 -5
package/dist/index.mjs
CHANGED
|
@@ -1,39 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* List of plugin callbacks that can be called by the plugin manager.
|
|
4
|
-
*
|
|
5
|
-
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#transformloglevel | transformLogLevel Docs}
|
|
6
|
-
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforedataout | onBeforeDataOut Docs}
|
|
7
|
-
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#shouldsendtologger | shouldSendToLogger Docs}
|
|
8
|
-
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#onmetadatacalled | onMetadataCalled Docs}
|
|
9
|
-
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforemessageout | onBeforeMessageOut Docs}
|
|
10
|
-
* @see {@link https://loglayer.dev/plugins/creating-plugins.html#oncontextcalled | onContextCalled Docs}
|
|
11
|
-
*/
|
|
12
|
-
let PluginCallbackType = /* @__PURE__ */ function(PluginCallbackType) {
|
|
13
|
-
PluginCallbackType["transformLogLevel"] = "transformLogLevel";
|
|
14
|
-
PluginCallbackType["onBeforeDataOut"] = "onBeforeDataOut";
|
|
15
|
-
PluginCallbackType["shouldSendToLogger"] = "shouldSendToLogger";
|
|
16
|
-
PluginCallbackType["onMetadataCalled"] = "onMetadataCalled";
|
|
17
|
-
PluginCallbackType["onBeforeMessageOut"] = "onBeforeMessageOut";
|
|
18
|
-
PluginCallbackType["onContextCalled"] = "onContextCalled";
|
|
19
|
-
return PluginCallbackType;
|
|
20
|
-
}({});
|
|
21
|
-
PluginCallbackType.onBeforeDataOut, PluginCallbackType.onMetadataCalled, PluginCallbackType.onBeforeMessageOut, PluginCallbackType.transformLogLevel, PluginCallbackType.shouldSendToLogger, PluginCallbackType.onContextCalled;
|
|
22
|
-
/**
|
|
23
|
-
* The class that the mixin extends
|
|
24
|
-
*/
|
|
25
|
-
let LogLayerMixinAugmentType = /* @__PURE__ */ function(LogLayerMixinAugmentType) {
|
|
26
|
-
/**
|
|
27
|
-
* Mixin extends the LogBuilder prototype
|
|
28
|
-
*/
|
|
29
|
-
LogLayerMixinAugmentType["LogBuilder"] = "LogBuilder";
|
|
30
|
-
/**
|
|
31
|
-
* Mixin extends the LogLayer prototype
|
|
32
|
-
*/
|
|
33
|
-
LogLayerMixinAugmentType["LogLayer"] = "LogLayer";
|
|
34
|
-
return LogLayerMixinAugmentType;
|
|
35
|
-
}({});
|
|
36
|
-
//#endregion
|
|
1
|
+
import { LogLayerMixinAugmentType } from "loglayer";
|
|
37
2
|
//#region src/mixin.ts
|
|
38
3
|
/**
|
|
39
4
|
* Log levels that default to rate=1 (error/fatal) — can be overridden via `perLevel` or callback.
|
|
@@ -150,13 +115,13 @@ function createWideEventMixin(options) {
|
|
|
150
115
|
const contextTrackerPlugin = {
|
|
151
116
|
id: `@loglayer/wide-events-context-tracker-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
152
117
|
onBeforeDataOut: (params) => {
|
|
153
|
-
if (!includeContext) return params;
|
|
118
|
+
if (!includeContext) return params.data;
|
|
154
119
|
const store = asyncContext.getStore();
|
|
155
120
|
if (store && params.context && Object.keys(params.context).length > 0) {
|
|
156
121
|
if (!store._llContext) store._llContext = {};
|
|
157
122
|
Object.assign(store._llContext, params.context);
|
|
158
123
|
}
|
|
159
|
-
return params;
|
|
124
|
+
return params.data;
|
|
160
125
|
}
|
|
161
126
|
};
|
|
162
127
|
/**
|
|
@@ -241,7 +206,11 @@ function createWideEventMixin(options) {
|
|
|
241
206
|
if (!runRateSampling(level, samplingConfig.strategy, samplingConfig.rate, samplingConfig.perLevel) || !callbackOk) return;
|
|
242
207
|
} catch {}
|
|
243
208
|
const metadataToEmit = wideEventField ? { [wideEventField]: wideEventData } : wideEventData;
|
|
244
|
-
self.
|
|
209
|
+
self.raw({
|
|
210
|
+
logLevel: level,
|
|
211
|
+
messages: [config.message],
|
|
212
|
+
rootData: metadataToEmit
|
|
213
|
+
});
|
|
245
214
|
}
|
|
246
215
|
return {
|
|
247
216
|
mixinsToAdd: [{
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loglayer/mixin-wide-events",
|
|
3
3
|
"description": "Adds wide event logging functionality to LogLayer for comprehensive, self-contained log entries.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -34,14 +34,16 @@
|
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "25.9.1",
|
|
37
|
-
"tsdown": "0.22.
|
|
37
|
+
"tsdown": "0.22.1",
|
|
38
38
|
"typescript": "6.0.3",
|
|
39
39
|
"vitest": "4.1.7",
|
|
40
40
|
"@internal/tsconfig": "2.1.0",
|
|
41
|
-
"@loglayer/shared": "4.
|
|
42
|
-
"loglayer": "9.
|
|
41
|
+
"@loglayer/shared": "4.3.0",
|
|
42
|
+
"loglayer": "9.3.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"loglayer": ">=9.0.0"
|
|
43
46
|
},
|
|
44
|
-
"peerDependencies": {},
|
|
45
47
|
"bugs": "https://github.com/loglayer/loglayer/issues",
|
|
46
48
|
"files": [
|
|
47
49
|
"dist"
|