@blac/logging-plugin 2.0.20 → 2.0.21
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 +1 -1
- package/dist/LoggingPlugin.d.cts +27 -0
- package/dist/types.d.cts +68 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ pnpm add @blac/logging-plugin
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
21
|
```ts
|
|
22
|
-
import { getPluginManager } from '@blac/core';
|
|
22
|
+
import { getPluginManager } from '@blac/core/plugins';
|
|
23
23
|
import { LoggingPlugin } from '@blac/logging-plugin';
|
|
24
24
|
|
|
25
25
|
getPluginManager().install(new LoggingPlugin(), {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BlacPlugin, PathSet, PluginContext } from '@blac/core';
|
|
2
|
+
import type { LoggingPluginConfig } from './types';
|
|
3
|
+
export declare class LoggingPlugin implements BlacPlugin {
|
|
4
|
+
readonly name = "LoggingPlugin";
|
|
5
|
+
readonly version = "1.0.0";
|
|
6
|
+
private config;
|
|
7
|
+
private context?;
|
|
8
|
+
private simpleFormatter;
|
|
9
|
+
private groupedFormatter;
|
|
10
|
+
private instanceCountMonitor;
|
|
11
|
+
private lifecycleMonitor;
|
|
12
|
+
private stateChangeCount;
|
|
13
|
+
private stateChangeWindowStart;
|
|
14
|
+
private stateChangeLoggingDisabled;
|
|
15
|
+
constructor(config?: LoggingPluginConfig);
|
|
16
|
+
onInstall(ctx: PluginContext): void;
|
|
17
|
+
onUninstall(): void;
|
|
18
|
+
onCreated(ctx: PluginContext): void;
|
|
19
|
+
onStateChange<S extends object>(ctx: PluginContext, previousState: S, currentState: S, paths: PathSet): void;
|
|
20
|
+
onDestroyed(ctx: PluginContext): void;
|
|
21
|
+
logStats(): void;
|
|
22
|
+
private shouldLog;
|
|
23
|
+
private shouldLogLifecycle;
|
|
24
|
+
private shouldLogStateChanges;
|
|
25
|
+
private logWarning;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=LoggingPlugin.d.ts.map
|
package/dist/types.d.cts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { StateContainer } from '@blac/core';
|
|
2
|
+
export type LogLevel = 'minimal' | 'info' | 'debug' | 'verbose';
|
|
3
|
+
export type LogFormat = 'simple' | 'grouped';
|
|
4
|
+
export interface Logger {
|
|
5
|
+
log(...args: unknown[]): void;
|
|
6
|
+
warn(...args: unknown[]): void;
|
|
7
|
+
error(...args: unknown[]): void;
|
|
8
|
+
group?(label: string): void;
|
|
9
|
+
groupEnd?(): void;
|
|
10
|
+
groupCollapsed?(label: string): void;
|
|
11
|
+
}
|
|
12
|
+
export interface FilterContext {
|
|
13
|
+
instance: StateContainer<any>;
|
|
14
|
+
className: string;
|
|
15
|
+
instanceId: string;
|
|
16
|
+
}
|
|
17
|
+
export type FilterFn = (ctx: FilterContext) => boolean;
|
|
18
|
+
export interface LoggingPluginConfig {
|
|
19
|
+
/** Log verbosity level (default: 'info') */
|
|
20
|
+
level?: LogLevel;
|
|
21
|
+
/** Output format (default: 'grouped') */
|
|
22
|
+
format?: LogFormat;
|
|
23
|
+
/** Custom logger implementation (default: console) */
|
|
24
|
+
logger?: Logger;
|
|
25
|
+
/** Filter which instances to log */
|
|
26
|
+
filter?: FilterFn;
|
|
27
|
+
/** Include class names to log (whitelist) */
|
|
28
|
+
include?: string[];
|
|
29
|
+
/** Exclude class names from logging (blacklist) */
|
|
30
|
+
exclude?: string[];
|
|
31
|
+
/** Log instance creation/disposal (default: true) */
|
|
32
|
+
logLifecycle?: boolean;
|
|
33
|
+
/** Log state changes (default: true) */
|
|
34
|
+
logStateChanges?: boolean;
|
|
35
|
+
/** Include callstack in state change logs (default: false) */
|
|
36
|
+
includeCallstack?: boolean;
|
|
37
|
+
/** Log changed path names in state change output (default: false) */
|
|
38
|
+
logPaths?: boolean;
|
|
39
|
+
/** Warn when instance count exceeds threshold (default: 50) */
|
|
40
|
+
instanceCountWarningThreshold?: number;
|
|
41
|
+
/** Warn on rapid init/dispose cycles (default: true) */
|
|
42
|
+
detectRapidLifecycles?: boolean;
|
|
43
|
+
/** Time window for rapid lifecycle detection in ms (default: 1000) */
|
|
44
|
+
rapidLifecycleWindowMs?: number;
|
|
45
|
+
/** Number of cycles in window to trigger warning (default: 5) */
|
|
46
|
+
rapidLifecycleThreshold?: number;
|
|
47
|
+
/** Log prefix (default: '[BlaC]') */
|
|
48
|
+
prefix?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface ResolvedConfig {
|
|
51
|
+
level: LogLevel;
|
|
52
|
+
format: LogFormat;
|
|
53
|
+
logger: Logger;
|
|
54
|
+
filter: FilterFn | undefined;
|
|
55
|
+
include: string[] | undefined;
|
|
56
|
+
exclude: string[] | undefined;
|
|
57
|
+
logLifecycle: boolean;
|
|
58
|
+
logStateChanges: boolean;
|
|
59
|
+
includeCallstack: boolean;
|
|
60
|
+
logPaths: boolean;
|
|
61
|
+
instanceCountWarningThreshold: number;
|
|
62
|
+
detectRapidLifecycles: boolean;
|
|
63
|
+
rapidLifecycleWindowMs: number;
|
|
64
|
+
rapidLifecycleThreshold: number;
|
|
65
|
+
prefix: string;
|
|
66
|
+
}
|
|
67
|
+
export declare function resolveConfig(config?: LoggingPluginConfig): ResolvedConfig;
|
|
68
|
+
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blac/logging-plugin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.21",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Brendan Mullins <jsnanigans@gmail.com>",
|
|
6
6
|
"description": "Logging and debugging plugin for BlaC state management",
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
"devtools"
|
|
47
47
|
],
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@blac/core": "^2.
|
|
49
|
+
"@blac/core": "^2.1.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"publint": "^0.3.
|
|
52
|
+
"publint": "^0.3.24",
|
|
53
53
|
"typescript": "^6.0.3",
|
|
54
|
-
"vite-plus": "^0.1.
|
|
55
|
-
"vitest": "npm:@voidzero-dev/vite-plus-test@
|
|
56
|
-
"@blac/core": "2.
|
|
54
|
+
"vite-plus": "^0.1.24",
|
|
55
|
+
"vitest": "npm:@voidzero-dev/vite-plus-test@0.1.24",
|
|
56
|
+
"@blac/core": "2.1.1"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"dev": "vp pack --watch",
|
|
60
|
-
"build": "vp pack && tsc -p tsconfig.build.json &&
|
|
60
|
+
"build": "vp pack && tsc -p tsconfig.build.json && for f in dist/*.d.ts; do cp \"$f\" \"${f%.d.ts}.d.cts\"; done",
|
|
61
61
|
"clean": "rm -rf dist",
|
|
62
62
|
"format": "vp fmt \".\"",
|
|
63
63
|
"format:check": "vp fmt \".\" --check",
|