@mks2508/better-logger 5.0.0 → 5.0.2
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/chunks/{Logger-Cbi1f10o.js → Logger-CKqzXDh3.js} +2 -2
- package/dist/chunks/{Logger-Cbi1f10o.js.map → Logger-CKqzXDh3.js.map} +1 -1
- package/dist/chunks/{Logger-BZ7B7OXE.js → Logger-D_vuKP4l.js} +2 -2
- package/dist/chunks/{Logger-BZ7B7OXE.js.map → Logger-D_vuKP4l.js.map} +1 -1
- package/dist/chunks/cli-module-B-njrTWb.js +2 -0
- package/dist/chunks/cli-module-B-njrTWb.js.map +1 -0
- package/dist/chunks/{cli-module-ClIJmaT8.js → cli-module-Cx7qotPY.js} +16 -9
- package/dist/chunks/cli-module-Cx7qotPY.js.map +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/exports.cjs +1 -1
- package/dist/exports.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/styling.cjs +1 -1
- package/dist/styling.js +2 -2
- package/dist/terminal/formatter.d.ts.map +1 -1
- package/package.json +5 -1
- package/.claude/settings.local.json +0 -48
- package/.github/workflows/ci-quality.yml +0 -357
- package/.github/workflows/docs-demo.yml +0 -119
- package/.github/workflows/releases-core.yml +0 -512
- package/.github/workflows/releases-full.yml +0 -582
- package/.github/workflows-backup/ci.yml +0 -221
- package/.github/workflows-backup/nightly.yml +0 -196
- package/.github/workflows-backup/release-optimized.yml +0 -373
- package/.github/workflows-backup/release.yml +0 -269
- package/.release-notes-0.2.0.md +0 -129
- package/.yamllint +0 -28
- package/CHANGELOG.json +0 -1076
- package/CHANGELOG.md +0 -209
- package/CLAUDE.md +0 -217
- package/bun.lock +0 -333
- package/demo.html +0 -847
- package/dist/chunks/cli-module-CadqgZ1Z.js +0 -2
- package/dist/chunks/cli-module-CadqgZ1Z.js.map +0 -1
- package/dist/chunks/cli-module-ClIJmaT8.js.map +0 -1
- package/docs/API.md +0 -918
- package/docs/CORE.md +0 -264
- package/docs/DEVELOPMENT.md +0 -731
- package/docs/EXPORTS.md +0 -467
- package/docs/PACKAGES.md +0 -244
- package/docs/STYLING.md +0 -405
- package/docs/_config.yml +0 -36
- package/docs/index.md +0 -179
- package/examples/README.md +0 -208
- package/examples/basic-logging.js +0 -75
- package/examples/data-export.js +0 -234
- package/examples/package.json +0 -16
- package/examples/performance-timing.js +0 -170
- package/examples/simplified-api.js +0 -124
- package/examples/styling-themes.js +0 -207
- package/index.html +0 -358
- package/packages/core/package.json +0 -57
- package/packages/exports/package.json +0 -41
- package/packages/nodejs-opentui/README.md +0 -232
- package/packages/nodejs-opentui/package.json +0 -72
- package/packages/nodejs-opentui/src/LogRenderer.ts +0 -171
- package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +0 -178
- package/packages/nodejs-opentui/src/components/LogBadge.tsx +0 -131
- package/packages/nodejs-opentui/src/index.ts +0 -133
- package/packages/nodejs-opentui/src/types.ts +0 -158
- package/packages/nodejs-opentui/tsconfig.json +0 -20
- package/packages/styling/package.json +0 -41
- package/playground/demo-all.ts +0 -95
- package/playground/demo-box.ts +0 -85
- package/playground/demo-levels.ts +0 -56
- package/playground/demo-real-world.ts +0 -98
- package/playground/demo-spinner.ts +0 -77
- package/playground/demo-steps.ts +0 -72
- package/playground/demo-table.ts +0 -83
- package/project-utils/README.md +0 -172
- package/project-utils/auto-release-gemini.ts +0 -1193
- package/project-utils/auto-release-ui.ts +0 -1329
- package/project-utils/commit-generator.ts +0 -1385
- package/project-utils/commit-ui.ts +0 -264
- package/project-utils/git-utils.ts +0 -199
- package/project-utils/github-release-manager.ts +0 -466
- package/project-utils/project-config.ts +0 -260
- package/project-utils/prompt-templates.js +0 -345
- package/project-utils/prompt-templates.ts +0 -422
- package/project-utils/version-manager.ts +0 -1078
- package/public/vite.svg +0 -1
- package/src/Logger.ts +0 -1858
- package/src/ScopedLogger.ts +0 -256
- package/src/cli/CommandProcessor.ts +0 -248
- package/src/cli/commands/ConfigCommand.ts +0 -93
- package/src/cli/commands/ExportCommand.ts +0 -276
- package/src/cli/commands/HistoryCommand.ts +0 -117
- package/src/cli/commands/StatusCommand.ts +0 -112
- package/src/cli/commands/ThemeCommand.ts +0 -88
- package/src/cli/help.ts +0 -127
- package/src/cli/index.ts +0 -71
- package/src/cli-module.ts +0 -21
- package/src/cli-primitives/box.ts +0 -86
- package/src/cli-primitives/cli-table.ts +0 -62
- package/src/cli-primitives/divider.ts +0 -17
- package/src/cli-primitives/header.ts +0 -18
- package/src/cli-primitives/index.ts +0 -13
- package/src/cli-primitives/server-fallback.ts +0 -54
- package/src/cli-primitives/spinner.ts +0 -133
- package/src/cli-primitives/step.ts +0 -22
- package/src/constants.ts +0 -313
- package/src/core.ts +0 -397
- package/src/example.ts +0 -210
- package/src/exports-module.ts +0 -311
- package/src/handlers/AnalyticsLogHandler.ts +0 -22
- package/src/handlers/ExportLogHandler.ts +0 -610
- package/src/handlers/FileLogHandler.ts +0 -169
- package/src/handlers/RemoteLogHandler.ts +0 -42
- package/src/handlers/index.ts +0 -8
- package/src/hooks/HookManager.ts +0 -177
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +0 -395
- package/src/main.ts +0 -196
- package/src/serializers/SerializerRegistry.ts +0 -173
- package/src/serializers/index.ts +0 -1
- package/src/style.css +0 -96
- package/src/styling/LogStyleBuilder.ts +0 -355
- package/src/styling/SemanticStyles.ts +0 -380
- package/src/styling/SmartPresets.ts +0 -288
- package/src/styling/StyleBuilder.ts +0 -319
- package/src/styling/StyleCache.ts +0 -131
- package/src/styling/banners.ts +0 -168
- package/src/styling/index.ts +0 -27
- package/src/styling/themes.ts +0 -235
- package/src/styling-module.ts +0 -244
- package/src/terminal/color-converter.ts +0 -315
- package/src/terminal/formatter.ts +0 -236
- package/src/terminal/terminal-renderer.ts +0 -342
- package/src/transports/ConsoleTransport.ts +0 -28
- package/src/transports/FileTransport.ts +0 -53
- package/src/transports/HttpTransport.ts +0 -56
- package/src/transports/TransportManager.ts +0 -130
- package/src/transports/index.ts +0 -4
- package/src/types/core.ts +0 -417
- package/src/types/handlers.ts +0 -95
- package/src/types/hooks.ts +0 -45
- package/src/types/index.ts +0 -83
- package/src/types/serializers.ts +0 -30
- package/src/types/transports.ts +0 -52
- package/src/typescript.svg +0 -1
- package/src/utils/adapter.ts +0 -291
- package/src/utils/ansi-colors.ts +0 -333
- package/src/utils/environment-detector.ts +0 -170
- package/src/utils/environment.ts +0 -94
- package/src/utils/formatting.ts +0 -332
- package/src/utils/index.ts +0 -33
- package/src/utils/opentui-detection.ts +0 -138
- package/src/utils/output.ts +0 -227
- package/src/utils/stackTrace.ts +0 -144
- package/src/utils/timestamps.ts +0 -80
- package/src/vite-env.d.ts +0 -1
- package/src/writers/BufferWriter.ts +0 -157
- package/src/writers/index.ts +0 -6
- package/test-core-browser.html +0 -237
- package/test-core-node.js +0 -63
- package/tests/test-conflict-resolution.ts +0 -391
- package/tests/validate-workflows.sh +0 -131
- package/tests/yaml-autofix.sh +0 -146
- package/tsconfig.json +0 -50
- package/vite.config.ts +0 -256
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SerializerFn,
|
|
3
|
-
SerializerContext,
|
|
4
|
-
SerializerEntry,
|
|
5
|
-
SerializerConfig,
|
|
6
|
-
ISerializerRegistry
|
|
7
|
-
} from '../types/index.js';
|
|
8
|
-
|
|
9
|
-
const DEFAULT_CONFIG: Required<SerializerConfig> = {
|
|
10
|
-
maxDepth: 5,
|
|
11
|
-
circular: 'placeholder',
|
|
12
|
-
preserveUndefined: false
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export class SerializerRegistry implements ISerializerRegistry {
|
|
16
|
-
private serializers: Map<Function, SerializerEntry> = new Map();
|
|
17
|
-
private config: Required<SerializerConfig>;
|
|
18
|
-
|
|
19
|
-
constructor(config: SerializerConfig = {}) {
|
|
20
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
21
|
-
this.registerDefaults();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
private registerDefaults(): void {
|
|
25
|
-
this.add(Error, (err: Error) => ({
|
|
26
|
-
name: err.name,
|
|
27
|
-
message: err.message,
|
|
28
|
-
stack: err.stack?.split('\n').slice(0, 10),
|
|
29
|
-
...(err.cause ? { cause: this.serialize(err.cause) } : {})
|
|
30
|
-
}), 100);
|
|
31
|
-
|
|
32
|
-
this.add(Date, (date: Date) => ({
|
|
33
|
-
iso: date.toISOString(),
|
|
34
|
-
timestamp: date.getTime()
|
|
35
|
-
}), 90);
|
|
36
|
-
|
|
37
|
-
this.add(RegExp, (regex: RegExp) => ({
|
|
38
|
-
pattern: regex.source,
|
|
39
|
-
flags: regex.flags
|
|
40
|
-
}), 90);
|
|
41
|
-
|
|
42
|
-
this.add(Map, (map: Map<any, any>, ctx) => {
|
|
43
|
-
const obj: Record<string, any> = {};
|
|
44
|
-
map.forEach((value, key) => {
|
|
45
|
-
const keyStr = typeof key === 'object' ? JSON.stringify(key) : String(key);
|
|
46
|
-
obj[keyStr] = this.serializeInternal(value, {
|
|
47
|
-
...ctx,
|
|
48
|
-
depth: ctx.depth + 1,
|
|
49
|
-
path: [...ctx.path, keyStr]
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
return { __type: 'Map', entries: obj };
|
|
53
|
-
}, 80);
|
|
54
|
-
|
|
55
|
-
this.add(Set, (set: Set<any>, ctx) => ({
|
|
56
|
-
__type: 'Set',
|
|
57
|
-
values: Array.from(set).map((v, i) =>
|
|
58
|
-
this.serializeInternal(v, {
|
|
59
|
-
...ctx,
|
|
60
|
-
depth: ctx.depth + 1,
|
|
61
|
-
path: [...ctx.path, `[${i}]`]
|
|
62
|
-
})
|
|
63
|
-
)
|
|
64
|
-
}), 80);
|
|
65
|
-
|
|
66
|
-
if (typeof Buffer !== 'undefined') {
|
|
67
|
-
this.add(Buffer as any, (buf: Buffer) => ({
|
|
68
|
-
__type: 'Buffer',
|
|
69
|
-
length: buf.length,
|
|
70
|
-
preview: buf.slice(0, 50).toString('hex')
|
|
71
|
-
}), 70);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
add<T>(
|
|
76
|
-
type: new (...args: any[]) => T,
|
|
77
|
-
serializer: SerializerFn<T>,
|
|
78
|
-
priority: number = 50
|
|
79
|
-
): void {
|
|
80
|
-
this.serializers.set(type, { type, serializer, priority });
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
remove<T>(type: new (...args: any[]) => T): boolean {
|
|
84
|
-
return this.serializers.delete(type);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
has<T>(type: new (...args: any[]) => T): boolean {
|
|
88
|
-
return this.serializers.has(type);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
getAll(): SerializerEntry[] {
|
|
92
|
-
return Array.from(this.serializers.values())
|
|
93
|
-
.sort((a, b) => (b.priority ?? 50) - (a.priority ?? 50));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
private findSerializer(value: any): SerializerEntry | null {
|
|
97
|
-
const sorted = this.getAll();
|
|
98
|
-
for (const entry of sorted) {
|
|
99
|
-
if (value instanceof entry.type) {
|
|
100
|
-
return entry;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
private serializeInternal(value: any, context: SerializerContext): any {
|
|
107
|
-
if (value === null) return null;
|
|
108
|
-
if (value === undefined) return this.config.preserveUndefined ? undefined : '[undefined]';
|
|
109
|
-
if (typeof value === 'function') return `[Function: ${value.name || 'anonymous'}]`;
|
|
110
|
-
if (typeof value !== 'object') return value;
|
|
111
|
-
|
|
112
|
-
if (context.depth >= this.config.maxDepth) {
|
|
113
|
-
return '[Max Depth]';
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (context.seen.has(value)) {
|
|
117
|
-
switch (this.config.circular) {
|
|
118
|
-
case 'error':
|
|
119
|
-
throw new Error(`Circular reference at ${context.path.join('.')}`);
|
|
120
|
-
case 'skip':
|
|
121
|
-
return undefined;
|
|
122
|
-
case 'placeholder':
|
|
123
|
-
default:
|
|
124
|
-
return '[Circular]';
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
context.seen.add(value);
|
|
128
|
-
|
|
129
|
-
const serializer = this.findSerializer(value);
|
|
130
|
-
if (serializer) {
|
|
131
|
-
return serializer.serializer(value, context);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (Array.isArray(value)) {
|
|
135
|
-
return value.map((item, i) =>
|
|
136
|
-
this.serializeInternal(item, {
|
|
137
|
-
...context,
|
|
138
|
-
depth: context.depth + 1,
|
|
139
|
-
path: [...context.path, `[${i}]`]
|
|
140
|
-
})
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const result: Record<string, any> = {};
|
|
145
|
-
for (const [key, val] of Object.entries(value)) {
|
|
146
|
-
result[key] = this.serializeInternal(val, {
|
|
147
|
-
...context,
|
|
148
|
-
depth: context.depth + 1,
|
|
149
|
-
path: [...context.path, key]
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
return result;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
serialize(value: any, config?: SerializerConfig): any {
|
|
156
|
-
const mergedConfig = { ...this.config, ...config };
|
|
157
|
-
return this.serializeInternal(value, {
|
|
158
|
-
depth: 0,
|
|
159
|
-
maxDepth: mergedConfig.maxDepth,
|
|
160
|
-
path: [],
|
|
161
|
-
seen: new WeakSet()
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
let _defaultRegistry: SerializerRegistry | null = null;
|
|
167
|
-
|
|
168
|
-
export function getDefaultSerializerRegistry(): SerializerRegistry {
|
|
169
|
-
if (!_defaultRegistry) {
|
|
170
|
-
_defaultRegistry = new SerializerRegistry();
|
|
171
|
-
}
|
|
172
|
-
return _defaultRegistry;
|
|
173
|
-
}
|
package/src/serializers/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SerializerRegistry, getDefaultSerializerRegistry } from './SerializerRegistry.js';
|
package/src/style.css
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
-
line-height: 1.5;
|
|
4
|
-
font-weight: 400;
|
|
5
|
-
|
|
6
|
-
color-scheme: light dark;
|
|
7
|
-
color: rgba(255, 255, 255, 0.87);
|
|
8
|
-
background-color: #242424;
|
|
9
|
-
|
|
10
|
-
font-synthesis: none;
|
|
11
|
-
text-rendering: optimizeLegibility;
|
|
12
|
-
-webkit-font-smoothing: antialiased;
|
|
13
|
-
-moz-osx-font-smoothing: grayscale;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
a {
|
|
17
|
-
font-weight: 500;
|
|
18
|
-
color: #646cff;
|
|
19
|
-
text-decoration: inherit;
|
|
20
|
-
}
|
|
21
|
-
a:hover {
|
|
22
|
-
color: #535bf2;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
body {
|
|
26
|
-
margin: 0;
|
|
27
|
-
display: flex;
|
|
28
|
-
place-items: center;
|
|
29
|
-
min-width: 320px;
|
|
30
|
-
min-height: 100vh;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
h1 {
|
|
34
|
-
font-size: 3.2em;
|
|
35
|
-
line-height: 1.1;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
#app {
|
|
39
|
-
max-width: 1280px;
|
|
40
|
-
margin: 0 auto;
|
|
41
|
-
padding: 2rem;
|
|
42
|
-
text-align: center;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.logo {
|
|
46
|
-
height: 6em;
|
|
47
|
-
padding: 1.5em;
|
|
48
|
-
will-change: filter;
|
|
49
|
-
transition: filter 300ms;
|
|
50
|
-
}
|
|
51
|
-
.logo:hover {
|
|
52
|
-
filter: drop-shadow(0 0 2em #646cffaa);
|
|
53
|
-
}
|
|
54
|
-
.logo.vanilla:hover {
|
|
55
|
-
filter: drop-shadow(0 0 2em #3178c6aa);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.card {
|
|
59
|
-
padding: 2em;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.read-the-docs {
|
|
63
|
-
color: #888;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
button {
|
|
67
|
-
border-radius: 8px;
|
|
68
|
-
border: 1px solid transparent;
|
|
69
|
-
padding: 0.6em 1.2em;
|
|
70
|
-
font-size: 1em;
|
|
71
|
-
font-weight: 500;
|
|
72
|
-
font-family: inherit;
|
|
73
|
-
background-color: #1a1a1a;
|
|
74
|
-
cursor: pointer;
|
|
75
|
-
transition: border-color 0.25s;
|
|
76
|
-
}
|
|
77
|
-
button:hover {
|
|
78
|
-
border-color: #646cff;
|
|
79
|
-
}
|
|
80
|
-
button:focus,
|
|
81
|
-
button:focus-visible {
|
|
82
|
-
outline: 4px auto -webkit-focus-ring-color;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
@media (prefers-color-scheme: light) {
|
|
86
|
-
:root {
|
|
87
|
-
color: #213547;
|
|
88
|
-
background-color: #ffffff;
|
|
89
|
-
}
|
|
90
|
-
a:hover {
|
|
91
|
-
color: #747bff;
|
|
92
|
-
}
|
|
93
|
-
button {
|
|
94
|
-
background-color: #f9f9f9;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview LogStyleBuilder for fluent log styling API
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { Logger } from '../Logger.js';
|
|
6
|
-
import type { LogStyles, LogLayout, SpacingType } from '../types/index.js';
|
|
7
|
-
import {
|
|
8
|
-
TimestampStyler,
|
|
9
|
-
LevelStyler,
|
|
10
|
-
PrefixStyler,
|
|
11
|
-
MessageStyler,
|
|
12
|
-
LocationStyler
|
|
13
|
-
} from './SemanticStyles.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Fluent API builder for log styling with semantic methods
|
|
17
|
-
*/
|
|
18
|
-
export class LogStyleBuilder {
|
|
19
|
-
private logStyles: LogStyles = {};
|
|
20
|
-
private logger: Logger;
|
|
21
|
-
|
|
22
|
-
constructor(logger: Logger) {
|
|
23
|
-
this.logger = logger;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Configure timestamp styling
|
|
28
|
-
*/
|
|
29
|
-
timestamp(): TimestampStyleBuilderProxy {
|
|
30
|
-
return new TimestampStyleBuilderProxy(this);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Configure level badge styling
|
|
35
|
-
*/
|
|
36
|
-
level(): LevelStyleBuilderProxy {
|
|
37
|
-
return new LevelStyleBuilderProxy(this);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Configure prefix styling
|
|
42
|
-
*/
|
|
43
|
-
prefix(): PrefixStyleBuilderProxy {
|
|
44
|
-
return new PrefixStyleBuilderProxy(this);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Configure message text styling
|
|
49
|
-
*/
|
|
50
|
-
message(): MessageStyleBuilderProxy {
|
|
51
|
-
return new MessageStyleBuilderProxy(this);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Configure location info styling
|
|
56
|
-
*/
|
|
57
|
-
location(): LocationStyleBuilderProxy {
|
|
58
|
-
return new LocationStyleBuilderProxy(this);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Use a predefined preset
|
|
63
|
-
*/
|
|
64
|
-
usePreset(presetName: string): LogStyleBuilder {
|
|
65
|
-
// Will be implemented when we create the presets
|
|
66
|
-
console.warn(`Preset '${presetName}' will be available in next implementation phase`);
|
|
67
|
-
return this;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Customize with partial configuration
|
|
72
|
-
*/
|
|
73
|
-
customize(overrides: Partial<LogStyles>): LogStyleBuilder {
|
|
74
|
-
this.logStyles = { ...this.logStyles, ...overrides };
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Set layout spacing
|
|
80
|
-
*/
|
|
81
|
-
spacing(type: SpacingType): LogStyleBuilder {
|
|
82
|
-
if (!this.logStyles.layout) {
|
|
83
|
-
this.logStyles.layout = { spacing: type };
|
|
84
|
-
} else {
|
|
85
|
-
this.logStyles.layout.spacing = type;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Apply spacing-specific configurations
|
|
89
|
-
switch (type) {
|
|
90
|
-
case 'compact':
|
|
91
|
-
this.logStyles.layout.innerPadding = '1px';
|
|
92
|
-
this.logStyles.layout.outerMargin = '0px';
|
|
93
|
-
break;
|
|
94
|
-
case 'spacious':
|
|
95
|
-
this.logStyles.layout.innerPadding = '4px';
|
|
96
|
-
this.logStyles.layout.outerMargin = '2px';
|
|
97
|
-
break;
|
|
98
|
-
default: // normal
|
|
99
|
-
this.logStyles.layout.innerPadding = '2px';
|
|
100
|
-
this.logStyles.layout.outerMargin = '1px';
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return this;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Set backdrop filter for glassmorphism effects
|
|
108
|
-
*/
|
|
109
|
-
backdrop(filter: string): LogStyleBuilder {
|
|
110
|
-
this.logStyles.backdrop = filter;
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Set overall transparency
|
|
116
|
-
*/
|
|
117
|
-
transparency(value: number): LogStyleBuilder {
|
|
118
|
-
this.logStyles.transparency = Math.max(0, Math.min(1, value));
|
|
119
|
-
return this;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Apply the configured styles to the logger
|
|
124
|
-
*/
|
|
125
|
-
apply(): void {
|
|
126
|
-
// Store the configuration in the logger
|
|
127
|
-
// This will be implemented when we integrate with the main Logger
|
|
128
|
-
(this.logger as any)._customLogStyles = this.logStyles;
|
|
129
|
-
console.log('Applied log styles:', this.logStyles);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Get current configuration (for debugging)
|
|
134
|
-
*/
|
|
135
|
-
getConfig(): LogStyles {
|
|
136
|
-
return { ...this.logStyles };
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Internal method to update part configuration
|
|
141
|
-
*/
|
|
142
|
-
_updatePartConfig(part: keyof LogStyles, styles: string): void {
|
|
143
|
-
if (part === 'layout' || part === 'backdrop' || part === 'transparency') {
|
|
144
|
-
return; // Skip these non-part configs
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (!this.logStyles[part]) {
|
|
148
|
-
this.logStyles[part] = {};
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Parse basic CSS styles into config
|
|
152
|
-
// This is a simplified approach - in production might want more sophisticated parsing
|
|
153
|
-
this.logStyles[part]!.style = styles;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Base proxy class for part-specific styling
|
|
159
|
-
*/
|
|
160
|
-
abstract class PartStyleBuilderProxy {
|
|
161
|
-
protected parentBuilder: LogStyleBuilder;
|
|
162
|
-
protected partName: keyof LogStyles;
|
|
163
|
-
|
|
164
|
-
constructor(parentBuilder: LogStyleBuilder, partName: keyof LogStyles) {
|
|
165
|
-
this.parentBuilder = parentBuilder;
|
|
166
|
-
this.partName = partName;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Return to the main builder for chaining other parts
|
|
171
|
-
*/
|
|
172
|
-
and(): LogStyleBuilder {
|
|
173
|
-
return this.parentBuilder;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Apply styles and finish configuration
|
|
178
|
-
*/
|
|
179
|
-
apply(): void {
|
|
180
|
-
this.parentBuilder.apply();
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Helper to apply styles to the parent builder
|
|
185
|
-
*/
|
|
186
|
-
protected applyStyles(styler: any): this {
|
|
187
|
-
const styles = styler.build();
|
|
188
|
-
this.parentBuilder._updatePartConfig(this.partName, styles);
|
|
189
|
-
return this;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Timestamp styling proxy with fluent API
|
|
195
|
-
*/
|
|
196
|
-
class TimestampStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
197
|
-
constructor(parentBuilder: LogStyleBuilder) {
|
|
198
|
-
super(parentBuilder, 'timestamp');
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
default(): TimestampStyleBuilderProxy {
|
|
202
|
-
return this.applyStyles(new TimestampStyler().default());
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
hidden(): TimestampStyleBuilderProxy {
|
|
206
|
-
return this.applyStyles(new TimestampStyler().hidden());
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
minimal(): TimestampStyleBuilderProxy {
|
|
210
|
-
return this.applyStyles(new TimestampStyler().minimal());
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
muted(): TimestampStyleBuilderProxy {
|
|
214
|
-
return this.applyStyles(new TimestampStyler().muted());
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
mono(): TimestampStyleBuilderProxy {
|
|
218
|
-
return this.applyStyles(new TimestampStyler().mono());
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
compact(): TimestampStyleBuilderProxy {
|
|
222
|
-
return this.applyStyles(new TimestampStyler().compact());
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Level badge styling proxy with fluent API
|
|
228
|
-
*/
|
|
229
|
-
class LevelStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
230
|
-
constructor(parentBuilder: LogStyleBuilder) {
|
|
231
|
-
super(parentBuilder, 'level');
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
badge(): LevelStyleBuilderProxy {
|
|
235
|
-
return this.applyStyles(new LevelStyler().badge());
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
gradient(from?: string, to?: string): LevelStyleBuilderProxy {
|
|
239
|
-
return this.applyStyles(new LevelStyler().gradient(from, to));
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
glowing(): LevelStyleBuilderProxy {
|
|
243
|
-
return this.applyStyles(new LevelStyler().glowing());
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
flat(): LevelStyleBuilderProxy {
|
|
247
|
-
return this.applyStyles(new LevelStyler().flat());
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
bold(): LevelStyleBuilderProxy {
|
|
251
|
-
return this.applyStyles(new LevelStyler().bold());
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
uppercase(): LevelStyleBuilderProxy {
|
|
255
|
-
return this.applyStyles(new LevelStyler().uppercase());
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
neon(): LevelStyleBuilderProxy {
|
|
259
|
-
return this.applyStyles(new LevelStyler().neon());
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Prefix styling proxy with fluent API
|
|
265
|
-
*/
|
|
266
|
-
class PrefixStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
267
|
-
constructor(parentBuilder: LogStyleBuilder) {
|
|
268
|
-
super(parentBuilder, 'prefix');
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
dark(): PrefixStyleBuilderProxy {
|
|
272
|
-
return this.applyStyles(new PrefixStyler().dark());
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
light(): PrefixStyleBuilderProxy {
|
|
276
|
-
return this.applyStyles(new PrefixStyler().light());
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
compact(): PrefixStyleBuilderProxy {
|
|
280
|
-
return this.applyStyles(new PrefixStyler().compact());
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
muted(): PrefixStyleBuilderProxy {
|
|
284
|
-
return this.applyStyles(new PrefixStyler().muted());
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
mono(): PrefixStyleBuilderProxy {
|
|
288
|
-
return this.applyStyles(new PrefixStyler().mono());
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Message styling proxy with fluent API
|
|
294
|
-
*/
|
|
295
|
-
class MessageStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
296
|
-
constructor(parentBuilder: LogStyleBuilder) {
|
|
297
|
-
super(parentBuilder, 'message');
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
readable(): MessageStyleBuilderProxy {
|
|
301
|
-
return this.applyStyles(new MessageStyler().readable());
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
code(): MessageStyleBuilderProxy {
|
|
305
|
-
return this.applyStyles(new MessageStyler().code());
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
large(): MessageStyleBuilderProxy {
|
|
309
|
-
return this.applyStyles(new MessageStyler().large());
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
system(): MessageStyleBuilderProxy {
|
|
313
|
-
return this.applyStyles(new MessageStyler().system());
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
mono(): MessageStyleBuilderProxy {
|
|
317
|
-
return this.applyStyles(new MessageStyler().mono());
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Location styling proxy with fluent API
|
|
323
|
-
*/
|
|
324
|
-
class LocationStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
325
|
-
constructor(parentBuilder: LogStyleBuilder) {
|
|
326
|
-
super(parentBuilder, 'location');
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
subtle(): LocationStyleBuilderProxy {
|
|
330
|
-
return this.applyStyles(new LocationStyler().subtle());
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
hidden(): LocationStyleBuilderProxy {
|
|
334
|
-
return this.applyStyles(new LocationStyler().hidden());
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
clickable(): LocationStyleBuilderProxy {
|
|
338
|
-
return this.applyStyles(new LocationStyler().clickable());
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
muted(): LocationStyleBuilderProxy {
|
|
342
|
-
return this.applyStyles(new LocationStyler().muted());
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
mono(): LocationStyleBuilderProxy {
|
|
346
|
-
return this.applyStyles(new LocationStyler().mono());
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Create a new LogStyleBuilder instance
|
|
352
|
-
*/
|
|
353
|
-
export function createLogStyleBuilder(logger: Logger): LogStyleBuilder {
|
|
354
|
-
return new LogStyleBuilder(logger);
|
|
355
|
-
}
|