@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 CHANGED
@@ -1,40 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region ../../core/plugin/dist/index.js
3
- /**
4
- * List of plugin callbacks that can be called by the plugin manager.
5
- *
6
- * @see {@link https://loglayer.dev/plugins/creating-plugins.html#transformloglevel | transformLogLevel Docs}
7
- * @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforedataout | onBeforeDataOut Docs}
8
- * @see {@link https://loglayer.dev/plugins/creating-plugins.html#shouldsendtologger | shouldSendToLogger Docs}
9
- * @see {@link https://loglayer.dev/plugins/creating-plugins.html#onmetadatacalled | onMetadataCalled Docs}
10
- * @see {@link https://loglayer.dev/plugins/creating-plugins.html#onbeforemessageout | onBeforeMessageOut Docs}
11
- * @see {@link https://loglayer.dev/plugins/creating-plugins.html#oncontextcalled | onContextCalled Docs}
12
- */
13
- let PluginCallbackType = /* @__PURE__ */ function(PluginCallbackType) {
14
- PluginCallbackType["transformLogLevel"] = "transformLogLevel";
15
- PluginCallbackType["onBeforeDataOut"] = "onBeforeDataOut";
16
- PluginCallbackType["shouldSendToLogger"] = "shouldSendToLogger";
17
- PluginCallbackType["onMetadataCalled"] = "onMetadataCalled";
18
- PluginCallbackType["onBeforeMessageOut"] = "onBeforeMessageOut";
19
- PluginCallbackType["onContextCalled"] = "onContextCalled";
20
- return PluginCallbackType;
21
- }({});
22
- PluginCallbackType.onBeforeDataOut, PluginCallbackType.onMetadataCalled, PluginCallbackType.onBeforeMessageOut, PluginCallbackType.transformLogLevel, PluginCallbackType.shouldSendToLogger, PluginCallbackType.onContextCalled;
23
- /**
24
- * The class that the mixin extends
25
- */
26
- let LogLayerMixinAugmentType = /* @__PURE__ */ function(LogLayerMixinAugmentType) {
27
- /**
28
- * Mixin extends the LogBuilder prototype
29
- */
30
- LogLayerMixinAugmentType["LogBuilder"] = "LogBuilder";
31
- /**
32
- * Mixin extends the LogLayer prototype
33
- */
34
- LogLayerMixinAugmentType["LogLayer"] = "LogLayer";
35
- return LogLayerMixinAugmentType;
36
- }({});
37
- //#endregion
2
+ let loglayer = require("loglayer");
38
3
  //#region src/mixin.ts
39
4
  /**
40
5
  * Log levels that default to rate=1 (error/fatal) — can be overridden via `perLevel` or callback.
@@ -151,13 +116,13 @@ function createWideEventMixin(options) {
151
116
  const contextTrackerPlugin = {
152
117
  id: `@loglayer/wide-events-context-tracker-${Date.now()}-${Math.random().toString(36).slice(2)}`,
153
118
  onBeforeDataOut: (params) => {
154
- if (!includeContext) return params;
119
+ if (!includeContext) return params.data;
155
120
  const store = asyncContext.getStore();
156
121
  if (store && params.context && Object.keys(params.context).length > 0) {
157
122
  if (!store._llContext) store._llContext = {};
158
123
  Object.assign(store._llContext, params.context);
159
124
  }
160
- return params;
125
+ return params.data;
161
126
  }
162
127
  };
163
128
  /**
@@ -242,11 +207,15 @@ function createWideEventMixin(options) {
242
207
  if (!runRateSampling(level, samplingConfig.strategy, samplingConfig.rate, samplingConfig.perLevel) || !callbackOk) return;
243
208
  } catch {}
244
209
  const metadataToEmit = wideEventField ? { [wideEventField]: wideEventData } : wideEventData;
245
- self.withMetadata(metadataToEmit)[level](config.message);
210
+ self.raw({
211
+ logLevel: level,
212
+ messages: [config.message],
213
+ rootData: metadataToEmit
214
+ });
246
215
  }
247
216
  return {
248
217
  mixinsToAdd: [{
249
- augmentationType: LogLayerMixinAugmentType.LogLayer,
218
+ augmentationType: loglayer.LogLayerMixinAugmentType.LogLayer,
250
219
  augment: (prototype) => {
251
220
  prototype.withWideEvents = function(data) {
252
221
  return withWideEventsImpl(data, this);