@blac/logging-plugin 2.0.0 → 2.0.3

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/README.md CHANGED
@@ -30,14 +30,13 @@ new LoggingPlugin({
30
30
  format: 'grouped',
31
31
 
32
32
  // Filtering
33
- include: ['CounterCubit', 'CartVertex'], // Only log these classes
33
+ include: ['CounterCubit', 'CartCubit'], // Only log these classes
34
34
  exclude: ['AnalyticsCubit'], // Exclude these classes
35
35
  filter: ({ className, isIsolated }) => !isIsolated, // Custom filter
36
36
 
37
37
  // Feature toggles
38
38
  logLifecycle: true, // Log create/dispose
39
39
  logStateChanges: true, // Log state transitions
40
- logEvents: true, // Log Vertex events
41
40
  includeCallstack: false, // Include callstack in logs
42
41
 
43
42
  // Memory monitoring
@@ -62,7 +61,7 @@ new LoggingPlugin({
62
61
  | --------- | -------------------------------------------------- |
63
62
  | `minimal` | Warnings only (memory issues, suspicious activity) |
64
63
  | `info` | Lifecycle + warnings |
65
- | `debug` | + state changes + events |
64
+ | `debug` | + state changes |
66
65
  | `verbose` | + callstacks + full state objects |
67
66
 
68
67
  ## Output Examples
@@ -1,4 +1,4 @@
1
- import type { BlacPlugin, PluginContext, StateContainer, Vertex, DiscriminatedEvent } from '@blac/core';
1
+ import type { BlacPlugin, PluginContext, StateContainer } from '@blac/core';
2
2
  import type { LoggingPluginConfig } from './types';
3
3
  export declare class LoggingPlugin implements BlacPlugin {
4
4
  readonly name = "LoggingPlugin";
@@ -17,16 +17,11 @@ export declare class LoggingPlugin implements BlacPlugin {
17
17
  onUninstall(): void;
18
18
  onInstanceCreated(instance: StateContainer<any>, context: PluginContext): void;
19
19
  onStateChanged<S extends object>(instance: StateContainer<S>, previousState: S, currentState: S, callstack: string | undefined, context: PluginContext): void;
20
- onEventAdded<E extends DiscriminatedEvent>(vertex: Vertex<any, E>, event: E & {
21
- timestamp?: number;
22
- source?: string;
23
- }, context: PluginContext): void;
24
20
  onInstanceDisposed(instance: StateContainer<any>, context: PluginContext): void;
25
21
  logStats(): void;
26
22
  private shouldLog;
27
23
  private shouldLogLifecycle;
28
24
  private shouldLogStateChanges;
29
- private shouldLogEvents;
30
25
  private logWarning;
31
26
  }
32
27
  //# sourceMappingURL=LoggingPlugin.d.ts.map
@@ -15,7 +15,6 @@ export declare class GroupedFormatter {
15
15
  logInstanceCreated(metadata: InstanceMetadata, initialState: unknown): void;
16
16
  logInstanceDisposed(metadata: InstanceMetadata, lifespanMs: number, stateChangeCount: number): void;
17
17
  logStateChanged(metadata: InstanceMetadata, previousState: unknown, currentState: unknown, callstack: string | undefined, includeCallstack: boolean): void;
18
- logEventAdded(className: string, instanceId: string, eventType: string, event: unknown): void;
19
18
  logWarning(message: string, details?: Record<string, unknown>): void;
20
19
  logStats(stats: {
21
20
  registeredTypes: number;
@@ -13,7 +13,6 @@ export declare class SimpleFormatter {
13
13
  logInstanceCreated(metadata: InstanceMetadata): void;
14
14
  logInstanceDisposed(metadata: InstanceMetadata, lifespanMs: number): void;
15
15
  logStateChanged(metadata: InstanceMetadata, previousState: unknown, currentState: unknown, _callstack: string | undefined, includeCallstack: boolean): void;
16
- logEventAdded(className: string, instanceId: string, eventType: string, payload: unknown): void;
17
16
  logWarning(message: string): void;
18
17
  logStats(stats: {
19
18
  registeredTypes: number;
package/dist/index.cjs CHANGED
@@ -31,11 +31,6 @@ var SimpleFormatter = class {
31
31
  this.logger.log(`${this.prefix} ${instanceId} state: ${prev} → ${curr}`);
32
32
  if (includeCallstack && _callstack) this.logger.log(`${this.prefix} Callstack: ${_callstack}`);
33
33
  }
34
- logEventAdded(className, instanceId, eventType, payload) {
35
- const id = this.formatInstanceId(className, instanceId);
36
- const payloadStr = this.formatState(payload);
37
- this.logger.log(`${this.prefix} ${id} event: ${eventType} ${payloadStr}`);
38
- }
39
34
  logWarning(message) {
40
35
  this.logger.warn(`${this.prefix} ⚠️ ${message}`);
41
36
  }
@@ -113,12 +108,6 @@ var GroupedFormatter = class {
113
108
  if (includeCallstack && callstack) this.logger.log("Callstack:", callstack);
114
109
  this.groupEnd();
115
110
  }
116
- logEventAdded(className, instanceId, eventType, event) {
117
- const id = this.formatInstanceId(className, instanceId);
118
- this.group(`${this.prefix} ${id} event: ${eventType}`);
119
- this.logger.log("Event:", event);
120
- this.groupEnd();
121
- }
122
111
  logWarning(message, details) {
123
112
  if (details) {
124
113
  this.group(`${this.prefix} ⚠️ ${message}`, false);
@@ -255,7 +244,6 @@ function resolveConfig(config = {}) {
255
244
  exclude: config.exclude,
256
245
  logLifecycle: config.logLifecycle ?? true,
257
246
  logStateChanges: config.logStateChanges ?? true,
258
- logEvents: config.logEvents ?? true,
259
247
  includeCallstack: config.includeCallstack ?? false,
260
248
  instanceCountWarningThreshold: config.instanceCountWarningThreshold ?? 50,
261
249
  detectRapidLifecycles: config.detectRapidLifecycles ?? true,
@@ -329,14 +317,6 @@ var LoggingPlugin = class {
329
317
  if (this.config.format === "simple") this.simpleFormatter.logStateChanged(metadata, previousState, currentState, callstack, this.config.includeCallstack);
330
318
  else this.groupedFormatter.logStateChanged(metadata, previousState, currentState, callstack, this.config.includeCallstack);
331
319
  }
332
- onEventAdded(vertex, event, context) {
333
- const metadata = context.getInstanceMetadata(vertex);
334
- if (!this.shouldLog(vertex, metadata.className, metadata.id, metadata.isIsolated)) return;
335
- if (!this.shouldLogEvents()) return;
336
- const eventType = event.type ?? "UnknownEvent";
337
- if (this.config.format === "simple") this.simpleFormatter.logEventAdded(metadata.className, metadata.id, eventType, event);
338
- else this.groupedFormatter.logEventAdded(metadata.className, metadata.id, eventType, event);
339
- }
340
320
  onInstanceDisposed(instance, context) {
341
321
  const metadata = context.getInstanceMetadata(instance);
342
322
  if (!this.shouldLog(instance, metadata.className, metadata.id, metadata.isIsolated)) return;
@@ -377,10 +357,6 @@ var LoggingPlugin = class {
377
357
  if (!this.config.logStateChanges) return false;
378
358
  return this.config.level === "info" || this.config.level === "debug" || this.config.level === "verbose";
379
359
  }
380
- shouldLogEvents() {
381
- if (!this.config.logEvents) return false;
382
- return this.config.level === "debug" || this.config.level === "verbose";
383
- }
384
360
  logWarning(message, details) {
385
361
  if (this.config.format === "simple") this.simpleFormatter.logWarning(message);
386
362
  else this.groupedFormatter.logWarning(message, details);
package/dist/index.js CHANGED
@@ -30,11 +30,6 @@ var SimpleFormatter = class {
30
30
  this.logger.log(`${this.prefix} ${instanceId} state: ${prev} → ${curr}`);
31
31
  if (includeCallstack && _callstack) this.logger.log(`${this.prefix} Callstack: ${_callstack}`);
32
32
  }
33
- logEventAdded(className, instanceId, eventType, payload) {
34
- const id = this.formatInstanceId(className, instanceId);
35
- const payloadStr = this.formatState(payload);
36
- this.logger.log(`${this.prefix} ${id} event: ${eventType} ${payloadStr}`);
37
- }
38
33
  logWarning(message) {
39
34
  this.logger.warn(`${this.prefix} ⚠️ ${message}`);
40
35
  }
@@ -112,12 +107,6 @@ var GroupedFormatter = class {
112
107
  if (includeCallstack && callstack) this.logger.log("Callstack:", callstack);
113
108
  this.groupEnd();
114
109
  }
115
- logEventAdded(className, instanceId, eventType, event) {
116
- const id = this.formatInstanceId(className, instanceId);
117
- this.group(`${this.prefix} ${id} event: ${eventType}`);
118
- this.logger.log("Event:", event);
119
- this.groupEnd();
120
- }
121
110
  logWarning(message, details) {
122
111
  if (details) {
123
112
  this.group(`${this.prefix} ⚠️ ${message}`, false);
@@ -254,7 +243,6 @@ function resolveConfig(config = {}) {
254
243
  exclude: config.exclude,
255
244
  logLifecycle: config.logLifecycle ?? true,
256
245
  logStateChanges: config.logStateChanges ?? true,
257
- logEvents: config.logEvents ?? true,
258
246
  includeCallstack: config.includeCallstack ?? false,
259
247
  instanceCountWarningThreshold: config.instanceCountWarningThreshold ?? 50,
260
248
  detectRapidLifecycles: config.detectRapidLifecycles ?? true,
@@ -328,14 +316,6 @@ var LoggingPlugin = class {
328
316
  if (this.config.format === "simple") this.simpleFormatter.logStateChanged(metadata, previousState, currentState, callstack, this.config.includeCallstack);
329
317
  else this.groupedFormatter.logStateChanged(metadata, previousState, currentState, callstack, this.config.includeCallstack);
330
318
  }
331
- onEventAdded(vertex, event, context) {
332
- const metadata = context.getInstanceMetadata(vertex);
333
- if (!this.shouldLog(vertex, metadata.className, metadata.id, metadata.isIsolated)) return;
334
- if (!this.shouldLogEvents()) return;
335
- const eventType = event.type ?? "UnknownEvent";
336
- if (this.config.format === "simple") this.simpleFormatter.logEventAdded(metadata.className, metadata.id, eventType, event);
337
- else this.groupedFormatter.logEventAdded(metadata.className, metadata.id, eventType, event);
338
- }
339
319
  onInstanceDisposed(instance, context) {
340
320
  const metadata = context.getInstanceMetadata(instance);
341
321
  if (!this.shouldLog(instance, metadata.className, metadata.id, metadata.isIsolated)) return;
@@ -376,10 +356,6 @@ var LoggingPlugin = class {
376
356
  if (!this.config.logStateChanges) return false;
377
357
  return this.config.level === "info" || this.config.level === "debug" || this.config.level === "verbose";
378
358
  }
379
- shouldLogEvents() {
380
- if (!this.config.logEvents) return false;
381
- return this.config.level === "debug" || this.config.level === "verbose";
382
- }
383
359
  logWarning(message, details) {
384
360
  if (this.config.format === "simple") this.simpleFormatter.logWarning(message);
385
361
  else this.groupedFormatter.logWarning(message, details);
package/dist/types.d.ts CHANGED
@@ -33,8 +33,6 @@ export interface LoggingPluginConfig {
33
33
  logLifecycle?: boolean;
34
34
  /** Log state changes (default: true) */
35
35
  logStateChanges?: boolean;
36
- /** Log Vertex events (default: true) */
37
- logEvents?: boolean;
38
36
  /** Include callstack in state change logs (default: false) */
39
37
  includeCallstack?: boolean;
40
38
  /** Warn when instance count exceeds threshold (default: 50) */
@@ -57,7 +55,6 @@ export interface ResolvedConfig {
57
55
  exclude: string[] | undefined;
58
56
  logLifecycle: boolean;
59
57
  logStateChanges: boolean;
60
- logEvents: boolean;
61
58
  includeCallstack: boolean;
62
59
  instanceCountWarningThreshold: number;
63
60
  detectRapidLifecycles: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blac/logging-plugin",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Brendan Mullins <jsnanigans@gmail.com>",
@@ -45,15 +45,14 @@
45
45
  "state-management",
46
46
  "devtools"
47
47
  ],
48
- "peerDependencies": {
49
- "@blac/core": "2.0.0"
48
+ "dependencies": {
49
+ "@blac/core": "2.0.3"
50
50
  },
51
51
  "devDependencies": {
52
52
  "prettier": "^3.6.2",
53
53
  "typescript": "^5.9.2",
54
54
  "vitest": "3.2.4",
55
- "tsdown": "^0.15.7",
56
- "@blac/core": "2.0.0"
55
+ "tsdown": "^0.15.7"
57
56
  },
58
57
  "scripts": {
59
58
  "dev": "tsdown --watch",