@mks2508/better-logger 0.0.2-alpha.2 → 0.11.0-alpha.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/.github/workflows/ci-quality.yml +357 -0
- package/.github/workflows/docs-demo.yml +119 -0
- package/.github/workflows/releases-core.yml +512 -0
- package/.github/workflows/releases-full.yml +582 -0
- package/.github/{workflows → workflows-backup}/ci.yml +12 -110
- package/.github/workflows-backup/nightly.yml +196 -0
- package/.github/workflows-backup/release-optimized.yml +373 -0
- package/.release-notes-0.2.0.md +129 -0
- package/.yamllint +28 -0
- package/CHANGELOG.json +749 -0
- package/CLAUDE.md +92 -1
- package/README.md +142 -498
- package/bun.lock +323 -0
- package/demo.html +9 -2
- package/dist/Logger.d.ts +176 -0
- package/dist/Logger.d.ts.map +1 -0
- package/dist/Logger.js +498 -0
- package/dist/chunks/Logger-C2-cR3No.js +2 -0
- package/dist/chunks/Logger-C2-cR3No.js.map +1 -0
- package/dist/chunks/Logger-CVwk8cgA.js +2159 -0
- package/dist/chunks/Logger-CVwk8cgA.js.map +1 -0
- package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +33 -0
- package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +1 -0
- package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +2 -0
- package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +1 -0
- package/dist/chunks/StyleBuilder-BoJTmskd.js +361 -0
- package/dist/chunks/StyleBuilder-BoJTmskd.js.map +1 -0
- package/dist/chunks/StyleBuilder-LPLzsoHY.js +4 -0
- package/dist/chunks/StyleBuilder-LPLzsoHY.js.map +1 -0
- package/dist/cli/CommandProcessor.d.ts +103 -0
- package/dist/cli/CommandProcessor.d.ts.map +1 -0
- package/dist/cli/CommandProcessor.js +184 -0
- package/dist/cli/commands/ConfigCommand.d.ts +17 -0
- package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
- package/dist/cli/commands/ConfigCommand.js +88 -0
- package/dist/cli/commands/ExportCommand.d.ts +51 -0
- package/dist/cli/commands/ExportCommand.d.ts.map +1 -0
- package/dist/cli/commands/ExportCommand.js +243 -0
- package/dist/cli/commands/HistoryCommand.d.ts +50 -0
- package/dist/cli/commands/HistoryCommand.d.ts.map +1 -0
- package/dist/cli/commands/HistoryCommand.js +96 -0
- package/dist/cli/commands/StatusCommand.d.ts +33 -0
- package/dist/cli/commands/StatusCommand.d.ts.map +1 -0
- package/dist/cli/commands/StatusCommand.js +93 -0
- package/dist/cli/commands/ThemeCommand.d.ts +33 -0
- package/dist/cli/commands/ThemeCommand.d.ts.map +1 -0
- package/dist/cli/commands/ThemeCommand.js +79 -0
- package/dist/cli/help.d.ts +15 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +118 -0
- package/dist/cli/index.d.ts +15 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +46 -0
- package/dist/constants.d.ts +91 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +80 -0
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +130 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +258 -242
- package/dist/core.js.map +1 -1
- package/dist/example.d.ts +18 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +154 -0
- package/dist/exports-module.d.ts +203 -0
- package/dist/exports-module.d.ts.map +1 -0
- package/dist/exports-module.js +260 -0
- package/dist/exports.cjs +1 -1
- package/dist/exports.cjs.map +1 -1
- package/dist/exports.js +2 -2
- package/dist/handlers/AnalyticsLogHandler.d.ts +11 -0
- package/dist/handlers/AnalyticsLogHandler.d.ts.map +1 -0
- package/dist/handlers/AnalyticsLogHandler.js +19 -0
- package/dist/handlers/ExportLogHandler.d.ts +103 -0
- package/dist/handlers/ExportLogHandler.d.ts.map +1 -0
- package/dist/handlers/ExportLogHandler.js +516 -0
- package/dist/handlers/FileLogHandler.d.ts +13 -0
- package/dist/handlers/FileLogHandler.d.ts.map +1 -0
- package/dist/handlers/FileLogHandler.js +24 -0
- package/dist/handlers/RemoteLogHandler.d.ts +14 -0
- package/dist/handlers/RemoteLogHandler.d.ts.map +1 -0
- package/dist/handlers/RemoteLogHandler.js +37 -0
- package/dist/handlers/index.d.ts +8 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +7 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +89 -103
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +139 -0
- package/dist/styling/StyleBuilder.d.ts +132 -0
- package/dist/styling/StyleBuilder.d.ts.map +1 -0
- package/dist/styling/StyleBuilder.js +268 -0
- package/dist/styling/banners.d.ts +45 -0
- package/dist/styling/banners.d.ts.map +1 -0
- package/dist/styling/banners.js +155 -0
- package/dist/styling/index.d.ts +7 -0
- package/dist/styling/index.d.ts.map +1 -0
- package/dist/styling/index.js +6 -0
- package/dist/styling/themes.d.ts +10 -0
- package/dist/styling/themes.d.ts.map +1 -0
- package/dist/styling/themes.js +231 -0
- package/dist/styling-module.d.ts +185 -0
- package/dist/styling-module.d.ts.map +1 -0
- package/dist/styling-module.js +199 -0
- package/dist/styling.cjs +1 -1
- package/dist/styling.cjs.map +1 -1
- package/dist/styling.js +4 -4
- package/dist/types/Logger.d.ts +172 -0
- package/dist/types/Logger.d.ts.map +1 -0
- package/dist/types/cli/CommandProcessor.d.ts +100 -0
- package/dist/types/cli/CommandProcessor.d.ts.map +1 -0
- package/dist/types/cli/commands/ConfigCommand.d.ts +14 -0
- package/dist/types/cli/commands/ConfigCommand.d.ts.map +1 -0
- package/dist/types/cli/commands/ExportCommand.d.ts +48 -0
- package/dist/types/cli/commands/ExportCommand.d.ts.map +1 -0
- package/dist/types/cli/commands/HistoryCommand.d.ts +47 -0
- package/dist/types/cli/commands/HistoryCommand.d.ts.map +1 -0
- package/dist/types/cli/commands/StatusCommand.d.ts +30 -0
- package/dist/types/cli/commands/StatusCommand.d.ts.map +1 -0
- package/dist/types/cli/commands/ThemeCommand.d.ts +30 -0
- package/dist/types/cli/commands/ThemeCommand.d.ts.map +1 -0
- package/dist/types/cli/help.d.ts +12 -0
- package/dist/types/cli/help.d.ts.map +1 -0
- package/dist/types/cli/index.d.ts +15 -0
- package/dist/types/cli/index.d.ts.map +1 -0
- package/dist/types/constants.d.ts +88 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/core.d.ts +71 -211
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +13 -0
- package/dist/types/example.d.ts +18 -0
- package/dist/types/example.d.ts.map +1 -0
- package/dist/types/exports-module.d.ts +196 -0
- package/dist/types/exports-module.d.ts.map +1 -0
- package/dist/types/handlers/AnalyticsLogHandler.d.ts +8 -0
- package/dist/types/handlers/AnalyticsLogHandler.d.ts.map +1 -0
- package/dist/types/handlers/ExportLogHandler.d.ts +100 -0
- package/dist/types/handlers/ExportLogHandler.d.ts.map +1 -0
- package/dist/types/handlers/FileLogHandler.d.ts +10 -0
- package/dist/types/handlers/FileLogHandler.d.ts.map +1 -0
- package/dist/types/handlers/RemoteLogHandler.d.ts +11 -0
- package/dist/types/handlers/RemoteLogHandler.d.ts.map +1 -0
- package/dist/types/handlers/index.d.ts +8 -0
- package/dist/types/handlers/index.d.ts.map +1 -0
- package/dist/types/handlers.d.ts +88 -0
- package/dist/types/handlers.d.ts.map +1 -0
- package/dist/types/handlers.js +4 -0
- package/dist/types/index.d.ts +7 -675
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/types/main.d.ts +2 -0
- package/dist/types/main.d.ts.map +1 -0
- package/dist/types/styling/StyleBuilder.d.ts +132 -0
- package/dist/types/styling/StyleBuilder.d.ts.map +1 -0
- package/dist/types/styling/banners.d.ts +42 -0
- package/dist/types/styling/banners.d.ts.map +1 -0
- package/dist/types/styling/index.d.ts +7 -0
- package/dist/types/styling/index.d.ts.map +1 -0
- package/dist/types/styling/themes.d.ts +7 -0
- package/dist/types/styling/themes.d.ts.map +1 -0
- package/dist/types/styling-module.d.ts +178 -0
- package/dist/types/styling-module.d.ts.map +1 -0
- package/dist/types/types/core.d.ts +71 -0
- package/dist/types/types/core.d.ts.map +1 -0
- package/dist/types/types/handlers.d.ts +85 -0
- package/dist/types/types/handlers.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +7 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +7 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/output.d.ts +29 -0
- package/dist/types/utils/output.d.ts.map +1 -0
- package/dist/types/utils/stackTrace.d.ts +6 -0
- package/dist/types/utils/stackTrace.d.ts.map +1 -0
- package/dist/types/utils/timestamps.d.ts +20 -0
- package/dist/types/utils/timestamps.d.ts.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/output.d.ts +32 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +97 -0
- package/dist/utils/stackTrace.d.ts +9 -0
- package/dist/utils/stackTrace.d.ts.map +1 -0
- package/dist/utils/stackTrace.js +81 -0
- package/dist/utils/timestamps.d.ts +20 -0
- package/dist/utils/timestamps.d.ts.map +1 -0
- package/dist/utils/timestamps.js +71 -0
- package/docs/API.md +691 -0
- package/docs/DEVELOPMENT.md +731 -0
- package/docs/PACKAGES.md +244 -0
- package/docs/_config.yml +36 -0
- package/docs/index.md +179 -0
- package/examples/README.md +208 -0
- package/examples/basic-logging.js +75 -0
- package/examples/data-export.js +234 -0
- package/examples/package.json +16 -0
- package/examples/performance-timing.js +170 -0
- package/examples/styling-themes.js +207 -0
- package/package.json +32 -21
- package/packages/core/package.json +35 -0
- package/packages/exports/package.json +41 -0
- package/packages/styling/package.json +41 -0
- package/project-utils/README.md +172 -0
- package/project-utils/auto-release-gemini.ts +1193 -0
- package/project-utils/commit-generator.ts +1385 -0
- package/project-utils/commit-ui.ts +264 -0
- package/project-utils/git-utils.ts +199 -0
- package/project-utils/github-release-manager.ts +466 -0
- package/project-utils/prompt-templates.js +345 -0
- package/project-utils/prompt-templates.ts +422 -0
- package/project-utils/version-manager.ts +1078 -0
- package/src/Logger.ts +2 -1
- package/src/cli/CommandProcessor.ts +173 -2
- package/src/cli/commands/HistoryCommand.ts +117 -0
- package/src/cli/index.ts +12 -0
- package/src/handlers/ExportLogHandler.ts +141 -0
- package/tests/test-conflict-resolution.ts +391 -0
- package/tests/validate-workflows.sh +131 -0
- package/tests/yaml-autofix.sh +146 -0
- package/vite.config.ts +152 -50
- package/.claude/settings.local.json +0 -22
- package/.npmrc.bak +0 -1
- package/dist/chunks/Logger-BQhMKy_T.js +0 -2
- package/dist/chunks/Logger-BQhMKy_T.js.map +0 -1
- package/dist/chunks/Logger-BrFKFZcD.js +0 -978
- package/dist/chunks/Logger-BrFKFZcD.js.map +0 -1
- package/dist/chunks/core-2opW4Pi3.js +0 -194
- package/dist/chunks/core-2opW4Pi3.js.map +0 -1
- package/dist/chunks/core-DyugwSYZ.js +0 -4
- package/dist/chunks/core-DyugwSYZ.js.map +0 -1
- package/dist/chunks/exports-BNP3R7dp.js +0 -421
- package/dist/chunks/exports-BNP3R7dp.js.map +0 -1
- package/dist/chunks/exports-U1xLBXrY.js +0 -2
- package/dist/chunks/exports-U1xLBXrY.js.map +0 -1
- package/dist/chunks/styling-DhUDzwlE.js +0 -654
- package/dist/chunks/styling-DhUDzwlE.js.map +0 -1
- package/dist/chunks/styling-tmRDI28D.js +0 -2
- package/dist/chunks/styling-tmRDI28D.js.map +0 -1
- package/dist/types/exports.d.ts +0 -600
- package/dist/types/styling.d.ts +0 -751
- /package/.github/{workflows → workflows-backup}/release.yml +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Utility functions exports for Advanced Logger
|
|
3
|
+
*/
|
|
4
|
+
export { parseStackTrace } from './stackTrace.js';
|
|
5
|
+
export { formatTimestamp, parseRelativeTime, parseTimeInput, formatDisplayTime } from './timestamps.js';
|
|
6
|
+
export { createStyledOutput, generateLogId, escapeHtml, safeStringify } from './output.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Styled output creation utilities for Advanced Logger
|
|
3
|
+
*/
|
|
4
|
+
import type { LogLevel, StackInfo } from '../types/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Style configuration for each log level
|
|
7
|
+
*/
|
|
8
|
+
export interface LevelStyleConfig {
|
|
9
|
+
emoji: string;
|
|
10
|
+
label: string;
|
|
11
|
+
background: string;
|
|
12
|
+
color: string;
|
|
13
|
+
border: string;
|
|
14
|
+
shadow: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates styled console output with multiple %c formatters
|
|
18
|
+
*/
|
|
19
|
+
export declare function createStyledOutput(level: LogLevel, levelStyles: Record<LogLevel | 'success', LevelStyleConfig>, prefix: string | undefined, message: string, stackInfo: StackInfo | null): [string, ...string[]];
|
|
20
|
+
/**
|
|
21
|
+
* Create a unique ID for log entries
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateLogId(): string;
|
|
24
|
+
/**
|
|
25
|
+
* Escape HTML entities for safe HTML output
|
|
26
|
+
*/
|
|
27
|
+
export declare function escapeHtml(text: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Convert objects to safe string representation for logging
|
|
30
|
+
*/
|
|
31
|
+
export declare function safeStringify(obj: any, _maxDepth?: number): string;
|
|
32
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAI7D;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB;AAGD;;GAEG;AACH,wBAAgB,kBAAkB,CAC9B,KAAK,EAAE,QAAQ,EACf,WAAW,EAAE,MAAM,CAAC,QAAQ,GAAG,SAAS,EAAE,gBAAgB,CAAC,EAC3D,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,SAAS,GAAG,IAAI,GAC5B,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CA+DvB;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,SAAI,GAAG,MAAM,CAY7D"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Styled output creation utilities for Advanced Logger
|
|
3
|
+
*/
|
|
4
|
+
import { formatTimestamp } from './timestamps.js';
|
|
5
|
+
import { StyleBuilder } from '../styling/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Creates styled console output with multiple %c formatters
|
|
8
|
+
*/
|
|
9
|
+
export function createStyledOutput(level, levelStyles, prefix, message, stackInfo) {
|
|
10
|
+
const levelConfig = levelStyles[level];
|
|
11
|
+
const timestamp = formatTimestamp();
|
|
12
|
+
// Base styles
|
|
13
|
+
const timestampStyle = new StyleBuilder()
|
|
14
|
+
.color('#666')
|
|
15
|
+
.size('11px')
|
|
16
|
+
.font('Monaco, Consolas, monospace')
|
|
17
|
+
.build();
|
|
18
|
+
const levelStyle = new StyleBuilder()
|
|
19
|
+
.bg(levelConfig.background)
|
|
20
|
+
.color(levelConfig.color)
|
|
21
|
+
.border(levelConfig.border)
|
|
22
|
+
.shadow(levelConfig.shadow)
|
|
23
|
+
.padding('2px 8px')
|
|
24
|
+
.rounded('4px')
|
|
25
|
+
.bold()
|
|
26
|
+
.font('Monaco, Consolas, monospace')
|
|
27
|
+
.size('12px')
|
|
28
|
+
.build();
|
|
29
|
+
const prefixStyle = new StyleBuilder()
|
|
30
|
+
.bg('#2d3748')
|
|
31
|
+
.color('#e2e8f0')
|
|
32
|
+
.padding('2px 6px')
|
|
33
|
+
.rounded('3px')
|
|
34
|
+
.bold()
|
|
35
|
+
.font('Monaco, Consolas, monospace')
|
|
36
|
+
.size('11px')
|
|
37
|
+
.build();
|
|
38
|
+
const messageStyle = new StyleBuilder()
|
|
39
|
+
.color('#2d3748')
|
|
40
|
+
.font('system-ui, -apple-system, sans-serif')
|
|
41
|
+
.size('14px')
|
|
42
|
+
.build();
|
|
43
|
+
const locationStyle = new StyleBuilder()
|
|
44
|
+
.color('#718096')
|
|
45
|
+
.size('11px')
|
|
46
|
+
.font('Monaco, Consolas, monospace')
|
|
47
|
+
.build();
|
|
48
|
+
// Build format string and styles
|
|
49
|
+
let format = `%c${timestamp.slice(11, 23)} %c${levelConfig.emoji} ${levelConfig.label}`;
|
|
50
|
+
const styles = [timestampStyle, levelStyle];
|
|
51
|
+
if (prefix) {
|
|
52
|
+
format += ` %c${prefix}`;
|
|
53
|
+
styles.push(prefixStyle);
|
|
54
|
+
}
|
|
55
|
+
format += ` %c${message}`;
|
|
56
|
+
styles.push(messageStyle);
|
|
57
|
+
if (stackInfo) {
|
|
58
|
+
format += ` %c(${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`;
|
|
59
|
+
styles.push(locationStyle);
|
|
60
|
+
}
|
|
61
|
+
return [format, ...styles];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a unique ID for log entries
|
|
65
|
+
*/
|
|
66
|
+
export function generateLogId() {
|
|
67
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Escape HTML entities for safe HTML output
|
|
71
|
+
*/
|
|
72
|
+
export function escapeHtml(text) {
|
|
73
|
+
const div = document.createElement('div');
|
|
74
|
+
div.textContent = text;
|
|
75
|
+
return div.innerHTML;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Convert objects to safe string representation for logging
|
|
79
|
+
*/
|
|
80
|
+
export function safeStringify(obj, _maxDepth = 3) {
|
|
81
|
+
try {
|
|
82
|
+
return JSON.stringify(obj, (_key, value) => {
|
|
83
|
+
if (typeof value === 'function')
|
|
84
|
+
return '[Function]';
|
|
85
|
+
if (value instanceof Error)
|
|
86
|
+
return `[Error: ${value.message}]`;
|
|
87
|
+
if (value instanceof Date)
|
|
88
|
+
return value.toISOString();
|
|
89
|
+
if (typeof value === 'undefined')
|
|
90
|
+
return '[undefined]';
|
|
91
|
+
return value;
|
|
92
|
+
}, 2);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
return String(obj);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Stack trace parsing utilities for Advanced Logger
|
|
3
|
+
*/
|
|
4
|
+
import type { StackInfo } from '../types/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Parses the current stack trace to extract caller information
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseStackTrace(): StackInfo | null;
|
|
9
|
+
//# sourceMappingURL=stackTrace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stackTrace.d.ts","sourceRoot":"","sources":["../../src/utils/stackTrace.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,wBAAgB,eAAe,IAAI,SAAS,GAAG,IAAI,CAqFlD"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Stack trace parsing utilities for Advanced Logger
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Parses the current stack trace to extract caller information
|
|
6
|
+
*/
|
|
7
|
+
export function parseStackTrace() {
|
|
8
|
+
try {
|
|
9
|
+
const stack = new Error().stack;
|
|
10
|
+
if (!stack) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const lines = stack.split('\n').filter(line => line.trim());
|
|
14
|
+
// Find the first caller that's not from Logger methods
|
|
15
|
+
for (let i = 1; i < lines.length; i++) {
|
|
16
|
+
const line = lines[i];
|
|
17
|
+
if (!line) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
// Skip if line contains Logger methods or parseStackTrace
|
|
21
|
+
if (line.includes('parseStackTrace') ||
|
|
22
|
+
line.includes('Logger.') ||
|
|
23
|
+
line.includes('.log(') ||
|
|
24
|
+
line.includes('createStyledOutput')) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
// Parse different stack trace formats
|
|
28
|
+
let match;
|
|
29
|
+
// Chrome format: "at functionName (file:line:column)" or "at file:line:column"
|
|
30
|
+
const chromeMatch = line.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);
|
|
31
|
+
if (chromeMatch) {
|
|
32
|
+
match = chromeMatch;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// Firefox format: "functionName@file:line:column"
|
|
36
|
+
const firefoxMatch = line.match(/(.+?)@(.+?):(\d+):(\d+)$/);
|
|
37
|
+
if (firefoxMatch) {
|
|
38
|
+
match = firefoxMatch;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// Safari/other formats
|
|
42
|
+
const safariMatch = line.match(/(\S+)?@(.+?):(\d+):(\d+)$/);
|
|
43
|
+
if (safariMatch) {
|
|
44
|
+
match = safariMatch;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (!match) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const [, functionName, file, lineStr, columnStr] = match;
|
|
52
|
+
if (!file) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
// Process file path - remove query params and get filename
|
|
56
|
+
const fileParts = file.split('/');
|
|
57
|
+
const fileName = fileParts[fileParts.length - 1];
|
|
58
|
+
if (!fileName) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const cleanFileName = fileName.split('?')[0];
|
|
62
|
+
// Parse line and column numbers
|
|
63
|
+
const lineNum = lineStr ? parseInt(lineStr, 10) : 0;
|
|
64
|
+
const columnNum = columnStr ? parseInt(columnStr, 10) : 0;
|
|
65
|
+
// Clean function name
|
|
66
|
+
const cleanFunction = functionName && functionName.trim()
|
|
67
|
+
? functionName.trim()
|
|
68
|
+
: undefined;
|
|
69
|
+
return {
|
|
70
|
+
file: cleanFileName ? cleanFileName : 'unknown',
|
|
71
|
+
line: lineNum,
|
|
72
|
+
column: columnNum,
|
|
73
|
+
function: cleanFunction
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Timestamp utilities for Advanced Logger
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Formats the timestamp using modern Date API
|
|
6
|
+
*/
|
|
7
|
+
export declare function formatTimestamp(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Parse relative time strings like "2h", "30m", "1d" into milliseconds
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseRelativeTime(timeStr: string): number;
|
|
12
|
+
/**
|
|
13
|
+
* Parse time input which can be Date, ISO string, or relative time
|
|
14
|
+
*/
|
|
15
|
+
export declare function parseTimeInput(input: Date | string | number): Date;
|
|
16
|
+
/**
|
|
17
|
+
* Format timestamp for display in different contexts
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatDisplayTime(date: Date, format?: 'short' | 'full' | 'time-only'): string;
|
|
20
|
+
//# sourceMappingURL=timestamps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamps.d.ts","sourceRoot":"","sources":["../../src/utils/timestamps.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAQxC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAUzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CA2BlE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAE,OAAO,GAAG,MAAM,GAAG,WAAqB,GAAG,MAAM,CAUtG"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Timestamp utilities for Advanced Logger
|
|
3
|
+
*/
|
|
4
|
+
import { TIME_UNITS } from '../constants.js';
|
|
5
|
+
/**
|
|
6
|
+
* Formats the timestamp using modern Date API
|
|
7
|
+
*/
|
|
8
|
+
export function formatTimestamp() {
|
|
9
|
+
try {
|
|
10
|
+
// Use modern Temporal API if available, fallback to Date
|
|
11
|
+
const now = new Date();
|
|
12
|
+
return now.toISOString();
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return new Date().toISOString();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parse relative time strings like "2h", "30m", "1d" into milliseconds
|
|
20
|
+
*/
|
|
21
|
+
export function parseRelativeTime(timeStr) {
|
|
22
|
+
const match = timeStr.match(/^(\d+)(ms|s|m|h|d)$/);
|
|
23
|
+
if (!match) {
|
|
24
|
+
throw new Error(`Invalid time format: ${timeStr}. Use format like "2h", "30m", "1d"`);
|
|
25
|
+
}
|
|
26
|
+
const [, amount, unit] = match;
|
|
27
|
+
const multiplier = TIME_UNITS[unit];
|
|
28
|
+
return parseInt(amount || '0', 10) * multiplier;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Parse time input which can be Date, ISO string, or relative time
|
|
32
|
+
*/
|
|
33
|
+
export function parseTimeInput(input) {
|
|
34
|
+
if (input instanceof Date) {
|
|
35
|
+
return input;
|
|
36
|
+
}
|
|
37
|
+
if (typeof input === 'number') {
|
|
38
|
+
// Assume hours ago
|
|
39
|
+
return new Date(Date.now() - input * TIME_UNITS.h);
|
|
40
|
+
}
|
|
41
|
+
if (typeof input === 'string') {
|
|
42
|
+
// Try parsing as ISO date first
|
|
43
|
+
const isoDate = new Date(input);
|
|
44
|
+
if (!isNaN(isoDate.getTime())) {
|
|
45
|
+
return isoDate;
|
|
46
|
+
}
|
|
47
|
+
// Try parsing as relative time
|
|
48
|
+
try {
|
|
49
|
+
const ms = parseRelativeTime(input);
|
|
50
|
+
return new Date(Date.now() - ms);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new Error(`Invalid time format: ${input}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
throw new Error(`Unsupported time input type: ${typeof input}`);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Format timestamp for display in different contexts
|
|
60
|
+
*/
|
|
61
|
+
export function formatDisplayTime(date, format = 'short') {
|
|
62
|
+
switch (format) {
|
|
63
|
+
case 'time-only':
|
|
64
|
+
return date.toTimeString().slice(0, 8); // HH:MM:SS
|
|
65
|
+
case 'full':
|
|
66
|
+
return date.toISOString();
|
|
67
|
+
case 'short':
|
|
68
|
+
default:
|
|
69
|
+
return date.toISOString().slice(11, 23); // HH:MM:SS.mmm
|
|
70
|
+
}
|
|
71
|
+
}
|