@mks2508/better-logger 0.0.2-alpha.2 → 0.3.0
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/.claude/settings.local.json +18 -2
- 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 +783 -0
- package/CLAUDE.md +92 -1
- package/README.md +198 -490
- package/bun.lock +323 -0
- package/demo.html +9 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/Logger.d.ts +272 -0
- package/dist/Logger.d.ts.map +1 -0
- package/dist/Logger.js +680 -0
- package/dist/ScopedLogger.d.ts +126 -0
- package/dist/ScopedLogger.d.ts.map +1 -0
- package/dist/ScopedLogger.js +234 -0
- package/dist/chunks/Logger-BpeuYIxR.js +2 -0
- package/dist/chunks/Logger-BpeuYIxR.js.map +1 -0
- package/dist/chunks/Logger-Didxtr23.js +3275 -0
- package/dist/chunks/Logger-Didxtr23.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/environment-Bxbnw4pd.js +544 -0
- package/dist/chunks/environment-Bxbnw4pd.js.map +1 -0
- package/dist/chunks/environment-Dm66zOML.js +4 -0
- package/dist/chunks/environment-Dm66zOML.js.map +1 -0
- package/dist/chunks/formatting-C0riPC5_.js +95 -0
- package/dist/chunks/formatting-C0riPC5_.js.map +1 -0
- package/dist/chunks/formatting-DNCAV66-.js +2 -0
- package/dist/chunks/formatting-DNCAV66-.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 +122 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +159 -0
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +134 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +315 -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 +5 -4
- package/dist/exports.js.map +1 -1
- 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 +36 -0
- package/dist/handlers/FileLogHandler.d.ts.map +1 -0
- package/dist/handlers/FileLogHandler.js +156 -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/index.js.map +1 -1
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +139 -0
- package/dist/styling/LogStyleBuilder.d.ts +149 -0
- package/dist/styling/LogStyleBuilder.d.ts.map +1 -0
- package/dist/styling/LogStyleBuilder.js +289 -0
- package/dist/styling/SemanticStyles.d.ts +181 -0
- package/dist/styling/SemanticStyles.d.ts.map +1 -0
- package/dist/styling/SemanticStyles.js +339 -0
- package/dist/styling/SmartPresets.d.ts +25 -0
- package/dist/styling/SmartPresets.d.ts.map +1 -0
- package/dist/styling/SmartPresets.js +276 -0
- package/dist/styling/StyleBuilder.d.ts +140 -0
- package/dist/styling/StyleBuilder.d.ts.map +1 -0
- package/dist/styling/StyleBuilder.js +280 -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 +10 -0
- package/dist/styling/index.d.ts.map +1 -0
- package/dist/styling/index.js +9 -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 +6 -6
- package/dist/styling.js.map +1 -1
- package/dist/types/Logger.d.ts +268 -0
- package/dist/types/Logger.d.ts.map +1 -0
- package/dist/types/ScopedLogger.d.ts +123 -0
- package/dist/types/ScopedLogger.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 +119 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/core.d.ts +125 -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 +33 -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/LogStyleBuilder.d.ts +146 -0
- package/dist/types/styling/LogStyleBuilder.d.ts.map +1 -0
- package/dist/types/styling/SemanticStyles.d.ts +178 -0
- package/dist/types/styling/SemanticStyles.d.ts.map +1 -0
- package/dist/types/styling/SmartPresets.d.ts +22 -0
- package/dist/types/styling/SmartPresets.d.ts.map +1 -0
- package/dist/types/styling/StyleBuilder.d.ts +140 -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 +10 -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 +125 -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/environment.d.ts +47 -0
- package/dist/types/utils/environment.d.ts.map +1 -0
- package/dist/types/utils/formatting.d.ts +37 -0
- package/dist/types/utils/formatting.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/opentui-detection.d.ts +34 -0
- package/dist/types/utils/opentui-detection.d.ts.map +1 -0
- package/dist/types/utils/output.d.ts +41 -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/environment.d.ts +47 -0
- package/dist/utils/environment.d.ts.map +1 -0
- package/dist/utils/environment.js +85 -0
- package/dist/utils/formatting.d.ts +40 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/formatting.js +117 -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/opentui-detection.d.ts +34 -0
- package/dist/utils/opentui-detection.d.ts.map +1 -0
- package/dist/utils/opentui-detection.js +116 -0
- package/dist/utils/output.d.ts +44 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +150 -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/CORE.md +10 -10
- 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/simplified-api.js +124 -0
- package/examples/styling-themes.js +207 -0
- package/package.json +37 -21
- package/packages/core/package.json +57 -0
- package/packages/exports/package.json +41 -0
- package/packages/nodejs-opentui/README.md +232 -0
- package/packages/nodejs-opentui/package.json +72 -0
- package/packages/nodejs-opentui/src/LogRenderer.ts +171 -0
- package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +178 -0
- package/packages/nodejs-opentui/src/components/LogBadge.tsx +131 -0
- package/packages/nodejs-opentui/src/index.ts +133 -0
- package/packages/nodejs-opentui/src/types.ts +158 -0
- package/packages/nodejs-opentui/tsconfig.json +20 -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/auto-release-ui.ts +1329 -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/project-config.ts +260 -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 +251 -16
- package/src/ScopedLogger.ts +262 -0
- package/src/cli/CommandProcessor.ts +173 -2
- package/src/cli/commands/HistoryCommand.ts +117 -0
- package/src/cli/index.ts +12 -0
- package/src/constants.ts +84 -2
- package/src/core.ts +119 -46
- package/src/example.ts +4 -4
- package/src/exports-module.ts +1 -1
- package/src/handlers/ExportLogHandler.ts +141 -0
- package/src/handlers/FileLogHandler.ts +144 -5
- package/src/index.ts +1 -1
- package/src/main.ts +3 -3
- package/src/styling/LogStyleBuilder.ts +355 -0
- package/src/styling/SemanticStyles.ts +380 -0
- package/src/styling/SmartPresets.ts +288 -0
- package/src/styling/StyleBuilder.ts +14 -0
- package/src/styling/index.ts +16 -1
- package/src/styling-module.ts +1 -1
- package/src/types/core.ts +60 -0
- package/src/types/index.ts +6 -0
- package/src/utils/environment.ts +94 -0
- package/src/utils/formatting.ts +142 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/opentui-detection.ts +138 -0
- package/src/utils/output.ts +66 -8
- package/test-core-browser.html +237 -0
- package/test-core-node.js +63 -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 +189 -50
- 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/src/Logger.ts.backup +0 -1684
- /package/.github/{workflows → workflows-backup}/release.yml +0 -0
|
@@ -0,0 +1,3275 @@
|
|
|
1
|
+
import { g as getAdaptiveColor, A as ADAPTIVE_COLORS, b as StyleBuilder, B as BUFFER_LIMITS, d as generateLogId, e as parseTimeInput, h as formatDisplayTime, j as safeStringify, k as escapeHtml, E as EXPORT_FORMATS, D as DEFAULT_CONFIG, l as setupThemeChangeListener, p as parseStackTrace, c as createStyledOutput, f as formatTimestamp, S as StylePresets } from "./environment-Bxbnw4pd.js";
|
|
2
|
+
const THEME_PRESETS = {
|
|
3
|
+
default: {
|
|
4
|
+
debug: {
|
|
5
|
+
emoji: "🐞",
|
|
6
|
+
label: "DEBUG",
|
|
7
|
+
background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
8
|
+
color: "#ffffff",
|
|
9
|
+
border: "1px solid #667eea",
|
|
10
|
+
shadow: "0 2px 4px rgba(102, 126, 234, 0.3)"
|
|
11
|
+
},
|
|
12
|
+
info: {
|
|
13
|
+
emoji: "ℹ️",
|
|
14
|
+
label: "INFO",
|
|
15
|
+
background: "linear-gradient(135deg, #74b9ff 0%, #0984e3 100%)",
|
|
16
|
+
color: "#ffffff",
|
|
17
|
+
border: "1px solid #74b9ff",
|
|
18
|
+
shadow: "0 2px 4px rgba(116, 185, 255, 0.3)"
|
|
19
|
+
},
|
|
20
|
+
warn: {
|
|
21
|
+
emoji: "⚠️",
|
|
22
|
+
label: "WARN",
|
|
23
|
+
background: "linear-gradient(135deg, #fdcb6e 0%, #e17055 100%)",
|
|
24
|
+
color: "#2d3436",
|
|
25
|
+
border: "1px solid #fdcb6e",
|
|
26
|
+
shadow: "0 2px 4px rgba(253, 203, 110, 0.3)"
|
|
27
|
+
},
|
|
28
|
+
error: {
|
|
29
|
+
emoji: "❌",
|
|
30
|
+
label: "ERROR",
|
|
31
|
+
background: "linear-gradient(135deg, #e84393 0%, #d63031 100%)",
|
|
32
|
+
color: "#ffffff",
|
|
33
|
+
border: "1px solid #e84393",
|
|
34
|
+
shadow: "0 2px 4px rgba(232, 67, 147, 0.3)"
|
|
35
|
+
},
|
|
36
|
+
success: {
|
|
37
|
+
emoji: "✅",
|
|
38
|
+
label: "SUCCESS",
|
|
39
|
+
background: "linear-gradient(135deg, #00b894 0%, #00a085 100%)",
|
|
40
|
+
color: "#ffffff",
|
|
41
|
+
border: "1px solid #00b894",
|
|
42
|
+
shadow: "0 2px 4px rgba(0, 184, 148, 0.3)"
|
|
43
|
+
},
|
|
44
|
+
critical: {
|
|
45
|
+
emoji: "🔥",
|
|
46
|
+
label: "CRITICAL",
|
|
47
|
+
background: "linear-gradient(135deg, #ff3838 0%, #ff1744 100%)",
|
|
48
|
+
color: "#ffffff",
|
|
49
|
+
border: "2px solid #ff3838",
|
|
50
|
+
shadow: "0 4px 8px rgba(255, 56, 56, 0.5)"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
dark: {
|
|
54
|
+
debug: {
|
|
55
|
+
emoji: "🌙",
|
|
56
|
+
label: "DEBUG",
|
|
57
|
+
background: "linear-gradient(135deg, #2d3748 0%, #4a5568 100%)",
|
|
58
|
+
color: "#e2e8f0",
|
|
59
|
+
border: "1px solid #4a5568",
|
|
60
|
+
shadow: "0 2px 4px rgba(45, 55, 72, 0.8)"
|
|
61
|
+
},
|
|
62
|
+
info: {
|
|
63
|
+
emoji: "💡",
|
|
64
|
+
label: "INFO",
|
|
65
|
+
background: "linear-gradient(135deg, #1a202c 0%, #2d3748 100%)",
|
|
66
|
+
color: "#90cdf4",
|
|
67
|
+
border: "1px solid #3182ce",
|
|
68
|
+
shadow: "0 2px 4px rgba(26, 32, 44, 0.8)"
|
|
69
|
+
},
|
|
70
|
+
warn: {
|
|
71
|
+
emoji: "⚡",
|
|
72
|
+
label: "WARN",
|
|
73
|
+
background: "linear-gradient(135deg, #744210 0%, #975a16 100%)",
|
|
74
|
+
color: "#faf089",
|
|
75
|
+
border: "1px solid #d69e2e",
|
|
76
|
+
shadow: "0 2px 4px rgba(116, 66, 16, 0.8)"
|
|
77
|
+
},
|
|
78
|
+
error: {
|
|
79
|
+
emoji: "💀",
|
|
80
|
+
label: "ERROR",
|
|
81
|
+
background: "linear-gradient(135deg, #742a2a 0%, #9b2c2c 100%)",
|
|
82
|
+
color: "#feb2b2",
|
|
83
|
+
border: "1px solid #e53e3e",
|
|
84
|
+
shadow: "0 2px 4px rgba(116, 42, 42, 0.8)"
|
|
85
|
+
},
|
|
86
|
+
success: {
|
|
87
|
+
emoji: "🎯",
|
|
88
|
+
label: "SUCCESS",
|
|
89
|
+
background: "linear-gradient(135deg, #276749 0%, #2f855a 100%)",
|
|
90
|
+
color: "#9ae6b4",
|
|
91
|
+
border: "1px solid #38a169",
|
|
92
|
+
shadow: "0 2px 4px rgba(39, 103, 73, 0.8)"
|
|
93
|
+
},
|
|
94
|
+
critical: {
|
|
95
|
+
emoji: "💥",
|
|
96
|
+
label: "CRITICAL",
|
|
97
|
+
background: "linear-gradient(135deg, #1a1a1a 0%, #ff0000 100%)",
|
|
98
|
+
color: "#ffffff",
|
|
99
|
+
border: "2px solid #ff0000",
|
|
100
|
+
shadow: "0 4px 8px rgba(255, 0, 0, 0.9)"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
neon: {
|
|
104
|
+
debug: {
|
|
105
|
+
emoji: "⚡",
|
|
106
|
+
label: "DEBUG",
|
|
107
|
+
background: "linear-gradient(135deg, #0f3460 0%, #e94560 100%)",
|
|
108
|
+
color: "#00ffff",
|
|
109
|
+
border: "1px solid #00ffff",
|
|
110
|
+
shadow: "0 0 10px rgba(0, 255, 255, 0.5)"
|
|
111
|
+
},
|
|
112
|
+
info: {
|
|
113
|
+
emoji: "🔮",
|
|
114
|
+
label: "INFO",
|
|
115
|
+
background: "linear-gradient(135deg, #16213e 0%, #0f3460 100%)",
|
|
116
|
+
color: "#00ff41",
|
|
117
|
+
border: "1px solid #00ff41",
|
|
118
|
+
shadow: "0 0 10px rgba(0, 255, 65, 0.5)"
|
|
119
|
+
},
|
|
120
|
+
warn: {
|
|
121
|
+
emoji: "⚠️",
|
|
122
|
+
label: "WARN",
|
|
123
|
+
background: "linear-gradient(135deg, #533a03 0%, #e94560 100%)",
|
|
124
|
+
color: "#ffff00",
|
|
125
|
+
border: "1px solid #ffff00",
|
|
126
|
+
shadow: "0 0 10px rgba(255, 255, 0, 0.5)"
|
|
127
|
+
},
|
|
128
|
+
error: {
|
|
129
|
+
emoji: "💥",
|
|
130
|
+
label: "ERROR",
|
|
131
|
+
background: "linear-gradient(135deg, #5c0a0a 0%, #ff073a 100%)",
|
|
132
|
+
color: "#ff073a",
|
|
133
|
+
border: "1px solid #ff073a",
|
|
134
|
+
shadow: "0 0 10px rgba(255, 7, 58, 0.8)"
|
|
135
|
+
},
|
|
136
|
+
success: {
|
|
137
|
+
emoji: "✨",
|
|
138
|
+
label: "SUCCESS",
|
|
139
|
+
background: "linear-gradient(135deg, #0a5c0a 0%, #39ff14 100%)",
|
|
140
|
+
color: "#39ff14",
|
|
141
|
+
border: "1px solid #39ff14",
|
|
142
|
+
shadow: "0 0 10px rgba(57, 255, 20, 0.8)"
|
|
143
|
+
},
|
|
144
|
+
critical: {
|
|
145
|
+
emoji: "🌟",
|
|
146
|
+
label: "CRITICAL",
|
|
147
|
+
background: "linear-gradient(135deg, #000000 0%, #ff0080 100%)",
|
|
148
|
+
color: "#ff0080",
|
|
149
|
+
border: "2px solid #ff0080",
|
|
150
|
+
shadow: "0 0 20px rgba(255, 0, 128, 1)"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
minimal: {
|
|
154
|
+
debug: {
|
|
155
|
+
emoji: "",
|
|
156
|
+
label: "DEBUG",
|
|
157
|
+
background: "#f7fafc",
|
|
158
|
+
color: "#4a5568",
|
|
159
|
+
border: "1px solid #e2e8f0",
|
|
160
|
+
shadow: "none"
|
|
161
|
+
},
|
|
162
|
+
info: {
|
|
163
|
+
emoji: "",
|
|
164
|
+
label: "INFO",
|
|
165
|
+
background: "#ebf8ff",
|
|
166
|
+
color: "#2b6cb0",
|
|
167
|
+
border: "1px solid #bee3f8",
|
|
168
|
+
shadow: "none"
|
|
169
|
+
},
|
|
170
|
+
warn: {
|
|
171
|
+
emoji: "",
|
|
172
|
+
label: "WARN",
|
|
173
|
+
background: "#fffbf0",
|
|
174
|
+
color: "#c05621",
|
|
175
|
+
border: "1px solid #fed7aa",
|
|
176
|
+
shadow: "none"
|
|
177
|
+
},
|
|
178
|
+
error: {
|
|
179
|
+
emoji: "",
|
|
180
|
+
label: "ERROR",
|
|
181
|
+
background: "#fef5f5",
|
|
182
|
+
color: "#c53030",
|
|
183
|
+
border: "1px solid #fca5a5",
|
|
184
|
+
shadow: "none"
|
|
185
|
+
},
|
|
186
|
+
success: {
|
|
187
|
+
emoji: "",
|
|
188
|
+
label: "SUCCESS",
|
|
189
|
+
background: "#f0fff4",
|
|
190
|
+
color: "#2f855a",
|
|
191
|
+
border: "1px solid #9ae6b4",
|
|
192
|
+
shadow: "none"
|
|
193
|
+
},
|
|
194
|
+
critical: {
|
|
195
|
+
emoji: "",
|
|
196
|
+
label: "CRITICAL",
|
|
197
|
+
background: "#fef5f5",
|
|
198
|
+
color: "#e53e3e",
|
|
199
|
+
border: "2px solid #f56565",
|
|
200
|
+
shadow: "none"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
// Additional theme variants can be added here
|
|
204
|
+
light: {
|
|
205
|
+
debug: {
|
|
206
|
+
emoji: "🔍",
|
|
207
|
+
label: "DEBUG",
|
|
208
|
+
background: "linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%)",
|
|
209
|
+
color: "#1565c0",
|
|
210
|
+
border: "1px solid #90caf9",
|
|
211
|
+
shadow: "0 1px 3px rgba(33, 150, 243, 0.2)"
|
|
212
|
+
},
|
|
213
|
+
info: {
|
|
214
|
+
emoji: "ℹ️",
|
|
215
|
+
label: "INFO",
|
|
216
|
+
background: "linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%)",
|
|
217
|
+
color: "#7b1fa2",
|
|
218
|
+
border: "1px solid #ce93d8",
|
|
219
|
+
shadow: "0 1px 3px rgba(156, 39, 176, 0.2)"
|
|
220
|
+
},
|
|
221
|
+
warn: {
|
|
222
|
+
emoji: "⚠️",
|
|
223
|
+
label: "WARN",
|
|
224
|
+
background: "linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%)",
|
|
225
|
+
color: "#f57c00",
|
|
226
|
+
border: "1px solid #ffcc02",
|
|
227
|
+
shadow: "0 1px 3px rgba(255, 152, 0, 0.2)"
|
|
228
|
+
},
|
|
229
|
+
error: {
|
|
230
|
+
emoji: "❌",
|
|
231
|
+
label: "ERROR",
|
|
232
|
+
background: "linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%)",
|
|
233
|
+
color: "#d32f2f",
|
|
234
|
+
border: "1px solid #f44336",
|
|
235
|
+
shadow: "0 1px 3px rgba(244, 67, 54, 0.2)"
|
|
236
|
+
},
|
|
237
|
+
success: {
|
|
238
|
+
emoji: "✅",
|
|
239
|
+
label: "SUCCESS",
|
|
240
|
+
background: "linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%)",
|
|
241
|
+
color: "#388e3c",
|
|
242
|
+
border: "1px solid #4caf50",
|
|
243
|
+
shadow: "0 1px 3px rgba(76, 175, 80, 0.2)"
|
|
244
|
+
},
|
|
245
|
+
critical: {
|
|
246
|
+
emoji: "🚨",
|
|
247
|
+
label: "CRITICAL",
|
|
248
|
+
background: "linear-gradient(135deg, #fce4ec 0%, #f8bbd9 100%)",
|
|
249
|
+
color: "#c2185b",
|
|
250
|
+
border: "2px solid #e91e63",
|
|
251
|
+
shadow: "0 2px 6px rgba(233, 30, 99, 0.3)"
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
cyberpunk: {
|
|
255
|
+
debug: {
|
|
256
|
+
emoji: "🤖",
|
|
257
|
+
label: "DEBUG",
|
|
258
|
+
background: "linear-gradient(135deg, #0d1b2a 0%, #415a77 100%)",
|
|
259
|
+
color: "#00d4aa",
|
|
260
|
+
border: "1px solid #00d4aa",
|
|
261
|
+
shadow: "0 0 15px rgba(0, 212, 170, 0.4)"
|
|
262
|
+
},
|
|
263
|
+
info: {
|
|
264
|
+
emoji: "🔗",
|
|
265
|
+
label: "INFO",
|
|
266
|
+
background: "linear-gradient(135deg, #1b263b 0%, #0d1b2a 100%)",
|
|
267
|
+
color: "#00b4d8",
|
|
268
|
+
border: "1px solid #00b4d8",
|
|
269
|
+
shadow: "0 0 15px rgba(0, 180, 216, 0.4)"
|
|
270
|
+
},
|
|
271
|
+
warn: {
|
|
272
|
+
emoji: "⚡",
|
|
273
|
+
label: "WARN",
|
|
274
|
+
background: "linear-gradient(135deg, #f72585 0%, #b5179e 100%)",
|
|
275
|
+
color: "#ffff3f",
|
|
276
|
+
border: "1px solid #ffff3f",
|
|
277
|
+
shadow: "0 0 15px rgba(255, 255, 63, 0.4)"
|
|
278
|
+
},
|
|
279
|
+
error: {
|
|
280
|
+
emoji: "💀",
|
|
281
|
+
label: "ERROR",
|
|
282
|
+
background: "linear-gradient(135deg, #7209b7 0%, #480ca8 100%)",
|
|
283
|
+
color: "#ff006e",
|
|
284
|
+
border: "1px solid #ff006e",
|
|
285
|
+
shadow: "0 0 15px rgba(255, 0, 110, 0.6)"
|
|
286
|
+
},
|
|
287
|
+
success: {
|
|
288
|
+
emoji: "⚡",
|
|
289
|
+
label: "SUCCESS",
|
|
290
|
+
background: "linear-gradient(135deg, #003566 0%, #001d3d 100%)",
|
|
291
|
+
color: "#00f5ff",
|
|
292
|
+
border: "1px solid #00f5ff",
|
|
293
|
+
shadow: "0 0 15px rgba(0, 245, 255, 0.4)"
|
|
294
|
+
},
|
|
295
|
+
critical: {
|
|
296
|
+
emoji: "💥",
|
|
297
|
+
label: "CRITICAL",
|
|
298
|
+
background: "linear-gradient(135deg, #000000 0%, #ff0040 100%)",
|
|
299
|
+
color: "#ff0040",
|
|
300
|
+
border: "2px solid #ff0040",
|
|
301
|
+
shadow: "0 0 25px rgba(255, 0, 64, 0.8)"
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const BANNER_VARIANTS = {
|
|
306
|
+
simple: {
|
|
307
|
+
text: "🚀 ADVANCED LOGGER v2.0.0 - State-of-the-art Console Styling 🚀",
|
|
308
|
+
style: "background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 12px 20px; border-radius: 8px; font-weight: bold; font-size: 14px;"
|
|
309
|
+
},
|
|
310
|
+
ascii: {
|
|
311
|
+
text: `
|
|
312
|
+
___ ____ _ __ ___ _ __ _____ _____ ____ __ ___ _____ _____ _____ ____
|
|
313
|
+
/ _ \\ / __ \\| | / / / _ \\ | \\ | |/ ____| ____| _ \\ | | / _ \\ / ____| ___| _ | _ \\
|
|
314
|
+
/ /_\\ \\ / / _\` | |/ / / /_\\ \\ | \\| | | | |__ | | | | | | / / \\ \\| | __| |_ | |_| | |_) |
|
|
315
|
+
| _ || | (_| | < | _ | | . \` | | | __| | | | | | | | | | | | |_ | _| | /| _ <
|
|
316
|
+
| | | |\\ \\__,_|_|\\_\\ | | | | | |\\ | |___| |____| |_| | | |__\\ \\_/ /| |__| | |___| |\\ \\| |_) |
|
|
317
|
+
\\_| |_/ \\____/ \\_| |_/ |_| \\_|\\_____|______|____/ |_____/\\___/ \\_____|_____|_| \\_|____/
|
|
318
|
+
|
|
319
|
+
Advanced Logger v2.0.0 - Console Excellence`,
|
|
320
|
+
style: 'font-family: "Courier New", Consolas, Monaco, monospace; color: #667eea; font-size: 11px; line-height: 1.2;'
|
|
321
|
+
},
|
|
322
|
+
unicode: {
|
|
323
|
+
text: `
|
|
324
|
+
╔══════════════════════════════════════════════════════════════════════════╗
|
|
325
|
+
║ 🚀 ADVANCED LOGGER v2.0.0 ║
|
|
326
|
+
║ State-of-the-art Console Styling ║
|
|
327
|
+
╚══════════════════════════════════════════════════════════════════════════╝`,
|
|
328
|
+
style: 'font-family: "Courier New", Consolas, Monaco, monospace; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 15px; border-radius: 8px; font-size: 12px; line-height: 1.3;'
|
|
329
|
+
},
|
|
330
|
+
svg: {
|
|
331
|
+
text: " ",
|
|
332
|
+
style: `
|
|
333
|
+
background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 80'><defs><linearGradient id='grad' x1='0%' y1='0%' x2='100%' y2='0%'><stop offset='0%' style='stop-color:%23667eea'/><stop offset='100%' style='stop-color:%23764ba2'/></linearGradient></defs><rect width='100%' height='100%' fill='url(%23grad)' rx='8'/><text x='200' y='30' text-anchor='middle' fill='white' font-family='monospace' font-size='14' font-weight='bold'>🚀 ADVANCED LOGGER</text><text x='200' y='50' text-anchor='middle' fill='white' font-family='monospace' font-size='12'>State-of-the-art Console Styling</text><text x='200' y='65' text-anchor='middle' fill='white' font-family='monospace' font-size='10'>v2.0.0</text></svg>");
|
|
334
|
+
background-repeat: no-repeat;
|
|
335
|
+
background-size: 400px 80px;
|
|
336
|
+
padding: 40px 200px;
|
|
337
|
+
color: transparent;
|
|
338
|
+
display: inline-block;
|
|
339
|
+
border-radius: 8px;
|
|
340
|
+
`
|
|
341
|
+
},
|
|
342
|
+
animated: {
|
|
343
|
+
text: " 🚀 ADVANCED LOGGER v2.0.0 ",
|
|
344
|
+
style: `
|
|
345
|
+
background: linear-gradient(-45deg, #667eea, #764ba2, #667eea, #764ba2);
|
|
346
|
+
background-size: 400% 400%;
|
|
347
|
+
color: white;
|
|
348
|
+
padding: 15px 25px;
|
|
349
|
+
border-radius: 10px;
|
|
350
|
+
font-weight: bold;
|
|
351
|
+
font-size: 14px;
|
|
352
|
+
font-family: monospace;
|
|
353
|
+
animation: gradientShift 3s ease infinite;
|
|
354
|
+
display: inline-block;
|
|
355
|
+
`
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
const THEME_BANNERS = {
|
|
359
|
+
default: {
|
|
360
|
+
simple: "🚀 ADVANCED LOGGER v2.0.0 - State-of-the-art Console Styling 🚀",
|
|
361
|
+
style: "background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 12px 20px; border-radius: 8px; font-weight: bold;"
|
|
362
|
+
},
|
|
363
|
+
dark: {
|
|
364
|
+
simple: "🌙 ADVANCED LOGGER v2.0.0 - Dark Mode Console Excellence 🌙",
|
|
365
|
+
style: "background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%); color: #e2e8f0; padding: 12px 20px; border-radius: 8px; font-weight: bold; border: 1px solid #4a5568;"
|
|
366
|
+
},
|
|
367
|
+
neon: {
|
|
368
|
+
simple: "⚡ ADVANCED LOGGER v2.0.0 - Cyberpunk Console Experience ⚡",
|
|
369
|
+
style: "background: linear-gradient(135deg, #0f3460 0%, #e94560 100%); color: #00ffff; padding: 12px 20px; border-radius: 8px; font-weight: bold; text-shadow: 0 0 10px #00ffff;"
|
|
370
|
+
},
|
|
371
|
+
minimal: {
|
|
372
|
+
simple: "ADVANCED LOGGER v2.0.0 - Clean Console Styling",
|
|
373
|
+
style: "background: #f7fafc; color: #2d3748; padding: 8px 16px; border: 1px solid #e2e8f0; border-radius: 4px; font-weight: 500;"
|
|
374
|
+
},
|
|
375
|
+
light: {
|
|
376
|
+
simple: "☀️ ADVANCED LOGGER v2.0.0 - Bright Console Styling ☀️",
|
|
377
|
+
style: "background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%); color: #495057; padding: 12px 20px; border-radius: 8px; font-weight: bold; border: 1px solid #dee2e6;"
|
|
378
|
+
},
|
|
379
|
+
cyberpunk: {
|
|
380
|
+
simple: "🤖 ADVANCED LOGGER v2.0.0 - Neural Console Interface 🤖",
|
|
381
|
+
style: "background: linear-gradient(135deg, #0d1b2a 0%, #415a77 100%); color: #00d4aa; padding: 12px 20px; border-radius: 8px; font-weight: bold; text-shadow: 0 0 10px #00d4aa; border: 1px solid #00d4aa;"
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
function detectBannerCapabilities() {
|
|
385
|
+
const userAgent = navigator.userAgent;
|
|
386
|
+
const isChrome = /Chrome/.test(userAgent);
|
|
387
|
+
const isFirefox = /Firefox/.test(userAgent);
|
|
388
|
+
const isSafari = /Safari/.test(userAgent) && !/Chrome/.test(userAgent);
|
|
389
|
+
const supportsSVG = !!document.createElementNS && !!document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect;
|
|
390
|
+
const supportsAnimations = typeof document !== "undefined" && "animationName" in document.createElement("div").style;
|
|
391
|
+
if (supportsAnimations && isChrome) {
|
|
392
|
+
return "animated";
|
|
393
|
+
} else if (supportsSVG && (isChrome || isFirefox)) {
|
|
394
|
+
return "svg";
|
|
395
|
+
} else if (isChrome || isFirefox) {
|
|
396
|
+
return "unicode";
|
|
397
|
+
} else if (isSafari) {
|
|
398
|
+
return "ascii";
|
|
399
|
+
}
|
|
400
|
+
return "simple";
|
|
401
|
+
}
|
|
402
|
+
function displayInitBanner(bannerType) {
|
|
403
|
+
const selectedType = bannerType || detectBannerCapabilities();
|
|
404
|
+
const banner = BANNER_VARIANTS[selectedType];
|
|
405
|
+
if (selectedType === "animated") {
|
|
406
|
+
const style = document.createElement("style");
|
|
407
|
+
style.textContent = `
|
|
408
|
+
@keyframes gradientShift {
|
|
409
|
+
0% { background-position: 0% 50%; }
|
|
410
|
+
50% { background-position: 100% 50%; }
|
|
411
|
+
100% { background-position: 0% 50%; }
|
|
412
|
+
}
|
|
413
|
+
`;
|
|
414
|
+
document.head.appendChild(style);
|
|
415
|
+
}
|
|
416
|
+
console.log(`%c${banner.text}`, banner.style);
|
|
417
|
+
const features = [
|
|
418
|
+
"🎨 Advanced CSS Console Styling",
|
|
419
|
+
"📍 Automatic Stack Trace Parsing",
|
|
420
|
+
"🔧 Scoped Loggers & Prefixes",
|
|
421
|
+
"⚡ Performance Timers",
|
|
422
|
+
"🎯 Verbosity Filtering",
|
|
423
|
+
"🔌 Extensible Handlers",
|
|
424
|
+
"📱 Modern TypeScript Patterns",
|
|
425
|
+
"📤 Export & Clipboard Support"
|
|
426
|
+
];
|
|
427
|
+
console.group(`%c✨ Features`, "background: #f8f9fa; color: #495057; padding: 4px 8px; border-radius: 4px; font-weight: bold;");
|
|
428
|
+
features.forEach((feature) => {
|
|
429
|
+
console.log(`%c${feature}`, "color: #6c757d; font-size: 13px;");
|
|
430
|
+
});
|
|
431
|
+
console.groupEnd();
|
|
432
|
+
console.log("");
|
|
433
|
+
}
|
|
434
|
+
class BaseStyler {
|
|
435
|
+
builder;
|
|
436
|
+
constructor(builder = new StyleBuilder()) {
|
|
437
|
+
this.builder = builder;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Primary brand color (typically blue)
|
|
441
|
+
*/
|
|
442
|
+
primary() {
|
|
443
|
+
return this.color("#007bff");
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Secondary color (typically gray)
|
|
447
|
+
*/
|
|
448
|
+
secondary() {
|
|
449
|
+
return this.color("#6c757d");
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Accent color for highlights
|
|
453
|
+
*/
|
|
454
|
+
accent() {
|
|
455
|
+
return this.color("#17a2b8");
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Muted/subtle color - automatically adaptive
|
|
459
|
+
*/
|
|
460
|
+
muted() {
|
|
461
|
+
const mutedColors = { light: "#6c757d", dark: "#a0aec0" };
|
|
462
|
+
return this.color(getAdaptiveColor(mutedColors));
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Success color (green)
|
|
466
|
+
*/
|
|
467
|
+
success() {
|
|
468
|
+
return this.color("#28a745");
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Warning color (yellow/orange)
|
|
472
|
+
*/
|
|
473
|
+
warning() {
|
|
474
|
+
return this.color("#ffc107");
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Danger/error color (red)
|
|
478
|
+
*/
|
|
479
|
+
danger() {
|
|
480
|
+
return this.color("#dc3545");
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Monospace font family
|
|
484
|
+
*/
|
|
485
|
+
mono() {
|
|
486
|
+
this.builder.font('Monaco, Consolas, "Courier New", monospace');
|
|
487
|
+
return this;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* System font family
|
|
491
|
+
*/
|
|
492
|
+
system() {
|
|
493
|
+
this.builder.font('system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif');
|
|
494
|
+
return this;
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Readable font optimized for text
|
|
498
|
+
*/
|
|
499
|
+
readable() {
|
|
500
|
+
this.builder.font('Georgia, "Times New Roman", serif');
|
|
501
|
+
return this;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Compact spacing
|
|
505
|
+
*/
|
|
506
|
+
compact() {
|
|
507
|
+
this.builder.padding("1px 4px").margin("0 1px");
|
|
508
|
+
return this;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Spacious layout
|
|
512
|
+
*/
|
|
513
|
+
spacious() {
|
|
514
|
+
this.builder.padding("6px 12px").margin("2px 4px");
|
|
515
|
+
return this;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Inline display
|
|
519
|
+
*/
|
|
520
|
+
inline() {
|
|
521
|
+
this.builder.display("inline-block");
|
|
522
|
+
return this;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Glass morphism effect
|
|
526
|
+
*/
|
|
527
|
+
glassmorphic() {
|
|
528
|
+
this.builder.css("backdrop-filter", "blur(10px)").css("background", "rgba(255, 255, 255, 0.1)").border("1px solid rgba(255, 255, 255, 0.2)").rounded("8px");
|
|
529
|
+
return this;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Neon glow effect
|
|
533
|
+
*/
|
|
534
|
+
neon() {
|
|
535
|
+
const neonColor = "#00ffff";
|
|
536
|
+
this.builder.color(neonColor).border(`1px solid ${neonColor}`).shadow(`0 0 10px ${neonColor}, 0 0 20px ${neonColor}`).css("text-shadow", `0 0 5px ${neonColor}`);
|
|
537
|
+
return this;
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Gradient background
|
|
541
|
+
*/
|
|
542
|
+
gradient(from = "#667eea", to = "#764ba2") {
|
|
543
|
+
this.builder.bg(`linear-gradient(135deg, ${from} 0%, ${to} 100%)`);
|
|
544
|
+
return this;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Bold text
|
|
548
|
+
*/
|
|
549
|
+
bold() {
|
|
550
|
+
this.builder.bold();
|
|
551
|
+
return this;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* Set color with automatic adaptation
|
|
555
|
+
*/
|
|
556
|
+
color(color) {
|
|
557
|
+
this.builder.color(color);
|
|
558
|
+
return this;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Build the final CSS string
|
|
562
|
+
*/
|
|
563
|
+
build() {
|
|
564
|
+
return this.builder.build();
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
class TimestampStyler extends BaseStyler {
|
|
568
|
+
/**
|
|
569
|
+
* Default timestamp style - subtle and informative
|
|
570
|
+
*/
|
|
571
|
+
default() {
|
|
572
|
+
this.muted().mono();
|
|
573
|
+
this.builder.size("11px");
|
|
574
|
+
return this;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Hide timestamp
|
|
578
|
+
*/
|
|
579
|
+
hidden() {
|
|
580
|
+
this.builder.display("none");
|
|
581
|
+
return this;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Minimal timestamp (just time, no date)
|
|
585
|
+
*/
|
|
586
|
+
minimal() {
|
|
587
|
+
this.muted().mono();
|
|
588
|
+
this.builder.size("10px").opacity(0.7);
|
|
589
|
+
return this;
|
|
590
|
+
}
|
|
591
|
+
/**
|
|
592
|
+
* Set font size
|
|
593
|
+
*/
|
|
594
|
+
size(size) {
|
|
595
|
+
this.builder.size(size);
|
|
596
|
+
return this;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
class LevelStyler extends BaseStyler {
|
|
600
|
+
/**
|
|
601
|
+
* Colorful gradient badge
|
|
602
|
+
*/
|
|
603
|
+
badge() {
|
|
604
|
+
this.builder.padding("2px 8px").rounded("4px").bold().color("#ffffff");
|
|
605
|
+
return this;
|
|
606
|
+
}
|
|
607
|
+
/**
|
|
608
|
+
* Glowing effect for dark themes
|
|
609
|
+
*/
|
|
610
|
+
glowing() {
|
|
611
|
+
return this.neon().badge();
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Minimal flat style
|
|
615
|
+
*/
|
|
616
|
+
flat() {
|
|
617
|
+
this.builder.padding("1px 6px").rounded("2px").border("1px solid currentColor").css("background", "transparent");
|
|
618
|
+
return this;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Uppercase text
|
|
622
|
+
*/
|
|
623
|
+
uppercase() {
|
|
624
|
+
this.builder.uppercase();
|
|
625
|
+
return this;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
class PrefixStyler extends BaseStyler {
|
|
629
|
+
/**
|
|
630
|
+
* Dark theme prefix
|
|
631
|
+
*/
|
|
632
|
+
dark() {
|
|
633
|
+
const prefixColors = { light: "#2d3748", dark: "#4a5568" };
|
|
634
|
+
const textColors = { light: "#e2e8f0", dark: "#f7fafc" };
|
|
635
|
+
this.builder.bg(getAdaptiveColor(prefixColors)).color(getAdaptiveColor(textColors)).padding("2px 6px").rounded("3px").bold().mono().size("11px");
|
|
636
|
+
return this;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Light theme prefix
|
|
640
|
+
*/
|
|
641
|
+
light() {
|
|
642
|
+
this.builder.bg("#f8f9fa").color("#495057").padding("2px 6px").rounded("3px").bold().mono().size("11px").border("1px solid #dee2e6");
|
|
643
|
+
return this;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* Compact prefix
|
|
647
|
+
*/
|
|
648
|
+
compact() {
|
|
649
|
+
this.builder.padding("1px 4px").size("10px").rounded("2px");
|
|
650
|
+
return this;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
class MessageStyler extends BaseStyler {
|
|
654
|
+
/**
|
|
655
|
+
* Readable message text - automatically adaptive
|
|
656
|
+
*/
|
|
657
|
+
readable() {
|
|
658
|
+
this.builder.color(getAdaptiveColor(ADAPTIVE_COLORS.messageText)).system().size("14px");
|
|
659
|
+
return this;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Code-style monospace text
|
|
663
|
+
*/
|
|
664
|
+
code() {
|
|
665
|
+
this.builder.mono().size("13px").color(getAdaptiveColor(ADAPTIVE_COLORS.messageText)).bg("rgba(0, 0, 0, 0.05)").padding("1px 4px").rounded("3px");
|
|
666
|
+
return this;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Large, prominent text
|
|
670
|
+
*/
|
|
671
|
+
large() {
|
|
672
|
+
this.builder.size("16px").color(getAdaptiveColor(ADAPTIVE_COLORS.messageText));
|
|
673
|
+
return this;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
class LocationStyler extends BaseStyler {
|
|
677
|
+
/**
|
|
678
|
+
* Subtle location info - automatically adaptive
|
|
679
|
+
*/
|
|
680
|
+
subtle() {
|
|
681
|
+
this.builder.color(getAdaptiveColor(ADAPTIVE_COLORS.location)).mono().size("11px").opacity(0.7);
|
|
682
|
+
return this;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Hide location info
|
|
686
|
+
*/
|
|
687
|
+
hidden() {
|
|
688
|
+
this.builder.display("none");
|
|
689
|
+
return this;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Clickable style (for IDE integration)
|
|
693
|
+
*/
|
|
694
|
+
clickable() {
|
|
695
|
+
this.subtle();
|
|
696
|
+
this.builder.css("text-decoration", "underline").cursor("pointer");
|
|
697
|
+
return this;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
class LogStyleBuilder {
|
|
701
|
+
logStyles = {};
|
|
702
|
+
logger;
|
|
703
|
+
constructor(logger) {
|
|
704
|
+
this.logger = logger;
|
|
705
|
+
}
|
|
706
|
+
/**
|
|
707
|
+
* Configure timestamp styling
|
|
708
|
+
*/
|
|
709
|
+
timestamp() {
|
|
710
|
+
return new TimestampStyleBuilderProxy(this);
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Configure level badge styling
|
|
714
|
+
*/
|
|
715
|
+
level() {
|
|
716
|
+
return new LevelStyleBuilderProxy(this);
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Configure prefix styling
|
|
720
|
+
*/
|
|
721
|
+
prefix() {
|
|
722
|
+
return new PrefixStyleBuilderProxy(this);
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* Configure message text styling
|
|
726
|
+
*/
|
|
727
|
+
message() {
|
|
728
|
+
return new MessageStyleBuilderProxy(this);
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Configure location info styling
|
|
732
|
+
*/
|
|
733
|
+
location() {
|
|
734
|
+
return new LocationStyleBuilderProxy(this);
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* Use a predefined preset
|
|
738
|
+
*/
|
|
739
|
+
usePreset(presetName) {
|
|
740
|
+
console.warn(`Preset '${presetName}' will be available in next implementation phase`);
|
|
741
|
+
return this;
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Customize with partial configuration
|
|
745
|
+
*/
|
|
746
|
+
customize(overrides) {
|
|
747
|
+
this.logStyles = { ...this.logStyles, ...overrides };
|
|
748
|
+
return this;
|
|
749
|
+
}
|
|
750
|
+
/**
|
|
751
|
+
* Set layout spacing
|
|
752
|
+
*/
|
|
753
|
+
spacing(type) {
|
|
754
|
+
if (!this.logStyles.layout) {
|
|
755
|
+
this.logStyles.layout = { spacing: type };
|
|
756
|
+
} else {
|
|
757
|
+
this.logStyles.layout.spacing = type;
|
|
758
|
+
}
|
|
759
|
+
switch (type) {
|
|
760
|
+
case "compact":
|
|
761
|
+
this.logStyles.layout.innerPadding = "1px";
|
|
762
|
+
this.logStyles.layout.outerMargin = "0px";
|
|
763
|
+
break;
|
|
764
|
+
case "spacious":
|
|
765
|
+
this.logStyles.layout.innerPadding = "4px";
|
|
766
|
+
this.logStyles.layout.outerMargin = "2px";
|
|
767
|
+
break;
|
|
768
|
+
default:
|
|
769
|
+
this.logStyles.layout.innerPadding = "2px";
|
|
770
|
+
this.logStyles.layout.outerMargin = "1px";
|
|
771
|
+
}
|
|
772
|
+
return this;
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Set backdrop filter for glassmorphism effects
|
|
776
|
+
*/
|
|
777
|
+
backdrop(filter) {
|
|
778
|
+
this.logStyles.backdrop = filter;
|
|
779
|
+
return this;
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* Set overall transparency
|
|
783
|
+
*/
|
|
784
|
+
transparency(value) {
|
|
785
|
+
this.logStyles.transparency = Math.max(0, Math.min(1, value));
|
|
786
|
+
return this;
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Apply the configured styles to the logger
|
|
790
|
+
*/
|
|
791
|
+
apply() {
|
|
792
|
+
this.logger._customLogStyles = this.logStyles;
|
|
793
|
+
console.log("Applied log styles:", this.logStyles);
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Get current configuration (for debugging)
|
|
797
|
+
*/
|
|
798
|
+
getConfig() {
|
|
799
|
+
return { ...this.logStyles };
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Internal method to update part configuration
|
|
803
|
+
*/
|
|
804
|
+
_updatePartConfig(part, styles) {
|
|
805
|
+
if (part === "layout" || part === "backdrop" || part === "transparency") {
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
if (!this.logStyles[part]) {
|
|
809
|
+
this.logStyles[part] = {};
|
|
810
|
+
}
|
|
811
|
+
this.logStyles[part].style = styles;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
class PartStyleBuilderProxy {
|
|
815
|
+
parentBuilder;
|
|
816
|
+
partName;
|
|
817
|
+
constructor(parentBuilder, partName) {
|
|
818
|
+
this.parentBuilder = parentBuilder;
|
|
819
|
+
this.partName = partName;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Return to the main builder for chaining other parts
|
|
823
|
+
*/
|
|
824
|
+
and() {
|
|
825
|
+
return this.parentBuilder;
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Apply styles and finish configuration
|
|
829
|
+
*/
|
|
830
|
+
apply() {
|
|
831
|
+
this.parentBuilder.apply();
|
|
832
|
+
}
|
|
833
|
+
/**
|
|
834
|
+
* Helper to apply styles to the parent builder
|
|
835
|
+
*/
|
|
836
|
+
applyStyles(styler) {
|
|
837
|
+
const styles = styler.build();
|
|
838
|
+
this.parentBuilder._updatePartConfig(this.partName, styles);
|
|
839
|
+
return this;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
class TimestampStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
843
|
+
constructor(parentBuilder) {
|
|
844
|
+
super(parentBuilder, "timestamp");
|
|
845
|
+
}
|
|
846
|
+
default() {
|
|
847
|
+
return this.applyStyles(new TimestampStyler().default());
|
|
848
|
+
}
|
|
849
|
+
hidden() {
|
|
850
|
+
return this.applyStyles(new TimestampStyler().hidden());
|
|
851
|
+
}
|
|
852
|
+
minimal() {
|
|
853
|
+
return this.applyStyles(new TimestampStyler().minimal());
|
|
854
|
+
}
|
|
855
|
+
muted() {
|
|
856
|
+
return this.applyStyles(new TimestampStyler().muted());
|
|
857
|
+
}
|
|
858
|
+
mono() {
|
|
859
|
+
return this.applyStyles(new TimestampStyler().mono());
|
|
860
|
+
}
|
|
861
|
+
compact() {
|
|
862
|
+
return this.applyStyles(new TimestampStyler().compact());
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
class LevelStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
866
|
+
constructor(parentBuilder) {
|
|
867
|
+
super(parentBuilder, "level");
|
|
868
|
+
}
|
|
869
|
+
badge() {
|
|
870
|
+
return this.applyStyles(new LevelStyler().badge());
|
|
871
|
+
}
|
|
872
|
+
gradient(from, to) {
|
|
873
|
+
return this.applyStyles(new LevelStyler().gradient(from, to));
|
|
874
|
+
}
|
|
875
|
+
glowing() {
|
|
876
|
+
return this.applyStyles(new LevelStyler().glowing());
|
|
877
|
+
}
|
|
878
|
+
flat() {
|
|
879
|
+
return this.applyStyles(new LevelStyler().flat());
|
|
880
|
+
}
|
|
881
|
+
bold() {
|
|
882
|
+
return this.applyStyles(new LevelStyler().bold());
|
|
883
|
+
}
|
|
884
|
+
uppercase() {
|
|
885
|
+
return this.applyStyles(new LevelStyler().uppercase());
|
|
886
|
+
}
|
|
887
|
+
neon() {
|
|
888
|
+
return this.applyStyles(new LevelStyler().neon());
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
class PrefixStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
892
|
+
constructor(parentBuilder) {
|
|
893
|
+
super(parentBuilder, "prefix");
|
|
894
|
+
}
|
|
895
|
+
dark() {
|
|
896
|
+
return this.applyStyles(new PrefixStyler().dark());
|
|
897
|
+
}
|
|
898
|
+
light() {
|
|
899
|
+
return this.applyStyles(new PrefixStyler().light());
|
|
900
|
+
}
|
|
901
|
+
compact() {
|
|
902
|
+
return this.applyStyles(new PrefixStyler().compact());
|
|
903
|
+
}
|
|
904
|
+
muted() {
|
|
905
|
+
return this.applyStyles(new PrefixStyler().muted());
|
|
906
|
+
}
|
|
907
|
+
mono() {
|
|
908
|
+
return this.applyStyles(new PrefixStyler().mono());
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
class MessageStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
912
|
+
constructor(parentBuilder) {
|
|
913
|
+
super(parentBuilder, "message");
|
|
914
|
+
}
|
|
915
|
+
readable() {
|
|
916
|
+
return this.applyStyles(new MessageStyler().readable());
|
|
917
|
+
}
|
|
918
|
+
code() {
|
|
919
|
+
return this.applyStyles(new MessageStyler().code());
|
|
920
|
+
}
|
|
921
|
+
large() {
|
|
922
|
+
return this.applyStyles(new MessageStyler().large());
|
|
923
|
+
}
|
|
924
|
+
system() {
|
|
925
|
+
return this.applyStyles(new MessageStyler().system());
|
|
926
|
+
}
|
|
927
|
+
mono() {
|
|
928
|
+
return this.applyStyles(new MessageStyler().mono());
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
class LocationStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
932
|
+
constructor(parentBuilder) {
|
|
933
|
+
super(parentBuilder, "location");
|
|
934
|
+
}
|
|
935
|
+
subtle() {
|
|
936
|
+
return this.applyStyles(new LocationStyler().subtle());
|
|
937
|
+
}
|
|
938
|
+
hidden() {
|
|
939
|
+
return this.applyStyles(new LocationStyler().hidden());
|
|
940
|
+
}
|
|
941
|
+
clickable() {
|
|
942
|
+
return this.applyStyles(new LocationStyler().clickable());
|
|
943
|
+
}
|
|
944
|
+
muted() {
|
|
945
|
+
return this.applyStyles(new LocationStyler().muted());
|
|
946
|
+
}
|
|
947
|
+
mono() {
|
|
948
|
+
return this.applyStyles(new LocationStyler().mono());
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
function createLogStyleBuilder(logger) {
|
|
952
|
+
return new LogStyleBuilder(logger);
|
|
953
|
+
}
|
|
954
|
+
const SMART_PRESETS = {
|
|
955
|
+
/**
|
|
956
|
+
* Default preset - works perfectly out-of-the-box
|
|
957
|
+
* Clean, readable, automatically adaptive to dark/light themes
|
|
958
|
+
*/
|
|
959
|
+
default: {
|
|
960
|
+
layout: {
|
|
961
|
+
spacing: "normal",
|
|
962
|
+
innerPadding: "2px",
|
|
963
|
+
outerMargin: "1px"
|
|
964
|
+
},
|
|
965
|
+
timestamp: {
|
|
966
|
+
show: true,
|
|
967
|
+
color: "auto",
|
|
968
|
+
// Automatically adaptive
|
|
969
|
+
font: "Monaco, Consolas, monospace",
|
|
970
|
+
size: "11px"
|
|
971
|
+
},
|
|
972
|
+
level: {
|
|
973
|
+
show: true,
|
|
974
|
+
style: "badge",
|
|
975
|
+
uppercase: false,
|
|
976
|
+
padding: "2px 8px"
|
|
977
|
+
},
|
|
978
|
+
prefix: {
|
|
979
|
+
show: true,
|
|
980
|
+
style: "dark",
|
|
981
|
+
// Automatically adaptive
|
|
982
|
+
padding: "2px 6px"
|
|
983
|
+
},
|
|
984
|
+
message: {
|
|
985
|
+
show: true,
|
|
986
|
+
color: "auto",
|
|
987
|
+
// Automatically adaptive
|
|
988
|
+
font: "system-ui, -apple-system, sans-serif",
|
|
989
|
+
size: "14px"
|
|
990
|
+
},
|
|
991
|
+
location: {
|
|
992
|
+
show: true,
|
|
993
|
+
color: "auto",
|
|
994
|
+
// Automatically adaptive
|
|
995
|
+
font: "Monaco, Consolas, monospace",
|
|
996
|
+
size: "11px"
|
|
997
|
+
}
|
|
998
|
+
},
|
|
999
|
+
/**
|
|
1000
|
+
* Cyberpunk preset - neon colors, glowing effects, dark theme
|
|
1001
|
+
*/
|
|
1002
|
+
cyberpunk: {
|
|
1003
|
+
layout: {
|
|
1004
|
+
spacing: "compact",
|
|
1005
|
+
innerPadding: "1px",
|
|
1006
|
+
outerMargin: "0px"
|
|
1007
|
+
},
|
|
1008
|
+
timestamp: {
|
|
1009
|
+
show: true,
|
|
1010
|
+
color: "#00ffff",
|
|
1011
|
+
font: "Monaco, Consolas, monospace",
|
|
1012
|
+
size: "10px",
|
|
1013
|
+
style: "neon"
|
|
1014
|
+
},
|
|
1015
|
+
level: {
|
|
1016
|
+
show: true,
|
|
1017
|
+
style: "glowing",
|
|
1018
|
+
uppercase: true,
|
|
1019
|
+
padding: "2px 8px"
|
|
1020
|
+
},
|
|
1021
|
+
prefix: {
|
|
1022
|
+
show: true,
|
|
1023
|
+
color: "#ff0080",
|
|
1024
|
+
background: "rgba(255, 0, 128, 0.1)",
|
|
1025
|
+
border: "1px solid #ff0080",
|
|
1026
|
+
style: "neon"
|
|
1027
|
+
},
|
|
1028
|
+
message: {
|
|
1029
|
+
show: true,
|
|
1030
|
+
color: "#00ff41",
|
|
1031
|
+
font: "Monaco, Consolas, monospace",
|
|
1032
|
+
size: "13px"
|
|
1033
|
+
},
|
|
1034
|
+
location: {
|
|
1035
|
+
show: false
|
|
1036
|
+
// Hidden for cleaner look
|
|
1037
|
+
},
|
|
1038
|
+
backdrop: "blur(2px)",
|
|
1039
|
+
transparency: 0.9
|
|
1040
|
+
},
|
|
1041
|
+
/**
|
|
1042
|
+
* Glassmorphism preset - modern blur effects, transparency
|
|
1043
|
+
*/
|
|
1044
|
+
glassmorphism: {
|
|
1045
|
+
layout: {
|
|
1046
|
+
spacing: "spacious",
|
|
1047
|
+
innerPadding: "4px",
|
|
1048
|
+
outerMargin: "2px"
|
|
1049
|
+
},
|
|
1050
|
+
timestamp: {
|
|
1051
|
+
show: true,
|
|
1052
|
+
color: "auto",
|
|
1053
|
+
font: "system-ui, sans-serif",
|
|
1054
|
+
size: "11px",
|
|
1055
|
+
style: "glassmorphic"
|
|
1056
|
+
},
|
|
1057
|
+
level: {
|
|
1058
|
+
show: true,
|
|
1059
|
+
style: "glassmorphic",
|
|
1060
|
+
uppercase: false,
|
|
1061
|
+
padding: "4px 12px"
|
|
1062
|
+
},
|
|
1063
|
+
prefix: {
|
|
1064
|
+
show: true,
|
|
1065
|
+
style: "glassmorphic",
|
|
1066
|
+
padding: "3px 8px"
|
|
1067
|
+
},
|
|
1068
|
+
message: {
|
|
1069
|
+
show: true,
|
|
1070
|
+
color: "auto",
|
|
1071
|
+
font: "system-ui, sans-serif",
|
|
1072
|
+
size: "14px"
|
|
1073
|
+
},
|
|
1074
|
+
location: {
|
|
1075
|
+
show: true,
|
|
1076
|
+
color: "auto",
|
|
1077
|
+
font: "system-ui, sans-serif",
|
|
1078
|
+
size: "11px",
|
|
1079
|
+
style: "glassmorphic"
|
|
1080
|
+
},
|
|
1081
|
+
backdrop: "blur(10px)",
|
|
1082
|
+
transparency: 0.8
|
|
1083
|
+
},
|
|
1084
|
+
/**
|
|
1085
|
+
* Minimal preset - clean, no decorations, maximum readability
|
|
1086
|
+
*/
|
|
1087
|
+
minimal: {
|
|
1088
|
+
layout: {
|
|
1089
|
+
spacing: "compact",
|
|
1090
|
+
innerPadding: "0px",
|
|
1091
|
+
outerMargin: "0px"
|
|
1092
|
+
},
|
|
1093
|
+
timestamp: {
|
|
1094
|
+
show: false
|
|
1095
|
+
// Hidden for minimal look
|
|
1096
|
+
},
|
|
1097
|
+
level: {
|
|
1098
|
+
show: true,
|
|
1099
|
+
style: "flat",
|
|
1100
|
+
uppercase: true,
|
|
1101
|
+
padding: "0px 4px",
|
|
1102
|
+
border: "none",
|
|
1103
|
+
background: "transparent"
|
|
1104
|
+
},
|
|
1105
|
+
prefix: {
|
|
1106
|
+
show: true,
|
|
1107
|
+
style: "flat",
|
|
1108
|
+
padding: "0px 4px",
|
|
1109
|
+
border: "none",
|
|
1110
|
+
background: "transparent"
|
|
1111
|
+
},
|
|
1112
|
+
message: {
|
|
1113
|
+
show: true,
|
|
1114
|
+
color: "auto",
|
|
1115
|
+
font: "system-ui, sans-serif",
|
|
1116
|
+
size: "14px"
|
|
1117
|
+
},
|
|
1118
|
+
location: {
|
|
1119
|
+
show: false
|
|
1120
|
+
// Hidden for minimal look
|
|
1121
|
+
}
|
|
1122
|
+
},
|
|
1123
|
+
/**
|
|
1124
|
+
* Debug preset - monospace, detailed, compact for development
|
|
1125
|
+
*/
|
|
1126
|
+
debug: {
|
|
1127
|
+
layout: {
|
|
1128
|
+
spacing: "compact",
|
|
1129
|
+
innerPadding: "1px",
|
|
1130
|
+
outerMargin: "0px"
|
|
1131
|
+
},
|
|
1132
|
+
timestamp: {
|
|
1133
|
+
show: true,
|
|
1134
|
+
color: "auto",
|
|
1135
|
+
font: "Monaco, Consolas, monospace",
|
|
1136
|
+
size: "10px"
|
|
1137
|
+
},
|
|
1138
|
+
level: {
|
|
1139
|
+
show: true,
|
|
1140
|
+
style: "compact",
|
|
1141
|
+
uppercase: true,
|
|
1142
|
+
padding: "1px 4px",
|
|
1143
|
+
font: "Monaco, Consolas, monospace",
|
|
1144
|
+
size: "10px"
|
|
1145
|
+
},
|
|
1146
|
+
prefix: {
|
|
1147
|
+
show: true,
|
|
1148
|
+
style: "compact",
|
|
1149
|
+
padding: "1px 4px",
|
|
1150
|
+
font: "Monaco, Consolas, monospace",
|
|
1151
|
+
size: "10px"
|
|
1152
|
+
},
|
|
1153
|
+
message: {
|
|
1154
|
+
show: true,
|
|
1155
|
+
color: "auto",
|
|
1156
|
+
font: "Monaco, Consolas, monospace",
|
|
1157
|
+
size: "12px"
|
|
1158
|
+
},
|
|
1159
|
+
location: {
|
|
1160
|
+
show: true,
|
|
1161
|
+
color: "auto",
|
|
1162
|
+
font: "Monaco, Consolas, monospace",
|
|
1163
|
+
size: "10px",
|
|
1164
|
+
style: "clickable"
|
|
1165
|
+
}
|
|
1166
|
+
},
|
|
1167
|
+
/**
|
|
1168
|
+
* Production preset - clean, essential info only
|
|
1169
|
+
*/
|
|
1170
|
+
production: {
|
|
1171
|
+
layout: {
|
|
1172
|
+
spacing: "normal",
|
|
1173
|
+
innerPadding: "2px",
|
|
1174
|
+
outerMargin: "1px"
|
|
1175
|
+
},
|
|
1176
|
+
timestamp: {
|
|
1177
|
+
show: true,
|
|
1178
|
+
color: "auto",
|
|
1179
|
+
font: "system-ui, sans-serif",
|
|
1180
|
+
size: "11px"
|
|
1181
|
+
},
|
|
1182
|
+
level: {
|
|
1183
|
+
show: true,
|
|
1184
|
+
style: "badge",
|
|
1185
|
+
uppercase: false,
|
|
1186
|
+
padding: "2px 6px"
|
|
1187
|
+
},
|
|
1188
|
+
prefix: {
|
|
1189
|
+
show: false
|
|
1190
|
+
// Hidden in production
|
|
1191
|
+
},
|
|
1192
|
+
message: {
|
|
1193
|
+
show: true,
|
|
1194
|
+
color: "auto",
|
|
1195
|
+
font: "system-ui, sans-serif",
|
|
1196
|
+
size: "14px"
|
|
1197
|
+
},
|
|
1198
|
+
location: {
|
|
1199
|
+
show: false
|
|
1200
|
+
// Hidden in production
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
};
|
|
1204
|
+
function getSmartPreset(name) {
|
|
1205
|
+
return SMART_PRESETS[name] || null;
|
|
1206
|
+
}
|
|
1207
|
+
function getAvailablePresets() {
|
|
1208
|
+
return Object.keys(SMART_PRESETS);
|
|
1209
|
+
}
|
|
1210
|
+
function hasPreset(name) {
|
|
1211
|
+
return name in SMART_PRESETS;
|
|
1212
|
+
}
|
|
1213
|
+
class ScopedLogger extends Logger {
|
|
1214
|
+
parentLogger;
|
|
1215
|
+
scopeName;
|
|
1216
|
+
badgeList = [];
|
|
1217
|
+
contextStack = [];
|
|
1218
|
+
constructor(parentLogger, scopeName, config) {
|
|
1219
|
+
super({ ...parentLogger.getConfig(), ...config });
|
|
1220
|
+
this.parentLogger = parentLogger;
|
|
1221
|
+
this.scopeName = scopeName;
|
|
1222
|
+
const parentHandlers = parentLogger.getHandlers();
|
|
1223
|
+
parentHandlers.forEach((handler) => this.addHandler(handler));
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Add badges to this scoped logger
|
|
1227
|
+
*/
|
|
1228
|
+
badges(badges) {
|
|
1229
|
+
this.badgeList = [...badges];
|
|
1230
|
+
return this;
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Add a single badge
|
|
1234
|
+
*/
|
|
1235
|
+
badge(badge) {
|
|
1236
|
+
if (!this.badgeList.includes(badge)) {
|
|
1237
|
+
this.badgeList.push(badge);
|
|
1238
|
+
}
|
|
1239
|
+
return this;
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Remove badges
|
|
1243
|
+
*/
|
|
1244
|
+
clearBadges() {
|
|
1245
|
+
this.badgeList = [];
|
|
1246
|
+
return this;
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1249
|
+
* Set style preset for this scoped logger
|
|
1250
|
+
*/
|
|
1251
|
+
style(presetName) {
|
|
1252
|
+
this.setTheme(presetName);
|
|
1253
|
+
return this;
|
|
1254
|
+
}
|
|
1255
|
+
/**
|
|
1256
|
+
* Create a temporary context that gets automatically cleaned up
|
|
1257
|
+
*/
|
|
1258
|
+
context(contextName) {
|
|
1259
|
+
return new ContextLogger(this, contextName);
|
|
1260
|
+
}
|
|
1261
|
+
/**
|
|
1262
|
+
* Override core logging to include badges
|
|
1263
|
+
*/
|
|
1264
|
+
log(level, ...args) {
|
|
1265
|
+
const badges = this.getBadgeString();
|
|
1266
|
+
const scopePrefix = this.getScopePrefix();
|
|
1267
|
+
let enhancedMessage = "";
|
|
1268
|
+
if (badges) enhancedMessage += badges + " ";
|
|
1269
|
+
if (scopePrefix) enhancedMessage += `[${scopePrefix}] `;
|
|
1270
|
+
if (args.length > 0) {
|
|
1271
|
+
enhancedMessage += String(args[0]);
|
|
1272
|
+
args[0] = enhancedMessage;
|
|
1273
|
+
}
|
|
1274
|
+
super.log(level, ...args);
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Get formatted badge string
|
|
1278
|
+
*/
|
|
1279
|
+
getBadgeString() {
|
|
1280
|
+
if (this.badgeList.length === 0) return "";
|
|
1281
|
+
return this.badgeList.map((badge) => `[${badge}]`).join("");
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Get scope prefix (includes context stack)
|
|
1285
|
+
*/
|
|
1286
|
+
getScopePrefix() {
|
|
1287
|
+
const parts = [this.scopeName, ...this.contextStack].filter(Boolean);
|
|
1288
|
+
return parts.join(":");
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Internal method to push context
|
|
1292
|
+
*/
|
|
1293
|
+
_pushContext(context) {
|
|
1294
|
+
this.contextStack.push(context);
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Internal method to pop context
|
|
1298
|
+
*/
|
|
1299
|
+
_popContext() {
|
|
1300
|
+
this.contextStack.pop();
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
class APILogger extends ScopedLogger {
|
|
1304
|
+
constructor(parentLogger, apiName, config) {
|
|
1305
|
+
super(parentLogger, `API:${apiName}`, config);
|
|
1306
|
+
this.badge("API");
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* Log slow operations
|
|
1310
|
+
*/
|
|
1311
|
+
slow(message, duration) {
|
|
1312
|
+
this.badge("SLOW");
|
|
1313
|
+
const msg = duration ? `${message} (${duration}ms)` : message;
|
|
1314
|
+
this.warn(msg);
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Log rate limiting
|
|
1318
|
+
*/
|
|
1319
|
+
rateLimit(message) {
|
|
1320
|
+
this.badge("RATE_LIMIT");
|
|
1321
|
+
this.warn(message);
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Log authentication issues
|
|
1325
|
+
*/
|
|
1326
|
+
auth(message) {
|
|
1327
|
+
this.badge("AUTH");
|
|
1328
|
+
this.error(message);
|
|
1329
|
+
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Log deprecation warnings
|
|
1332
|
+
*/
|
|
1333
|
+
deprecated(message) {
|
|
1334
|
+
this.badge("DEPRECATED");
|
|
1335
|
+
this.warn(message);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
class ComponentLogger extends ScopedLogger {
|
|
1339
|
+
constructor(parentLogger, componentName, config) {
|
|
1340
|
+
super(parentLogger, componentName, config);
|
|
1341
|
+
this.badge("COMPONENT");
|
|
1342
|
+
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Log lifecycle events
|
|
1345
|
+
*/
|
|
1346
|
+
lifecycle(event, message) {
|
|
1347
|
+
this.badge("LIFECYCLE");
|
|
1348
|
+
const msg = message ? `${event}: ${message}` : event;
|
|
1349
|
+
this.info(msg);
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Log state changes
|
|
1353
|
+
*/
|
|
1354
|
+
stateChange(from, to, data) {
|
|
1355
|
+
this.badge("STATE");
|
|
1356
|
+
const msg = `${from} → ${to}`;
|
|
1357
|
+
if (data) {
|
|
1358
|
+
this.info(msg, data);
|
|
1359
|
+
} else {
|
|
1360
|
+
this.info(msg);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Log prop changes
|
|
1365
|
+
*/
|
|
1366
|
+
propsChange(changes) {
|
|
1367
|
+
this.badge("PROPS");
|
|
1368
|
+
this.debug("Props changed:", changes);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
class ContextLogger {
|
|
1372
|
+
parentLogger;
|
|
1373
|
+
contextName;
|
|
1374
|
+
constructor(parentLogger, contextName) {
|
|
1375
|
+
this.parentLogger = parentLogger;
|
|
1376
|
+
this.contextName = contextName;
|
|
1377
|
+
}
|
|
1378
|
+
/**
|
|
1379
|
+
* Run a function with this context active
|
|
1380
|
+
*/
|
|
1381
|
+
run(fn) {
|
|
1382
|
+
this.parentLogger._pushContext(this.contextName);
|
|
1383
|
+
try {
|
|
1384
|
+
return fn();
|
|
1385
|
+
} finally {
|
|
1386
|
+
this.parentLogger._popContext();
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
/**
|
|
1390
|
+
* Run an async function with this context active
|
|
1391
|
+
*/
|
|
1392
|
+
async runAsync(fn) {
|
|
1393
|
+
this.parentLogger._pushContext(this.contextName);
|
|
1394
|
+
try {
|
|
1395
|
+
return await fn();
|
|
1396
|
+
} finally {
|
|
1397
|
+
this.parentLogger._popContext();
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Start the context (manual mode)
|
|
1402
|
+
*/
|
|
1403
|
+
start() {
|
|
1404
|
+
this.parentLogger._pushContext(this.contextName);
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* End the context (manual mode)
|
|
1408
|
+
*/
|
|
1409
|
+
end() {
|
|
1410
|
+
this.parentLogger._popContext();
|
|
1411
|
+
}
|
|
1412
|
+
// Delegate logging methods to parent with context
|
|
1413
|
+
debug(...args) {
|
|
1414
|
+
this.parentLogger.debug(...args);
|
|
1415
|
+
}
|
|
1416
|
+
info(...args) {
|
|
1417
|
+
this.parentLogger.info(...args);
|
|
1418
|
+
}
|
|
1419
|
+
warn(...args) {
|
|
1420
|
+
this.parentLogger.warn(...args);
|
|
1421
|
+
}
|
|
1422
|
+
error(...args) {
|
|
1423
|
+
this.parentLogger.error(...args);
|
|
1424
|
+
}
|
|
1425
|
+
success(...args) {
|
|
1426
|
+
this.parentLogger.success(...args);
|
|
1427
|
+
}
|
|
1428
|
+
critical(...args) {
|
|
1429
|
+
this.parentLogger.critical(...args);
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
class ExportLogHandler {
|
|
1433
|
+
buffer = [];
|
|
1434
|
+
maxSize;
|
|
1435
|
+
groupDepth = 0;
|
|
1436
|
+
currentGroup;
|
|
1437
|
+
constructor(maxSize = BUFFER_LIMITS.DEFAULT_SIZE) {
|
|
1438
|
+
this.maxSize = Math.min(Math.max(maxSize, BUFFER_LIMITS.MIN_SIZE), BUFFER_LIMITS.MAX_SIZE);
|
|
1439
|
+
}
|
|
1440
|
+
/**
|
|
1441
|
+
* Handle incoming log and store in buffer
|
|
1442
|
+
*/
|
|
1443
|
+
handle(level, message, args, metadata) {
|
|
1444
|
+
const entry = {
|
|
1445
|
+
id: generateLogId(),
|
|
1446
|
+
timestamp: metadata.timestamp,
|
|
1447
|
+
level,
|
|
1448
|
+
prefix: metadata.prefix,
|
|
1449
|
+
message,
|
|
1450
|
+
args,
|
|
1451
|
+
location: metadata.stackInfo,
|
|
1452
|
+
groupInfo: this.groupDepth > 0 ? {
|
|
1453
|
+
depth: this.groupDepth,
|
|
1454
|
+
groupName: this.currentGroup
|
|
1455
|
+
} : void 0
|
|
1456
|
+
};
|
|
1457
|
+
this.buffer.push(entry);
|
|
1458
|
+
if (this.buffer.length > this.maxSize) {
|
|
1459
|
+
this.buffer.shift();
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Set group tracking for nested logs
|
|
1464
|
+
*/
|
|
1465
|
+
setGroupInfo(depth, groupName) {
|
|
1466
|
+
this.groupDepth = depth;
|
|
1467
|
+
this.currentGroup = groupName;
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* Get buffer statistics
|
|
1471
|
+
*/
|
|
1472
|
+
getBufferStats() {
|
|
1473
|
+
const levelCounts = this.buffer.reduce((acc, entry) => {
|
|
1474
|
+
const currentCount = acc[entry.level] ? acc[entry.level] : 0;
|
|
1475
|
+
acc[entry.level] = currentCount + 1;
|
|
1476
|
+
return acc;
|
|
1477
|
+
}, {});
|
|
1478
|
+
let oldestLog;
|
|
1479
|
+
let newestLog;
|
|
1480
|
+
if (this.buffer.length > 0) {
|
|
1481
|
+
const firstEntry = this.buffer[0];
|
|
1482
|
+
const lastEntry = this.buffer[this.buffer.length - 1];
|
|
1483
|
+
if (firstEntry && firstEntry.timestamp) {
|
|
1484
|
+
oldestLog = new Date(firstEntry.timestamp);
|
|
1485
|
+
}
|
|
1486
|
+
if (lastEntry && lastEntry.timestamp) {
|
|
1487
|
+
newestLog = new Date(lastEntry.timestamp);
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
return {
|
|
1491
|
+
size: this.buffer.length,
|
|
1492
|
+
maxSize: this.maxSize,
|
|
1493
|
+
usage: this.buffer.length / this.maxSize * 100,
|
|
1494
|
+
oldestLog,
|
|
1495
|
+
newestLog,
|
|
1496
|
+
levelCounts: {
|
|
1497
|
+
debug: levelCounts.debug ? levelCounts.debug : 0,
|
|
1498
|
+
info: levelCounts.info ? levelCounts.info : 0,
|
|
1499
|
+
warn: levelCounts.warn ? levelCounts.warn : 0,
|
|
1500
|
+
error: levelCounts.error ? levelCounts.error : 0,
|
|
1501
|
+
critical: levelCounts.critical ? levelCounts.critical : 0
|
|
1502
|
+
}
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1505
|
+
/**
|
|
1506
|
+
* Clear the buffer
|
|
1507
|
+
*/
|
|
1508
|
+
clearBuffer() {
|
|
1509
|
+
this.buffer = [];
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Set buffer size (with limits)
|
|
1513
|
+
*/
|
|
1514
|
+
setBufferSize(size) {
|
|
1515
|
+
this.maxSize = Math.min(Math.max(size, BUFFER_LIMITS.MIN_SIZE), BUFFER_LIMITS.MAX_SIZE);
|
|
1516
|
+
if (this.buffer.length > this.maxSize) {
|
|
1517
|
+
this.buffer = this.buffer.slice(-this.maxSize);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
/**
|
|
1521
|
+
* Filter logs based on criteria
|
|
1522
|
+
*/
|
|
1523
|
+
filterLogs(filters = {}) {
|
|
1524
|
+
let filtered = [...this.buffer];
|
|
1525
|
+
if (filters.levels?.length) {
|
|
1526
|
+
filtered = filtered.filter((entry) => filters.levels.includes(entry.level));
|
|
1527
|
+
}
|
|
1528
|
+
if (filters.prefixes?.length) {
|
|
1529
|
+
filtered = filtered.filter(
|
|
1530
|
+
(entry) => entry.prefix && filters.prefixes.includes(entry.prefix)
|
|
1531
|
+
);
|
|
1532
|
+
}
|
|
1533
|
+
if (filters.excludePrefixes?.length) {
|
|
1534
|
+
filtered = filtered.filter(
|
|
1535
|
+
(entry) => !entry.prefix || !filters.excludePrefixes.includes(entry.prefix)
|
|
1536
|
+
);
|
|
1537
|
+
}
|
|
1538
|
+
if (filters.since) {
|
|
1539
|
+
const sinceDate = parseTimeInput(filters.since);
|
|
1540
|
+
filtered = filtered.filter((entry) => new Date(entry.timestamp) >= sinceDate);
|
|
1541
|
+
}
|
|
1542
|
+
if (filters.until) {
|
|
1543
|
+
const untilDate = parseTimeInput(filters.until);
|
|
1544
|
+
filtered = filtered.filter((entry) => new Date(entry.timestamp) <= untilDate);
|
|
1545
|
+
}
|
|
1546
|
+
if (filters.withStackTrace) {
|
|
1547
|
+
filtered = filtered.filter((entry) => entry.location);
|
|
1548
|
+
}
|
|
1549
|
+
if (filters.errorsOnly) {
|
|
1550
|
+
filtered = filtered.filter((entry) => entry.level === "error" || entry.level === "critical");
|
|
1551
|
+
}
|
|
1552
|
+
if (filters.search) {
|
|
1553
|
+
const searchTerm = filters.search.toLowerCase();
|
|
1554
|
+
filtered = filtered.filter(
|
|
1555
|
+
(entry) => entry.message.toLowerCase().includes(searchTerm) || entry.args.some(
|
|
1556
|
+
(arg) => String(arg).toLowerCase().includes(searchTerm)
|
|
1557
|
+
)
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1560
|
+
if (filters.last) {
|
|
1561
|
+
filtered = filtered.slice(-filters.last);
|
|
1562
|
+
}
|
|
1563
|
+
if (filters.first) {
|
|
1564
|
+
filtered = filtered.slice(0, filters.first);
|
|
1565
|
+
}
|
|
1566
|
+
return filtered;
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* Export logs in JSON format
|
|
1570
|
+
*/
|
|
1571
|
+
exportJSON(logs, options) {
|
|
1572
|
+
const data = logs.map((entry) => ({
|
|
1573
|
+
timestamp: entry.timestamp,
|
|
1574
|
+
level: entry.level,
|
|
1575
|
+
prefix: entry.prefix,
|
|
1576
|
+
message: entry.message,
|
|
1577
|
+
...options.minimal ? {} : {
|
|
1578
|
+
args: entry.args.slice(1),
|
|
1579
|
+
location: entry.location,
|
|
1580
|
+
groupInfo: entry.groupInfo
|
|
1581
|
+
}
|
|
1582
|
+
}));
|
|
1583
|
+
return options.compact ? JSON.stringify(data) : JSON.stringify(data, null, 2);
|
|
1584
|
+
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Export logs in CSV format
|
|
1587
|
+
*/
|
|
1588
|
+
exportCSV(logs, options) {
|
|
1589
|
+
const headers = options.minimal ? ["Timestamp", "Level", "Prefix", "Message"] : ["Timestamp", "Level", "Prefix", "Message", "File", "Line", "Args"];
|
|
1590
|
+
const rows = logs.map((entry) => {
|
|
1591
|
+
const baseRow = [
|
|
1592
|
+
formatDisplayTime(new Date(entry.timestamp), "full"),
|
|
1593
|
+
entry.level.toUpperCase(),
|
|
1594
|
+
entry.prefix || "",
|
|
1595
|
+
`"${entry.message.replace(/"/g, '""')}"`
|
|
1596
|
+
];
|
|
1597
|
+
if (!options.minimal) {
|
|
1598
|
+
baseRow.push(
|
|
1599
|
+
entry.location?.file || "",
|
|
1600
|
+
entry.location?.line?.toString() || "",
|
|
1601
|
+
`"${safeStringify(entry.args.slice(1)).replace(/"/g, '""')}"`
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
return baseRow;
|
|
1605
|
+
});
|
|
1606
|
+
return [headers.join(","), ...rows.map((row) => row.join(","))].join("\n");
|
|
1607
|
+
}
|
|
1608
|
+
/**
|
|
1609
|
+
* Export logs in Markdown format
|
|
1610
|
+
*/
|
|
1611
|
+
exportMarkdown(logs, options) {
|
|
1612
|
+
const now = /* @__PURE__ */ new Date();
|
|
1613
|
+
let content = `# Log Export - ${formatDisplayTime(now, "full")}
|
|
1614
|
+
|
|
1615
|
+
`;
|
|
1616
|
+
if (!options.minimal) {
|
|
1617
|
+
const summary = this.getBufferStats();
|
|
1618
|
+
content += `## Summary
|
|
1619
|
+
`;
|
|
1620
|
+
content += `- **Total logs**: ${logs.length}
|
|
1621
|
+
`;
|
|
1622
|
+
content += `- **Errors**: ${summary.levelCounts.error + summary.levelCounts.critical}
|
|
1623
|
+
`;
|
|
1624
|
+
content += `- **Warnings**: ${summary.levelCounts.warn}
|
|
1625
|
+
|
|
1626
|
+
`;
|
|
1627
|
+
}
|
|
1628
|
+
if (options.groupBy === "level") {
|
|
1629
|
+
const grouped = logs.reduce((acc, entry) => {
|
|
1630
|
+
const level = entry.level;
|
|
1631
|
+
if (!acc[level]) {
|
|
1632
|
+
acc[level] = [];
|
|
1633
|
+
}
|
|
1634
|
+
const levelArray = acc[level];
|
|
1635
|
+
if (levelArray) {
|
|
1636
|
+
levelArray.push(entry);
|
|
1637
|
+
}
|
|
1638
|
+
return acc;
|
|
1639
|
+
}, {});
|
|
1640
|
+
Object.entries(grouped).forEach(([level, entries]) => {
|
|
1641
|
+
const emoji = this.getLevelEmoji(level);
|
|
1642
|
+
content += `## ${emoji} ${level.toUpperCase()} (${entries.length})
|
|
1643
|
+
|
|
1644
|
+
`;
|
|
1645
|
+
entries.forEach((entry) => {
|
|
1646
|
+
const time = formatDisplayTime(new Date(entry.timestamp), "time-only");
|
|
1647
|
+
const location = entry.location ? ` (${entry.location.file}:${entry.location.line})` : "";
|
|
1648
|
+
const prefix = entry.prefix ? ` **${entry.prefix}**:` : "";
|
|
1649
|
+
content += `- \`${time}\`${prefix} ${entry.message}${location}
|
|
1650
|
+
`;
|
|
1651
|
+
});
|
|
1652
|
+
content += "\n";
|
|
1653
|
+
});
|
|
1654
|
+
} else {
|
|
1655
|
+
content += "## Logs\n\n";
|
|
1656
|
+
logs.forEach((entry) => {
|
|
1657
|
+
const time = formatDisplayTime(new Date(entry.timestamp), "time-only");
|
|
1658
|
+
const emoji = this.getLevelEmoji(entry.level);
|
|
1659
|
+
const location = entry.location ? ` (${entry.location.file}:${entry.location.line})` : "";
|
|
1660
|
+
const prefix = entry.prefix ? ` **${entry.prefix}**:` : "";
|
|
1661
|
+
content += `- \`${time}\` ${emoji}${prefix} ${entry.message}${location}
|
|
1662
|
+
`;
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
return content;
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
* Export logs in plain text format
|
|
1669
|
+
*/
|
|
1670
|
+
exportPlain(logs, options) {
|
|
1671
|
+
return logs.map((entry) => {
|
|
1672
|
+
const time = formatDisplayTime(new Date(entry.timestamp), options.minimal ? "time-only" : "short");
|
|
1673
|
+
const level = entry.level.toUpperCase().padEnd(8);
|
|
1674
|
+
const prefix = entry.prefix ? `[${entry.prefix}] ` : "";
|
|
1675
|
+
const location = !options.minimal && entry.location ? ` (${entry.location.file}:${entry.location.line})` : "";
|
|
1676
|
+
return `${time} ${level} ${prefix}${entry.message}${location}`;
|
|
1677
|
+
}).join("\n");
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* Export logs in HTML format
|
|
1681
|
+
*/
|
|
1682
|
+
exportHTML(logs, _options) {
|
|
1683
|
+
const title = `Log Export - ${formatDisplayTime(/* @__PURE__ */ new Date(), "full")}`;
|
|
1684
|
+
let html = `<!DOCTYPE html>
|
|
1685
|
+
<html lang="en">
|
|
1686
|
+
<head>
|
|
1687
|
+
<meta charset="UTF-8">
|
|
1688
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1689
|
+
<title>${title}</title>
|
|
1690
|
+
<style>
|
|
1691
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 20px; line-height: 1.6; }
|
|
1692
|
+
.header { border-bottom: 2px solid #ddd; padding-bottom: 20px; margin-bottom: 20px; }
|
|
1693
|
+
.log-entry { margin: 5px 0; padding: 8px; border-radius: 4px; font-family: 'Monaco', 'Consolas', monospace; }
|
|
1694
|
+
.timestamp { color: #666; font-size: 0.9em; }
|
|
1695
|
+
.level { font-weight: bold; padding: 2px 6px; border-radius: 3px; margin: 0 8px; }
|
|
1696
|
+
.prefix { background: #2d3748; color: #e2e8f0; padding: 2px 6px; border-radius: 3px; margin: 0 8px; }
|
|
1697
|
+
.location { color: #718096; font-size: 0.9em; }
|
|
1698
|
+
.debug { background: #f0f4ff; }
|
|
1699
|
+
.info { background: #f0f9ff; }
|
|
1700
|
+
.warn { background: #fffbeb; }
|
|
1701
|
+
.error { background: #fef2f2; }
|
|
1702
|
+
.critical { background: #fef2f2; border-left: 4px solid #dc2626; }
|
|
1703
|
+
.level.debug { background: #667eea; color: white; }
|
|
1704
|
+
.level.info { background: #74b9ff; color: white; }
|
|
1705
|
+
.level.warn { background: #fdcb6e; color: #2d3436; }
|
|
1706
|
+
.level.error { background: #e84393; color: white; }
|
|
1707
|
+
.level.critical { background: #ff3838; color: white; }
|
|
1708
|
+
</style>
|
|
1709
|
+
</head>
|
|
1710
|
+
<body>
|
|
1711
|
+
<div class="header">
|
|
1712
|
+
<h1>${title}</h1>
|
|
1713
|
+
<p>Generated by Advanced Logger v2.0.0</p>
|
|
1714
|
+
</div>
|
|
1715
|
+
<div class="logs">`;
|
|
1716
|
+
logs.forEach((entry) => {
|
|
1717
|
+
const time = formatDisplayTime(new Date(entry.timestamp), "full");
|
|
1718
|
+
const location = entry.location ? ` <span class="location">(${escapeHtml(entry.location.file)}:${entry.location.line})</span>` : "";
|
|
1719
|
+
const prefix = entry.prefix ? ` <span class="prefix">${escapeHtml(entry.prefix)}</span>` : "";
|
|
1720
|
+
html += `
|
|
1721
|
+
<div class="log-entry ${entry.level}">
|
|
1722
|
+
<span class="timestamp">${time}</span>
|
|
1723
|
+
<span class="level ${entry.level}">${entry.level.toUpperCase()}</span>
|
|
1724
|
+
${prefix}
|
|
1725
|
+
<span class="message">${escapeHtml(entry.message)}</span>
|
|
1726
|
+
${location}
|
|
1727
|
+
</div>`;
|
|
1728
|
+
});
|
|
1729
|
+
html += `
|
|
1730
|
+
</div>
|
|
1731
|
+
</body>
|
|
1732
|
+
</html>`;
|
|
1733
|
+
return html;
|
|
1734
|
+
}
|
|
1735
|
+
/**
|
|
1736
|
+
* Get emoji for log level
|
|
1737
|
+
*/
|
|
1738
|
+
getLevelEmoji(level) {
|
|
1739
|
+
const emojis = {
|
|
1740
|
+
debug: "🐞",
|
|
1741
|
+
info: "ℹ️",
|
|
1742
|
+
warn: "⚠️",
|
|
1743
|
+
error: "❌",
|
|
1744
|
+
critical: "🔥"
|
|
1745
|
+
};
|
|
1746
|
+
return emojis[level] || "";
|
|
1747
|
+
}
|
|
1748
|
+
/**
|
|
1749
|
+
* Main export function
|
|
1750
|
+
*/
|
|
1751
|
+
export(format, filters = {}, options = {}) {
|
|
1752
|
+
const filteredLogs = this.filterLogs(filters);
|
|
1753
|
+
let data;
|
|
1754
|
+
switch (format) {
|
|
1755
|
+
case "json":
|
|
1756
|
+
data = this.exportJSON(filteredLogs, options);
|
|
1757
|
+
break;
|
|
1758
|
+
case "csv":
|
|
1759
|
+
data = this.exportCSV(filteredLogs, options);
|
|
1760
|
+
break;
|
|
1761
|
+
case "markdown":
|
|
1762
|
+
data = this.exportMarkdown(filteredLogs, options);
|
|
1763
|
+
break;
|
|
1764
|
+
case "plain":
|
|
1765
|
+
data = this.exportPlain(filteredLogs, options);
|
|
1766
|
+
break;
|
|
1767
|
+
case "html":
|
|
1768
|
+
data = this.exportHTML(filteredLogs, options);
|
|
1769
|
+
break;
|
|
1770
|
+
default:
|
|
1771
|
+
throw new Error(`Unsupported export format: ${format}`);
|
|
1772
|
+
}
|
|
1773
|
+
return {
|
|
1774
|
+
format,
|
|
1775
|
+
data,
|
|
1776
|
+
metadata: {
|
|
1777
|
+
totalLogs: this.buffer.length,
|
|
1778
|
+
filteredLogs: filteredLogs.length,
|
|
1779
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1780
|
+
filters,
|
|
1781
|
+
options
|
|
1782
|
+
}
|
|
1783
|
+
};
|
|
1784
|
+
}
|
|
1785
|
+
/**
|
|
1786
|
+
* Copy to clipboard with fallback
|
|
1787
|
+
*/
|
|
1788
|
+
async copyToClipboard(format, filters = {}, options = {}) {
|
|
1789
|
+
const result = this.export(format, filters, options);
|
|
1790
|
+
try {
|
|
1791
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
1792
|
+
await navigator.clipboard.writeText(result.data);
|
|
1793
|
+
return true;
|
|
1794
|
+
} else {
|
|
1795
|
+
const textArea = document.createElement("textarea");
|
|
1796
|
+
textArea.value = result.data;
|
|
1797
|
+
textArea.style.position = "fixed";
|
|
1798
|
+
textArea.style.opacity = "0";
|
|
1799
|
+
document.body.appendChild(textArea);
|
|
1800
|
+
textArea.focus();
|
|
1801
|
+
textArea.select();
|
|
1802
|
+
const success = document.execCommand("copy");
|
|
1803
|
+
document.body.removeChild(textArea);
|
|
1804
|
+
return success;
|
|
1805
|
+
}
|
|
1806
|
+
} catch (error) {
|
|
1807
|
+
console.error("Failed to copy to clipboard:", error);
|
|
1808
|
+
return false;
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
/**
|
|
1812
|
+
* Get all logs (for debugging)
|
|
1813
|
+
*/
|
|
1814
|
+
getAllLogs() {
|
|
1815
|
+
return [...this.buffer];
|
|
1816
|
+
}
|
|
1817
|
+
/**
|
|
1818
|
+
* Save export to file with download prompt
|
|
1819
|
+
*/
|
|
1820
|
+
async saveToFile(format, filters = {}, options = {}) {
|
|
1821
|
+
try {
|
|
1822
|
+
const result = this.export(format, filters, options);
|
|
1823
|
+
const blob = new Blob([result.data], {
|
|
1824
|
+
type: this.getMimeType(format)
|
|
1825
|
+
});
|
|
1826
|
+
const url = URL.createObjectURL(blob);
|
|
1827
|
+
const a = document.createElement("a");
|
|
1828
|
+
const filename = this.generateFilename(format, filters);
|
|
1829
|
+
a.href = url;
|
|
1830
|
+
a.download = filename;
|
|
1831
|
+
a.style.display = "none";
|
|
1832
|
+
document.body.appendChild(a);
|
|
1833
|
+
a.click();
|
|
1834
|
+
document.body.removeChild(a);
|
|
1835
|
+
URL.revokeObjectURL(url);
|
|
1836
|
+
return true;
|
|
1837
|
+
} catch (error) {
|
|
1838
|
+
console.error("Failed to save file:", error);
|
|
1839
|
+
return false;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
/**
|
|
1843
|
+
* Get MIME type for format
|
|
1844
|
+
*/
|
|
1845
|
+
getMimeType(format) {
|
|
1846
|
+
const mimeTypes = {
|
|
1847
|
+
json: "application/json",
|
|
1848
|
+
csv: "text/csv",
|
|
1849
|
+
markdown: "text/markdown",
|
|
1850
|
+
plain: "text/plain",
|
|
1851
|
+
html: "text/html"
|
|
1852
|
+
};
|
|
1853
|
+
return mimeTypes[format] || "text/plain";
|
|
1854
|
+
}
|
|
1855
|
+
/**
|
|
1856
|
+
* Generate filename with timestamp
|
|
1857
|
+
*/
|
|
1858
|
+
generateFilename(format, filters) {
|
|
1859
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, -5);
|
|
1860
|
+
const prefix = filters.prefixes?.length === 1 ? `_${filters.prefixes[0]}` : "";
|
|
1861
|
+
const extension = format === "markdown" ? "md" : format;
|
|
1862
|
+
return `logs${prefix}_${timestamp}.${extension}`;
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Stream logs to external endpoint
|
|
1866
|
+
*/
|
|
1867
|
+
async streamToEndpoint(endpoint, filters = {}, options = {}) {
|
|
1868
|
+
try {
|
|
1869
|
+
const logs = this.filterLogs(filters);
|
|
1870
|
+
const batchSize = options.batchSize || 100;
|
|
1871
|
+
const format = options.format || "json";
|
|
1872
|
+
for (let i = 0; i < logs.length; i += batchSize) {
|
|
1873
|
+
const batch = logs.slice(i, i + batchSize);
|
|
1874
|
+
const result = this.export(format, {}, { compact: true });
|
|
1875
|
+
const headers = {
|
|
1876
|
+
"Content-Type": "application/json"
|
|
1877
|
+
};
|
|
1878
|
+
if (options.apiKey) {
|
|
1879
|
+
headers["Authorization"] = `Bearer ${options.apiKey}`;
|
|
1880
|
+
}
|
|
1881
|
+
const response = await fetch(endpoint, {
|
|
1882
|
+
method: "POST",
|
|
1883
|
+
headers,
|
|
1884
|
+
body: JSON.stringify({
|
|
1885
|
+
logs: batch,
|
|
1886
|
+
metadata: {
|
|
1887
|
+
batchIndex: Math.floor(i / batchSize),
|
|
1888
|
+
totalBatches: Math.ceil(logs.length / batchSize),
|
|
1889
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
1890
|
+
}
|
|
1891
|
+
})
|
|
1892
|
+
});
|
|
1893
|
+
if (!response.ok) {
|
|
1894
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
return true;
|
|
1898
|
+
} catch (error) {
|
|
1899
|
+
console.error("Failed to stream logs:", error);
|
|
1900
|
+
return false;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
/**
|
|
1904
|
+
* Create export with metadata enrichment
|
|
1905
|
+
*/
|
|
1906
|
+
exportWithMetadata(format, filters = {}, options = {}) {
|
|
1907
|
+
const baseResult = this.export(format, filters, options);
|
|
1908
|
+
const bufferStats = this.getBufferStats();
|
|
1909
|
+
return {
|
|
1910
|
+
...baseResult,
|
|
1911
|
+
metadata: {
|
|
1912
|
+
...baseResult.metadata,
|
|
1913
|
+
bufferStats,
|
|
1914
|
+
performance: {
|
|
1915
|
+
memoryUsage: this.estimateMemoryUsage(),
|
|
1916
|
+
processingTime: Date.now()
|
|
1917
|
+
},
|
|
1918
|
+
system: {
|
|
1919
|
+
userAgent: typeof navigator !== "undefined" ? navigator.userAgent : "Node.js",
|
|
1920
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1921
|
+
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
1922
|
+
}
|
|
1923
|
+
}
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
/**
|
|
1927
|
+
* Estimate memory usage of buffer
|
|
1928
|
+
*/
|
|
1929
|
+
estimateMemoryUsage() {
|
|
1930
|
+
const sampleEntry = this.buffer[0];
|
|
1931
|
+
if (!sampleEntry) return 0;
|
|
1932
|
+
const sampleSize = JSON.stringify(sampleEntry).length;
|
|
1933
|
+
return sampleSize * this.buffer.length;
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
class CommandProcessor {
|
|
1937
|
+
commands = /* @__PURE__ */ new Map();
|
|
1938
|
+
aliases = /* @__PURE__ */ new Map();
|
|
1939
|
+
plugins = /* @__PURE__ */ new Map();
|
|
1940
|
+
history = [];
|
|
1941
|
+
maxHistorySize = 100;
|
|
1942
|
+
isInteractiveMode = false;
|
|
1943
|
+
/**
|
|
1944
|
+
* Register a command
|
|
1945
|
+
*/
|
|
1946
|
+
registerCommand(command) {
|
|
1947
|
+
this.commands.set(command.name, command);
|
|
1948
|
+
if (command.aliases) {
|
|
1949
|
+
for (const alias of command.aliases) {
|
|
1950
|
+
this.aliases.set(alias, command.name);
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
/**
|
|
1955
|
+
* Register a plugin
|
|
1956
|
+
*/
|
|
1957
|
+
registerPlugin(plugin, logger) {
|
|
1958
|
+
if (this.plugins.has(plugin.name)) {
|
|
1959
|
+
throw new Error(`Plugin ${plugin.name} is already registered`);
|
|
1960
|
+
}
|
|
1961
|
+
this.plugins.set(plugin.name, plugin);
|
|
1962
|
+
for (const command of plugin.commands) {
|
|
1963
|
+
this.registerCommand(command);
|
|
1964
|
+
}
|
|
1965
|
+
if (plugin.initialize && logger) {
|
|
1966
|
+
plugin.initialize(this, logger);
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Unregister a plugin
|
|
1971
|
+
*/
|
|
1972
|
+
unregisterPlugin(pluginName) {
|
|
1973
|
+
const plugin = this.plugins.get(pluginName);
|
|
1974
|
+
if (!plugin) return;
|
|
1975
|
+
for (const command of plugin.commands) {
|
|
1976
|
+
this.commands.delete(command.name);
|
|
1977
|
+
if (command.aliases) {
|
|
1978
|
+
for (const alias of command.aliases) {
|
|
1979
|
+
this.aliases.delete(alias);
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
if (plugin.cleanup) {
|
|
1984
|
+
plugin.cleanup();
|
|
1985
|
+
}
|
|
1986
|
+
this.plugins.delete(pluginName);
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Get all registered commands
|
|
1990
|
+
*/
|
|
1991
|
+
getCommands() {
|
|
1992
|
+
return Array.from(this.commands.values());
|
|
1993
|
+
}
|
|
1994
|
+
/**
|
|
1995
|
+
* Get a specific command
|
|
1996
|
+
*/
|
|
1997
|
+
getCommand(name) {
|
|
1998
|
+
let command = this.commands.get(name);
|
|
1999
|
+
if (command) return command;
|
|
2000
|
+
const aliasTarget = this.aliases.get(name);
|
|
2001
|
+
if (aliasTarget) {
|
|
2002
|
+
return this.commands.get(aliasTarget);
|
|
2003
|
+
}
|
|
2004
|
+
return void 0;
|
|
2005
|
+
}
|
|
2006
|
+
/**
|
|
2007
|
+
* Get command history
|
|
2008
|
+
*/
|
|
2009
|
+
getHistory() {
|
|
2010
|
+
return [...this.history];
|
|
2011
|
+
}
|
|
2012
|
+
/**
|
|
2013
|
+
* Clear command history
|
|
2014
|
+
*/
|
|
2015
|
+
clearHistory() {
|
|
2016
|
+
this.history = [];
|
|
2017
|
+
}
|
|
2018
|
+
/**
|
|
2019
|
+
* Get registered plugins
|
|
2020
|
+
*/
|
|
2021
|
+
getPlugins() {
|
|
2022
|
+
return Array.from(this.plugins.values());
|
|
2023
|
+
}
|
|
2024
|
+
/**
|
|
2025
|
+
* Enter interactive mode
|
|
2026
|
+
*/
|
|
2027
|
+
enterInteractiveMode(logger) {
|
|
2028
|
+
this.isInteractiveMode = true;
|
|
2029
|
+
logger.info("🔧 Interactive CLI mode activated. Type /exit to quit, /help for commands.");
|
|
2030
|
+
if (typeof window !== "undefined") {
|
|
2031
|
+
this.setupBrowserInteractiveMode(logger);
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
/**
|
|
2035
|
+
* Exit interactive mode
|
|
2036
|
+
*/
|
|
2037
|
+
exitInteractiveMode() {
|
|
2038
|
+
this.isInteractiveMode = false;
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* Setup browser interactive mode
|
|
2042
|
+
*/
|
|
2043
|
+
setupBrowserInteractiveMode(logger) {
|
|
2044
|
+
window.cli = (commandString) => {
|
|
2045
|
+
return this.processCommand(`/${commandString}`, logger);
|
|
2046
|
+
};
|
|
2047
|
+
logger.info('💡 Use cli("command") to execute CLI commands in browser console.');
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* Process a CLI command
|
|
2051
|
+
*/
|
|
2052
|
+
async processCommand(commandString, logger) {
|
|
2053
|
+
if (!commandString.startsWith("/")) {
|
|
2054
|
+
logger.error("Invalid command. Commands must start with /");
|
|
2055
|
+
this.addToHistory(commandString, false);
|
|
2056
|
+
return;
|
|
2057
|
+
}
|
|
2058
|
+
const parts = commandString.slice(1).split(" ");
|
|
2059
|
+
const commandName = parts[0] || "";
|
|
2060
|
+
const args = parts.slice(1).join(" ");
|
|
2061
|
+
const command = this.getCommand(commandName);
|
|
2062
|
+
if (!command) {
|
|
2063
|
+
logger.error(`Unknown command: ${commandName}. Type /help for available commands.`);
|
|
2064
|
+
const suggestions = this.getSuggestions(commandName);
|
|
2065
|
+
if (suggestions.length > 0) {
|
|
2066
|
+
logger.info(`📋 Did you mean: ${suggestions.slice(0, 3).join(", ")}?`);
|
|
2067
|
+
}
|
|
2068
|
+
this.addToHistory(commandString, false);
|
|
2069
|
+
return;
|
|
2070
|
+
}
|
|
2071
|
+
try {
|
|
2072
|
+
await command.execute(args || "", logger);
|
|
2073
|
+
this.addToHistory(commandString, true);
|
|
2074
|
+
} catch (error) {
|
|
2075
|
+
logger.error(`Command '${commandName}' failed:`, error);
|
|
2076
|
+
this.addToHistory(commandString, false);
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
/**
|
|
2080
|
+
* Add command to history
|
|
2081
|
+
*/
|
|
2082
|
+
addToHistory(command, success) {
|
|
2083
|
+
this.history.unshift({
|
|
2084
|
+
command,
|
|
2085
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
2086
|
+
success
|
|
2087
|
+
});
|
|
2088
|
+
if (this.history.length > this.maxHistorySize) {
|
|
2089
|
+
this.history = this.history.slice(0, this.maxHistorySize);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
/**
|
|
2093
|
+
* Get command suggestions for partial matches
|
|
2094
|
+
*/
|
|
2095
|
+
getSuggestions(partial) {
|
|
2096
|
+
const commandNames = Array.from(this.commands.keys());
|
|
2097
|
+
return commandNames.filter((name) => name.startsWith(partial));
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
class ConfigCommand {
|
|
2101
|
+
name = "config";
|
|
2102
|
+
description = "Show or update logger configuration";
|
|
2103
|
+
usage = "/config [json|key=value,...]";
|
|
2104
|
+
execute(args, logger) {
|
|
2105
|
+
if (!args) {
|
|
2106
|
+
this.showStatus(logger);
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
try {
|
|
2110
|
+
if (args.startsWith("{")) {
|
|
2111
|
+
const config = JSON.parse(args);
|
|
2112
|
+
this.applyConfig(config, logger);
|
|
2113
|
+
} else {
|
|
2114
|
+
const pairs = args.split(",").map((pair) => pair.trim().split("="));
|
|
2115
|
+
const config = {};
|
|
2116
|
+
pairs.forEach(([key, value]) => {
|
|
2117
|
+
if (key && value) {
|
|
2118
|
+
config[key.trim()] = value.trim().replace(/["']/g, "");
|
|
2119
|
+
}
|
|
2120
|
+
});
|
|
2121
|
+
this.applyConfig(config, logger);
|
|
2122
|
+
}
|
|
2123
|
+
} catch (error) {
|
|
2124
|
+
logger.error("Invalid config format. Use JSON or key=value pairs:", error);
|
|
2125
|
+
logger.info('Examples: /config {"theme":"dark"} or /config theme=neon,verbosity=debug');
|
|
2126
|
+
}
|
|
2127
|
+
}
|
|
2128
|
+
showStatus(logger) {
|
|
2129
|
+
const statusData = {
|
|
2130
|
+
theme: logger.getConfig().theme || "default",
|
|
2131
|
+
verbosity: logger.getConfig().verbosity,
|
|
2132
|
+
colors: logger.getConfig().enableColors,
|
|
2133
|
+
timestamps: logger.getConfig().enableTimestamps,
|
|
2134
|
+
stackTrace: logger.getConfig().enableStackTrace,
|
|
2135
|
+
globalPrefix: logger.getConfig().globalPrefix || "none",
|
|
2136
|
+
bannerType: logger.getConfig().bannerType || "simple",
|
|
2137
|
+
handlers: logger.getHandlers().length
|
|
2138
|
+
};
|
|
2139
|
+
logger.group("⚙️ Logger Configuration");
|
|
2140
|
+
logger.table(statusData);
|
|
2141
|
+
logger.groupEnd();
|
|
2142
|
+
}
|
|
2143
|
+
applyConfig(config, logger) {
|
|
2144
|
+
const validKeys = ["theme", "verbosity", "enableColors", "enableTimestamps", "enableStackTrace", "globalPrefix", "bannerType"];
|
|
2145
|
+
const applied = [];
|
|
2146
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
2147
|
+
if (validKeys.includes(key)) {
|
|
2148
|
+
if (key === "theme" && typeof value === "string") {
|
|
2149
|
+
logger.setTheme(value);
|
|
2150
|
+
applied.push(`${key}=${value}`);
|
|
2151
|
+
} else if (key === "bannerType" && typeof value === "string") {
|
|
2152
|
+
logger.setBannerType(value);
|
|
2153
|
+
applied.push(`${key}=${value}`);
|
|
2154
|
+
} else if (key === "verbosity") {
|
|
2155
|
+
logger.setVerbosity(value);
|
|
2156
|
+
applied.push(`${key}=${value}`);
|
|
2157
|
+
} else if (key === "globalPrefix") {
|
|
2158
|
+
logger.setGlobalPrefix(value);
|
|
2159
|
+
applied.push(`${key}=${value}`);
|
|
2160
|
+
} else {
|
|
2161
|
+
logger.updateConfig({ [key]: value });
|
|
2162
|
+
applied.push(`${key}=${value}`);
|
|
2163
|
+
}
|
|
2164
|
+
} else {
|
|
2165
|
+
logger.warn(`Invalid config key: ${key}`);
|
|
2166
|
+
}
|
|
2167
|
+
});
|
|
2168
|
+
if (applied.length > 0) {
|
|
2169
|
+
logger.success(`Configuration updated: ${applied.join(", ")}`);
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
class ThemesCommand {
|
|
2174
|
+
name = "themes";
|
|
2175
|
+
description = "Show available theme presets";
|
|
2176
|
+
usage = "/themes";
|
|
2177
|
+
execute(_args, logger) {
|
|
2178
|
+
logger.group("🎨 Available Themes");
|
|
2179
|
+
Object.keys(THEME_PRESETS).forEach((themeName) => {
|
|
2180
|
+
const preview = THEME_PRESETS[themeName];
|
|
2181
|
+
const previewStyle = new StyleBuilder().bg(preview.info.background).color(preview.info.color).padding("4px 8px").rounded("4px").border(preview.info.border).build();
|
|
2182
|
+
console.log(`%c${themeName}`, previewStyle, `- ${themeName} theme preview`);
|
|
2183
|
+
});
|
|
2184
|
+
logger.groupEnd();
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
class BannersCommand {
|
|
2188
|
+
name = "banners";
|
|
2189
|
+
description = "Show available banner types";
|
|
2190
|
+
usage = "/banners";
|
|
2191
|
+
execute(_args, logger) {
|
|
2192
|
+
logger.group("🖼️ Available Banner Types");
|
|
2193
|
+
Object.keys(BANNER_VARIANTS).forEach((bannerName) => {
|
|
2194
|
+
const banner = BANNER_VARIANTS[bannerName];
|
|
2195
|
+
console.log(`%c${bannerName}`, "font-weight: bold; color: #667eea;");
|
|
2196
|
+
console.log(`%cPreview:`, "color: #666; font-size: 12px;");
|
|
2197
|
+
if (bannerName === "simple") {
|
|
2198
|
+
console.log(`%c${banner.text}`, banner.style);
|
|
2199
|
+
} else if (bannerName === "ascii") {
|
|
2200
|
+
console.log(`%c${banner.text.split("\n").slice(1, 4).join("\n")}...`, "font-family: monospace; color: #667eea; font-size: 10px;");
|
|
2201
|
+
} else if (bannerName === "unicode") {
|
|
2202
|
+
console.log(`%c${banner.text}`, banner.style);
|
|
2203
|
+
} else {
|
|
2204
|
+
console.log(`%c${bannerName} banner`, "color: #666; font-style: italic;");
|
|
2205
|
+
}
|
|
2206
|
+
});
|
|
2207
|
+
logger.groupEnd();
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
class BannerCommand {
|
|
2211
|
+
name = "banner";
|
|
2212
|
+
description = "Change or show current banner type";
|
|
2213
|
+
usage = "/banner [type]";
|
|
2214
|
+
execute(args, logger) {
|
|
2215
|
+
if (!args) {
|
|
2216
|
+
logger.showBanner();
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2219
|
+
if (args in BANNER_VARIANTS) {
|
|
2220
|
+
logger.setBannerType(args);
|
|
2221
|
+
logger.showBanner();
|
|
2222
|
+
} else {
|
|
2223
|
+
logger.error(`Invalid banner type: ${args}. Available: ${Object.keys(BANNER_VARIANTS).join(", ")}`);
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
class StatusCommand {
|
|
2228
|
+
name = "status";
|
|
2229
|
+
description = "Show current logger status and configuration";
|
|
2230
|
+
usage = "/status";
|
|
2231
|
+
execute(_args, logger) {
|
|
2232
|
+
const config = logger.getConfig();
|
|
2233
|
+
const statusData = {
|
|
2234
|
+
theme: config.theme ? config.theme : "default",
|
|
2235
|
+
verbosity: config.verbosity,
|
|
2236
|
+
colors: config.enableColors,
|
|
2237
|
+
timestamps: config.enableTimestamps,
|
|
2238
|
+
stackTrace: config.enableStackTrace,
|
|
2239
|
+
globalPrefix: config.globalPrefix ? config.globalPrefix : "none",
|
|
2240
|
+
bannerType: config.bannerType ? config.bannerType : "simple",
|
|
2241
|
+
handlers: logger.getHandlers().length,
|
|
2242
|
+
bufferSize: config.bufferSize ? config.bufferSize : 1e3
|
|
2243
|
+
};
|
|
2244
|
+
logger.group("⚙️ Logger Configuration");
|
|
2245
|
+
logger.table(statusData);
|
|
2246
|
+
logger.groupEnd();
|
|
2247
|
+
const exportHandler = logger.getExportHandler();
|
|
2248
|
+
if (exportHandler) {
|
|
2249
|
+
const bufferStats = exportHandler.getBufferStats();
|
|
2250
|
+
logger.group("📊 Buffer Statistics");
|
|
2251
|
+
logger.table({
|
|
2252
|
+
size: `${bufferStats.size}/${bufferStats.maxSize}`,
|
|
2253
|
+
usage: `${bufferStats.usage.toFixed(1)}%`,
|
|
2254
|
+
oldestLog: bufferStats.oldestLog ? bufferStats.oldestLog.toISOString() : "None",
|
|
2255
|
+
newestLog: bufferStats.newestLog ? bufferStats.newestLog.toISOString() : "None",
|
|
2256
|
+
errorCount: bufferStats.levelCounts.error + bufferStats.levelCounts.critical,
|
|
2257
|
+
warningCount: bufferStats.levelCounts.warn
|
|
2258
|
+
});
|
|
2259
|
+
logger.groupEnd();
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
class ResetCommand {
|
|
2264
|
+
name = "reset";
|
|
2265
|
+
description = "Reset logger configuration to defaults";
|
|
2266
|
+
usage = "/reset";
|
|
2267
|
+
execute(_args, logger) {
|
|
2268
|
+
logger.resetConfig();
|
|
2269
|
+
}
|
|
2270
|
+
}
|
|
2271
|
+
class DemoCommand {
|
|
2272
|
+
name = "demo";
|
|
2273
|
+
description = "Show comprehensive feature demonstration";
|
|
2274
|
+
usage = "/demo";
|
|
2275
|
+
execute(_args, logger) {
|
|
2276
|
+
logger.group("🎪 Advanced Logger Demo");
|
|
2277
|
+
logger.debug("Debug message with detailed information");
|
|
2278
|
+
logger.info("Informational message about system state");
|
|
2279
|
+
logger.warn("Warning about deprecated feature");
|
|
2280
|
+
logger.error("Error processing user request");
|
|
2281
|
+
logger.success("Operation completed successfully");
|
|
2282
|
+
logger.critical("Critical system failure detected");
|
|
2283
|
+
logger.group("📊 Advanced Features Demo");
|
|
2284
|
+
logger.table([
|
|
2285
|
+
{ feature: "Styled Console", status: "✅ Active", performance: "Excellent" },
|
|
2286
|
+
{ feature: "Theme System", status: "✅ Active", performance: "Great" },
|
|
2287
|
+
{ feature: "CLI Interface", status: "✅ Active", performance: "Good" },
|
|
2288
|
+
{ feature: "Export System", status: "✅ Active", performance: "Excellent" }
|
|
2289
|
+
]);
|
|
2290
|
+
logger.time("demo-operation");
|
|
2291
|
+
setTimeout(() => {
|
|
2292
|
+
logger.timeEnd("demo-operation");
|
|
2293
|
+
}, 100);
|
|
2294
|
+
logger.logWithSVG("SVG Demo");
|
|
2295
|
+
logger.logAnimated("🌟 Animated Logger Demo 🌟", 2);
|
|
2296
|
+
logger.groupEnd();
|
|
2297
|
+
logger.groupEnd();
|
|
2298
|
+
logger.info("Demo completed! Check the console for styled output.");
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
function parseArguments(args) {
|
|
2302
|
+
const filters = {};
|
|
2303
|
+
const options = {};
|
|
2304
|
+
let format;
|
|
2305
|
+
if (!args.trim()) return { filters, options };
|
|
2306
|
+
const argParts = args.match(/(?:[^\s"]+|"[^"]*")+/g) || [];
|
|
2307
|
+
for (let i = 0; i < argParts.length; i++) {
|
|
2308
|
+
const arg = argParts[i];
|
|
2309
|
+
if (!arg) {
|
|
2310
|
+
continue;
|
|
2311
|
+
}
|
|
2312
|
+
if (i === 0 && !arg.startsWith("--") && arg in EXPORT_FORMATS) {
|
|
2313
|
+
format = arg;
|
|
2314
|
+
continue;
|
|
2315
|
+
}
|
|
2316
|
+
if (arg.startsWith("--")) {
|
|
2317
|
+
const [flag, value] = arg.slice(2).split("=");
|
|
2318
|
+
switch (flag) {
|
|
2319
|
+
case "level":
|
|
2320
|
+
case "levels":
|
|
2321
|
+
if (value) {
|
|
2322
|
+
filters.levels = value.split(",").map((l) => l.trim());
|
|
2323
|
+
}
|
|
2324
|
+
break;
|
|
2325
|
+
case "since":
|
|
2326
|
+
if (value) filters.since = value;
|
|
2327
|
+
break;
|
|
2328
|
+
case "until":
|
|
2329
|
+
if (value) filters.until = value;
|
|
2330
|
+
break;
|
|
2331
|
+
case "prefix":
|
|
2332
|
+
case "prefixes":
|
|
2333
|
+
if (value) {
|
|
2334
|
+
filters.prefixes = value.split(",").map((p) => p.trim());
|
|
2335
|
+
}
|
|
2336
|
+
break;
|
|
2337
|
+
case "exclude-prefix":
|
|
2338
|
+
case "exclude-prefixes":
|
|
2339
|
+
if (value) {
|
|
2340
|
+
filters.excludePrefixes = value.split(",").map((p) => p.trim());
|
|
2341
|
+
}
|
|
2342
|
+
break;
|
|
2343
|
+
case "last":
|
|
2344
|
+
if (value) filters.last = parseInt(value, 10);
|
|
2345
|
+
break;
|
|
2346
|
+
case "first":
|
|
2347
|
+
if (value) filters.first = parseInt(value, 10);
|
|
2348
|
+
break;
|
|
2349
|
+
case "search":
|
|
2350
|
+
if (value) filters.search = value.replace(/['"]/g, "");
|
|
2351
|
+
break;
|
|
2352
|
+
case "with-stack":
|
|
2353
|
+
filters.withStackTrace = true;
|
|
2354
|
+
break;
|
|
2355
|
+
case "errors-only":
|
|
2356
|
+
filters.errorsOnly = true;
|
|
2357
|
+
break;
|
|
2358
|
+
case "group-by":
|
|
2359
|
+
if (value) {
|
|
2360
|
+
filters.groupBy = value;
|
|
2361
|
+
options.groupBy = value;
|
|
2362
|
+
}
|
|
2363
|
+
break;
|
|
2364
|
+
case "minimal":
|
|
2365
|
+
options.minimal = true;
|
|
2366
|
+
break;
|
|
2367
|
+
case "compact":
|
|
2368
|
+
options.compact = true;
|
|
2369
|
+
break;
|
|
2370
|
+
case "styled":
|
|
2371
|
+
options.styled = true;
|
|
2372
|
+
break;
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
return { filters, options, format };
|
|
2377
|
+
}
|
|
2378
|
+
class ExportCommand {
|
|
2379
|
+
name = "export";
|
|
2380
|
+
description = "Export logs to various formats";
|
|
2381
|
+
usage = "/export <format> [--filter=value] [--option]";
|
|
2382
|
+
execute(args, logger) {
|
|
2383
|
+
const exportHandler = logger.getExportHandler();
|
|
2384
|
+
if (!exportHandler) {
|
|
2385
|
+
logger.error("Export handler not available. Make sure ExportLogHandler is registered.");
|
|
2386
|
+
return;
|
|
2387
|
+
}
|
|
2388
|
+
const { filters, options, format } = parseArguments(args);
|
|
2389
|
+
if (!format) {
|
|
2390
|
+
logger.error("Format required. Available formats: " + Object.keys(EXPORT_FORMATS).join(", "));
|
|
2391
|
+
logger.info("Usage: /export <format> [--filter=value]");
|
|
2392
|
+
logger.info("Example: /export json --level=error,warn --last=50");
|
|
2393
|
+
return;
|
|
2394
|
+
}
|
|
2395
|
+
try {
|
|
2396
|
+
const result = exportHandler.export(format, filters, options);
|
|
2397
|
+
logger.success(`✅ Export completed: ${result.metadata.filteredLogs} logs exported in ${format} format`);
|
|
2398
|
+
if (result.data.length < 1e3) {
|
|
2399
|
+
logger.group(`📄 Preview (${format.toUpperCase()})`);
|
|
2400
|
+
console.log(result.data);
|
|
2401
|
+
logger.groupEnd();
|
|
2402
|
+
} else {
|
|
2403
|
+
logger.info(`📄 Export size: ${(result.data.length / 1024).toFixed(2)}KB`);
|
|
2404
|
+
}
|
|
2405
|
+
logger.table({
|
|
2406
|
+
format: result.format,
|
|
2407
|
+
totalLogs: result.metadata.totalLogs,
|
|
2408
|
+
filtered: result.metadata.filteredLogs,
|
|
2409
|
+
exported: result.metadata.exportedAt
|
|
2410
|
+
});
|
|
2411
|
+
} catch (error) {
|
|
2412
|
+
logger.error("Export failed:", error);
|
|
2413
|
+
}
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
class CopyCommand {
|
|
2417
|
+
name = "copy";
|
|
2418
|
+
description = "Copy logs to clipboard";
|
|
2419
|
+
usage = "/copy <format> [--filter=value] [--option]";
|
|
2420
|
+
async execute(args, logger) {
|
|
2421
|
+
const exportHandler = logger.getExportHandler();
|
|
2422
|
+
if (!exportHandler) {
|
|
2423
|
+
logger.error("Export handler not available. Make sure ExportLogHandler is registered.");
|
|
2424
|
+
return;
|
|
2425
|
+
}
|
|
2426
|
+
const { filters, options, format } = parseArguments(args);
|
|
2427
|
+
if (!format) {
|
|
2428
|
+
logger.error("Format required. Available formats: " + Object.keys(EXPORT_FORMATS).join(", "));
|
|
2429
|
+
logger.info("Usage: /copy <format> [--filter=value]");
|
|
2430
|
+
logger.info("Example: /copy plain --level=error --last=25");
|
|
2431
|
+
return;
|
|
2432
|
+
}
|
|
2433
|
+
try {
|
|
2434
|
+
const success = await exportHandler.copyToClipboard(format, filters, options);
|
|
2435
|
+
if (success) {
|
|
2436
|
+
const result = exportHandler.export(format, filters, options);
|
|
2437
|
+
logger.success(`📋 Copied ${result.metadata.filteredLogs} logs to clipboard (${format} format)`);
|
|
2438
|
+
} else {
|
|
2439
|
+
logger.error("Failed to copy to clipboard. Browser may not support clipboard API.");
|
|
2440
|
+
}
|
|
2441
|
+
} catch (error) {
|
|
2442
|
+
logger.error("Copy failed:", error);
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
class BufferSizeCommand {
|
|
2447
|
+
name = "buffer-size";
|
|
2448
|
+
description = "Set log buffer size";
|
|
2449
|
+
usage = "/buffer-size <size>";
|
|
2450
|
+
execute(args, logger) {
|
|
2451
|
+
const exportHandler = logger.getExportHandler();
|
|
2452
|
+
if (!exportHandler) {
|
|
2453
|
+
logger.error("Export handler not available.");
|
|
2454
|
+
return;
|
|
2455
|
+
}
|
|
2456
|
+
const size = parseInt(args.trim(), 10);
|
|
2457
|
+
if (isNaN(size) || size <= 0) {
|
|
2458
|
+
logger.error("Invalid buffer size. Must be a positive number.");
|
|
2459
|
+
logger.info("Example: /buffer-size 2000");
|
|
2460
|
+
return;
|
|
2461
|
+
}
|
|
2462
|
+
exportHandler.setBufferSize(size);
|
|
2463
|
+
logger.success(`Buffer size set to ${size}`);
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
class ClearBufferCommand {
|
|
2467
|
+
name = "clear-buffer";
|
|
2468
|
+
description = "Clear the log buffer";
|
|
2469
|
+
usage = "/clear-buffer";
|
|
2470
|
+
execute(_args, logger) {
|
|
2471
|
+
const exportHandler = logger.getExportHandler();
|
|
2472
|
+
if (!exportHandler) {
|
|
2473
|
+
logger.error("Export handler not available.");
|
|
2474
|
+
return;
|
|
2475
|
+
}
|
|
2476
|
+
const stats = exportHandler.getBufferStats();
|
|
2477
|
+
exportHandler.clearBuffer();
|
|
2478
|
+
logger.success(`✅ Buffer cleared. Removed ${stats.size} log entries.`);
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
class BufferInfoCommand {
|
|
2482
|
+
name = "buffer-info";
|
|
2483
|
+
description = "Show buffer statistics and information";
|
|
2484
|
+
usage = "/buffer-info";
|
|
2485
|
+
execute(_args, logger) {
|
|
2486
|
+
const exportHandler = logger.getExportHandler();
|
|
2487
|
+
if (!exportHandler) {
|
|
2488
|
+
logger.error("Export handler not available.");
|
|
2489
|
+
return;
|
|
2490
|
+
}
|
|
2491
|
+
const stats = exportHandler.getBufferStats();
|
|
2492
|
+
logger.group("📊 Buffer Information");
|
|
2493
|
+
logger.table({
|
|
2494
|
+
size: `${stats.size}/${stats.maxSize}`,
|
|
2495
|
+
usage: `${stats.usage.toFixed(1)}%`,
|
|
2496
|
+
oldestLog: stats.oldestLog?.toLocaleString() || "None",
|
|
2497
|
+
newestLog: stats.newestLog?.toLocaleString() || "None"
|
|
2498
|
+
});
|
|
2499
|
+
logger.group("📈 Log Level Counts");
|
|
2500
|
+
logger.table(stats.levelCounts);
|
|
2501
|
+
logger.groupEnd();
|
|
2502
|
+
logger.groupEnd();
|
|
2503
|
+
}
|
|
2504
|
+
}
|
|
2505
|
+
class HelpCommand {
|
|
2506
|
+
name = "help";
|
|
2507
|
+
description = "Show CLI help and available commands";
|
|
2508
|
+
usage = "/help [command]";
|
|
2509
|
+
execute(_args, logger) {
|
|
2510
|
+
const helpStyle = new StyleBuilder().bg("linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%)").color("#495057").padding("15px 20px").rounded("8px").border("1px solid #dee2e6").font("Monaco, Consolas, monospace").size("13px").build();
|
|
2511
|
+
const helpText = `
|
|
2512
|
+
╭─────────────── ADVANCED LOGGER CLI COMMANDS ─────────────────╮
|
|
2513
|
+
│ │
|
|
2514
|
+
│ CONFIGURATION │
|
|
2515
|
+
│ /config Show current configuration │
|
|
2516
|
+
│ /config {json} Apply JSON configuration │
|
|
2517
|
+
│ /config key=val Apply key-value configuration │
|
|
2518
|
+
│ /themes Show available themes │
|
|
2519
|
+
│ /banners Show available banner types │
|
|
2520
|
+
│ /banner [type] Change/show banner type │
|
|
2521
|
+
│ /status Show logger status & buffer stats │
|
|
2522
|
+
│ /demo Show feature demonstration │
|
|
2523
|
+
│ /reset Reset to default configuration │
|
|
2524
|
+
│ │
|
|
2525
|
+
│ EXPORT & CLIPBOARD │
|
|
2526
|
+
│ /export <format> Export logs (json|csv|md|plain|html) │
|
|
2527
|
+
│ /copy <format> Copy logs to clipboard │
|
|
2528
|
+
│ /buffer-size N Set log buffer size │
|
|
2529
|
+
│ /buffer-info Show buffer statistics │
|
|
2530
|
+
│ /clear-buffer Clear stored logs │
|
|
2531
|
+
│ │
|
|
2532
|
+
│ EXPORT FILTERS (for export/copy commands) │
|
|
2533
|
+
│ --level error,warn Filter by log levels │
|
|
2534
|
+
│ --since 2h Logs from last 2 hours │
|
|
2535
|
+
│ --until 1h Logs until 1 hour ago │
|
|
2536
|
+
│ --prefix API,DB Filter by prefixes │
|
|
2537
|
+
│ --exclude-prefix INT Exclude prefixes │
|
|
2538
|
+
│ --last 50 Last 50 logs only │
|
|
2539
|
+
│ --first 25 First 25 logs only │
|
|
2540
|
+
│ --search "error" Search in log messages │
|
|
2541
|
+
│ --with-stack Only logs with stack traces │
|
|
2542
|
+
│ --errors-only Only error + critical logs │
|
|
2543
|
+
│ --group-by level Group by level/prefix/hour │
|
|
2544
|
+
│ │
|
|
2545
|
+
│ EXPORT OPTIONS │
|
|
2546
|
+
│ --minimal Minimal output format │
|
|
2547
|
+
│ --compact Remove extra whitespace │
|
|
2548
|
+
│ --styled Include styling (HTML format) │
|
|
2549
|
+
│ │
|
|
2550
|
+
├──────────────────── CONFIGURATION OPTIONS ─────────────────┤
|
|
2551
|
+
│ │
|
|
2552
|
+
│ theme: default | dark | light | neon | minimal | cyberpunk│
|
|
2553
|
+
│ bannerType: simple | ascii | unicode | svg | animated │
|
|
2554
|
+
│ verbosity: debug | info | warn | error | critical | silent│
|
|
2555
|
+
│ enableColors: true | false │
|
|
2556
|
+
│ enableTimestamps: true | false │
|
|
2557
|
+
│ enableStackTrace: true | false │
|
|
2558
|
+
│ globalPrefix: "string" │
|
|
2559
|
+
│ bufferSize: number (50-10000) │
|
|
2560
|
+
│ │
|
|
2561
|
+
├──────────────────────── EXAMPLES ──────────────────────────┤
|
|
2562
|
+
│ │
|
|
2563
|
+
│ Basic Configuration: │
|
|
2564
|
+
│ /config {"theme":"dark","verbosity":"debug"} │
|
|
2565
|
+
│ /config theme=neon,bufferSize=2000 │
|
|
2566
|
+
│ /banner animated Change to animated banner │
|
|
2567
|
+
│ │
|
|
2568
|
+
│ Export Examples: │
|
|
2569
|
+
│ /export json --level=error,warn --last=25 │
|
|
2570
|
+
│ /export csv --since=2h --prefix=API │
|
|
2571
|
+
│ /export markdown --group-by=level --errors-only │
|
|
2572
|
+
│ /export html --styled --since=1h │
|
|
2573
|
+
│ │
|
|
2574
|
+
│ Clipboard Examples: │
|
|
2575
|
+
│ /copy plain --minimal --last=10 │
|
|
2576
|
+
│ /copy json --search="authentication" --compact │
|
|
2577
|
+
│ /copy csv --since=30m --exclude-prefix=DEBUG │
|
|
2578
|
+
│ │
|
|
2579
|
+
│ Buffer Management: │
|
|
2580
|
+
│ /buffer-size 5000 Increase buffer to 5000 logs │
|
|
2581
|
+
│ /buffer-info Show detailed buffer statistics │
|
|
2582
|
+
│ /clear-buffer Clear all stored logs │
|
|
2583
|
+
│ │
|
|
2584
|
+
│ Time Formats: │
|
|
2585
|
+
│ --since=2h 2 hours ago │
|
|
2586
|
+
│ --since=30m 30 minutes ago │
|
|
2587
|
+
│ --since=1d 1 day ago │
|
|
2588
|
+
│ --since="2024-01-01T10:00:00Z" Specific ISO date │
|
|
2589
|
+
│ │
|
|
2590
|
+
╰─────────────────────────────────────────────────────────────╯`;
|
|
2591
|
+
console.log(`%c${helpText}`, helpStyle);
|
|
2592
|
+
logger.group("💡 Quick Tips");
|
|
2593
|
+
const tips = [
|
|
2594
|
+
"Use /demo to see all logger features in action",
|
|
2595
|
+
"Logs are automatically stored in a circular buffer for export",
|
|
2596
|
+
"Export formats: JSON (structured), CSV (Excel), Markdown (readable), Plain (simple), HTML (styled)",
|
|
2597
|
+
"Time filters support relative (2h, 30m) and absolute (ISO) formats",
|
|
2598
|
+
'Combine multiple filters: /export json --level=error --since=1h --search="auth"',
|
|
2599
|
+
"Use /copy for quick clipboard access instead of /export"
|
|
2600
|
+
];
|
|
2601
|
+
tips.forEach((tip) => {
|
|
2602
|
+
logger.info(`• ${tip}`);
|
|
2603
|
+
});
|
|
2604
|
+
logger.groupEnd();
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
class HistoryCommand {
|
|
2608
|
+
name = "history";
|
|
2609
|
+
description = "Show command execution history";
|
|
2610
|
+
usage = "/history [limit] - Show recent commands (default: 10)";
|
|
2611
|
+
category = "system";
|
|
2612
|
+
aliases = ["hist", "h"];
|
|
2613
|
+
execute(args, logger) {
|
|
2614
|
+
const processor = logger.cliProcessor;
|
|
2615
|
+
if (!processor) {
|
|
2616
|
+
logger.error("CLI processor not available");
|
|
2617
|
+
return;
|
|
2618
|
+
}
|
|
2619
|
+
const limit = parseInt(args) || 10;
|
|
2620
|
+
const history = processor.getHistory().slice(0, limit);
|
|
2621
|
+
if (history.length === 0) {
|
|
2622
|
+
logger.info("📝 No command history available");
|
|
2623
|
+
return;
|
|
2624
|
+
}
|
|
2625
|
+
logger.info(`📋 Last ${history.length} commands:`);
|
|
2626
|
+
history.forEach((entry, index) => {
|
|
2627
|
+
const status = entry.success ? "✅" : "❌";
|
|
2628
|
+
const time = entry.timestamp.toLocaleTimeString();
|
|
2629
|
+
logger.info(`${status} [${time}] ${entry.command}`);
|
|
2630
|
+
});
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
class ClearHistoryCommand {
|
|
2634
|
+
name = "clearhistory";
|
|
2635
|
+
description = "Clear command execution history";
|
|
2636
|
+
usage = "/clearhistory - Remove all command history";
|
|
2637
|
+
category = "system";
|
|
2638
|
+
aliases = ["clrhist"];
|
|
2639
|
+
execute(args, logger) {
|
|
2640
|
+
const processor = logger.cliProcessor;
|
|
2641
|
+
if (!processor) {
|
|
2642
|
+
logger.error("CLI processor not available");
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
processor.clearHistory();
|
|
2646
|
+
logger.success("🗑️ Command history cleared");
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
class InteractiveCommand {
|
|
2650
|
+
name = "interactive";
|
|
2651
|
+
description = "Enter interactive CLI mode";
|
|
2652
|
+
usage = "/interactive - Start interactive command mode";
|
|
2653
|
+
category = "system";
|
|
2654
|
+
aliases = ["i", "repl"];
|
|
2655
|
+
execute(args, logger) {
|
|
2656
|
+
const processor = logger.cliProcessor;
|
|
2657
|
+
if (!processor) {
|
|
2658
|
+
logger.error("CLI processor not available");
|
|
2659
|
+
return;
|
|
2660
|
+
}
|
|
2661
|
+
processor.enterInteractiveMode(logger);
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
class PluginsCommand {
|
|
2665
|
+
name = "plugins";
|
|
2666
|
+
description = "List loaded CLI plugins";
|
|
2667
|
+
usage = "/plugins - Show all registered plugins";
|
|
2668
|
+
category = "system";
|
|
2669
|
+
aliases = ["plug"];
|
|
2670
|
+
execute(args, logger) {
|
|
2671
|
+
const processor = logger.cliProcessor;
|
|
2672
|
+
if (!processor) {
|
|
2673
|
+
logger.error("CLI processor not available");
|
|
2674
|
+
return;
|
|
2675
|
+
}
|
|
2676
|
+
const plugins = processor.getPlugins();
|
|
2677
|
+
if (plugins.length === 0) {
|
|
2678
|
+
logger.info("🔌 No plugins registered");
|
|
2679
|
+
return;
|
|
2680
|
+
}
|
|
2681
|
+
logger.info(`🔌 Loaded plugins (${plugins.length}):`);
|
|
2682
|
+
plugins.forEach((plugin) => {
|
|
2683
|
+
logger.info(` 📦 ${plugin.name} v${plugin.version} - ${plugin.description}`);
|
|
2684
|
+
logger.info(` Commands: ${plugin.commands.map((c) => c.name).join(", ")}`);
|
|
2685
|
+
});
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
function createDefaultCLI() {
|
|
2689
|
+
const processor = new CommandProcessor();
|
|
2690
|
+
processor.registerCommand(new HelpCommand());
|
|
2691
|
+
processor.registerCommand(new ConfigCommand());
|
|
2692
|
+
processor.registerCommand(new ThemesCommand());
|
|
2693
|
+
processor.registerCommand(new BannersCommand());
|
|
2694
|
+
processor.registerCommand(new BannerCommand());
|
|
2695
|
+
processor.registerCommand(new StatusCommand());
|
|
2696
|
+
processor.registerCommand(new ResetCommand());
|
|
2697
|
+
processor.registerCommand(new DemoCommand());
|
|
2698
|
+
processor.registerCommand(new ExportCommand());
|
|
2699
|
+
processor.registerCommand(new CopyCommand());
|
|
2700
|
+
processor.registerCommand(new BufferSizeCommand());
|
|
2701
|
+
processor.registerCommand(new ClearBufferCommand());
|
|
2702
|
+
processor.registerCommand(new BufferInfoCommand());
|
|
2703
|
+
processor.registerCommand(new HistoryCommand());
|
|
2704
|
+
processor.registerCommand(new ClearHistoryCommand());
|
|
2705
|
+
processor.registerCommand(new InteractiveCommand());
|
|
2706
|
+
processor.registerCommand(new PluginsCommand());
|
|
2707
|
+
return processor;
|
|
2708
|
+
}
|
|
2709
|
+
let LEVEL_STYLES = THEME_PRESETS.default;
|
|
2710
|
+
class Logger {
|
|
2711
|
+
config;
|
|
2712
|
+
scopedPrefix;
|
|
2713
|
+
handlers = [];
|
|
2714
|
+
timers = /* @__PURE__ */ new Map();
|
|
2715
|
+
groupDepth = 0;
|
|
2716
|
+
exportHandler;
|
|
2717
|
+
cliProcessor;
|
|
2718
|
+
themeChangeListener;
|
|
2719
|
+
displaySettings = {
|
|
2720
|
+
showTimestamp: true,
|
|
2721
|
+
showLocation: true,
|
|
2722
|
+
showBadges: true
|
|
2723
|
+
};
|
|
2724
|
+
/**
|
|
2725
|
+
* Creates a new Logger instance
|
|
2726
|
+
*/
|
|
2727
|
+
constructor(config = {}) {
|
|
2728
|
+
this.config = {
|
|
2729
|
+
...DEFAULT_CONFIG,
|
|
2730
|
+
...config
|
|
2731
|
+
};
|
|
2732
|
+
if (this.config.bufferSize) {
|
|
2733
|
+
this.exportHandler = new ExportLogHandler(this.config.bufferSize);
|
|
2734
|
+
this.handlers.push(this.exportHandler);
|
|
2735
|
+
}
|
|
2736
|
+
this.cliProcessor = createDefaultCLI();
|
|
2737
|
+
if (this.config.autoDetectTheme) {
|
|
2738
|
+
this.setupAutoThemeDetection();
|
|
2739
|
+
}
|
|
2740
|
+
}
|
|
2741
|
+
// ===== PRIVATE HELPER METHODS =====
|
|
2742
|
+
/**
|
|
2743
|
+
* Sets up automatic theme detection with change listener
|
|
2744
|
+
*/
|
|
2745
|
+
setupAutoThemeDetection() {
|
|
2746
|
+
if (this.themeChangeListener) {
|
|
2747
|
+
this.themeChangeListener();
|
|
2748
|
+
this.themeChangeListener = null;
|
|
2749
|
+
}
|
|
2750
|
+
this.themeChangeListener = setupThemeChangeListener((theme) => {
|
|
2751
|
+
this.debug(`DevTools theme changed to: ${theme}`);
|
|
2752
|
+
});
|
|
2753
|
+
}
|
|
2754
|
+
// ===== CONFIGURATION METHODS =====
|
|
2755
|
+
/**
|
|
2756
|
+
* Get current configuration
|
|
2757
|
+
*/
|
|
2758
|
+
getConfig() {
|
|
2759
|
+
return { ...this.config };
|
|
2760
|
+
}
|
|
2761
|
+
/**
|
|
2762
|
+
* Update configuration
|
|
2763
|
+
*/
|
|
2764
|
+
updateConfig(updates) {
|
|
2765
|
+
const previousAutoDetect = this.config.autoDetectTheme;
|
|
2766
|
+
this.config = { ...this.config, ...updates };
|
|
2767
|
+
if (updates.autoDetectTheme !== void 0 && updates.autoDetectTheme !== previousAutoDetect) {
|
|
2768
|
+
if (updates.autoDetectTheme) {
|
|
2769
|
+
this.setupAutoThemeDetection();
|
|
2770
|
+
} else if (this.themeChangeListener) {
|
|
2771
|
+
this.themeChangeListener();
|
|
2772
|
+
this.themeChangeListener = null;
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
/**
|
|
2777
|
+
* Sets the global prefix for all log messages
|
|
2778
|
+
*/
|
|
2779
|
+
setGlobalPrefix(prefix) {
|
|
2780
|
+
this.config.globalPrefix = prefix;
|
|
2781
|
+
}
|
|
2782
|
+
/**
|
|
2783
|
+
* Sets the verbosity level for filtering log output
|
|
2784
|
+
*/
|
|
2785
|
+
setVerbosity(level) {
|
|
2786
|
+
this.config.verbosity = level;
|
|
2787
|
+
}
|
|
2788
|
+
/**
|
|
2789
|
+
* Sets the logger theme
|
|
2790
|
+
*/
|
|
2791
|
+
setTheme(theme) {
|
|
2792
|
+
if (hasPreset(theme)) {
|
|
2793
|
+
this.preset(theme);
|
|
2794
|
+
return;
|
|
2795
|
+
}
|
|
2796
|
+
if (theme in THEME_PRESETS) {
|
|
2797
|
+
LEVEL_STYLES = THEME_PRESETS[theme];
|
|
2798
|
+
this.config.theme = theme;
|
|
2799
|
+
if (theme in THEME_BANNERS) {
|
|
2800
|
+
const themeBanner = THEME_BANNERS[theme];
|
|
2801
|
+
console.log(`%c${themeBanner.simple}`, themeBanner.style);
|
|
2802
|
+
}
|
|
2803
|
+
this.success(`Theme changed to: ${theme}`);
|
|
2804
|
+
} else {
|
|
2805
|
+
this.error(`Invalid theme: ${theme}. Available:`, [...getAvailablePresets(), ...Object.keys(THEME_PRESETS)]);
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
/**
|
|
2809
|
+
* Set banner type for initialization display
|
|
2810
|
+
*/
|
|
2811
|
+
setBannerType(bannerType) {
|
|
2812
|
+
this.config.bannerType = bannerType;
|
|
2813
|
+
this.success(`Banner type changed to: ${bannerType}`);
|
|
2814
|
+
}
|
|
2815
|
+
/**
|
|
2816
|
+
* Reset logger to default configuration
|
|
2817
|
+
*/
|
|
2818
|
+
resetConfig() {
|
|
2819
|
+
if (this.themeChangeListener) {
|
|
2820
|
+
this.themeChangeListener();
|
|
2821
|
+
this.themeChangeListener = null;
|
|
2822
|
+
}
|
|
2823
|
+
this.config = { ...DEFAULT_CONFIG };
|
|
2824
|
+
LEVEL_STYLES = THEME_PRESETS.default;
|
|
2825
|
+
if (this.config.autoDetectTheme) {
|
|
2826
|
+
this.setupAutoThemeDetection();
|
|
2827
|
+
}
|
|
2828
|
+
this.success("Logger configuration reset to defaults");
|
|
2829
|
+
}
|
|
2830
|
+
/**
|
|
2831
|
+
* Cleanup method to remove event listeners and free resources
|
|
2832
|
+
*/
|
|
2833
|
+
cleanup() {
|
|
2834
|
+
if (this.themeChangeListener) {
|
|
2835
|
+
this.themeChangeListener();
|
|
2836
|
+
this.themeChangeListener = null;
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
// ===== SIMPLIFIED API =====
|
|
2840
|
+
/**
|
|
2841
|
+
* Apply a smart preset - works perfectly out-of-the-box
|
|
2842
|
+
*/
|
|
2843
|
+
preset(name) {
|
|
2844
|
+
if (!hasPreset(name)) {
|
|
2845
|
+
this.error(`Unknown preset: ${name}. Available presets:`, getAvailablePresets());
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
const presetConfig = getSmartPreset(name);
|
|
2849
|
+
if (presetConfig) {
|
|
2850
|
+
this.displaySettings.showTimestamp = presetConfig.timestamp?.show ?? true;
|
|
2851
|
+
this.displaySettings.showLocation = presetConfig.location?.show ?? true;
|
|
2852
|
+
this._activePreset = presetConfig;
|
|
2853
|
+
this._activePresetName = name;
|
|
2854
|
+
this.success(`Applied preset: ${name}`);
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
/**
|
|
2858
|
+
* List available presets
|
|
2859
|
+
*/
|
|
2860
|
+
presets() {
|
|
2861
|
+
return getAvailablePresets();
|
|
2862
|
+
}
|
|
2863
|
+
// ===== TOGGLE METHODS =====
|
|
2864
|
+
/**
|
|
2865
|
+
* Hide timestamp in logs
|
|
2866
|
+
*/
|
|
2867
|
+
hideTimestamp() {
|
|
2868
|
+
this.displaySettings.showTimestamp = false;
|
|
2869
|
+
this.success("Timestamp hidden");
|
|
2870
|
+
}
|
|
2871
|
+
/**
|
|
2872
|
+
* Show timestamp in logs
|
|
2873
|
+
*/
|
|
2874
|
+
showTimestamp() {
|
|
2875
|
+
this.displaySettings.showTimestamp = true;
|
|
2876
|
+
this.success("Timestamp shown");
|
|
2877
|
+
}
|
|
2878
|
+
/**
|
|
2879
|
+
* Hide location info in logs
|
|
2880
|
+
*/
|
|
2881
|
+
hideLocation() {
|
|
2882
|
+
this.displaySettings.showLocation = false;
|
|
2883
|
+
this.success("Location info hidden");
|
|
2884
|
+
}
|
|
2885
|
+
/**
|
|
2886
|
+
* Show location info in logs
|
|
2887
|
+
*/
|
|
2888
|
+
showLocation() {
|
|
2889
|
+
this.displaySettings.showLocation = true;
|
|
2890
|
+
this.success("Location info shown");
|
|
2891
|
+
}
|
|
2892
|
+
/**
|
|
2893
|
+
* Hide badges in logs
|
|
2894
|
+
*/
|
|
2895
|
+
hideBadges() {
|
|
2896
|
+
this.displaySettings.showBadges = false;
|
|
2897
|
+
this.success("Badges hidden");
|
|
2898
|
+
}
|
|
2899
|
+
/**
|
|
2900
|
+
* Show badges in logs
|
|
2901
|
+
*/
|
|
2902
|
+
showBadges() {
|
|
2903
|
+
this.displaySettings.showBadges = true;
|
|
2904
|
+
this.success("Badges shown");
|
|
2905
|
+
}
|
|
2906
|
+
// ===== SCOPED LOGGERS =====
|
|
2907
|
+
/**
|
|
2908
|
+
* Create a component logger with automatic styling
|
|
2909
|
+
*/
|
|
2910
|
+
component(name) {
|
|
2911
|
+
return new ComponentLogger(this, name);
|
|
2912
|
+
}
|
|
2913
|
+
/**
|
|
2914
|
+
* Create an API logger with automatic badges
|
|
2915
|
+
*/
|
|
2916
|
+
api(name) {
|
|
2917
|
+
return new APILogger(this, name);
|
|
2918
|
+
}
|
|
2919
|
+
/**
|
|
2920
|
+
* Create a general scoped logger with badges support
|
|
2921
|
+
*/
|
|
2922
|
+
scope(name) {
|
|
2923
|
+
return new ScopedLogger(this, name);
|
|
2924
|
+
}
|
|
2925
|
+
// ===== SIMPLE CUSTOMIZATION =====
|
|
2926
|
+
/**
|
|
2927
|
+
* Simple customization with minimal configuration
|
|
2928
|
+
*/
|
|
2929
|
+
customize(overrides) {
|
|
2930
|
+
if (overrides.timestamp?.show !== void 0) {
|
|
2931
|
+
this.displaySettings.showTimestamp = overrides.timestamp.show;
|
|
2932
|
+
}
|
|
2933
|
+
if (overrides.location?.show !== void 0) {
|
|
2934
|
+
this.displaySettings.showLocation = overrides.location.show;
|
|
2935
|
+
}
|
|
2936
|
+
if (overrides.prefix?.show !== void 0) ;
|
|
2937
|
+
this._customization = overrides;
|
|
2938
|
+
this.success("Customization applied");
|
|
2939
|
+
}
|
|
2940
|
+
/**
|
|
2941
|
+
* Access advanced styling API (for power users)
|
|
2942
|
+
*/
|
|
2943
|
+
styles() {
|
|
2944
|
+
return createLogStyleBuilder(this);
|
|
2945
|
+
}
|
|
2946
|
+
// ===== HANDLER MANAGEMENT =====
|
|
2947
|
+
/**
|
|
2948
|
+
* Adds a custom log handler for extensibility
|
|
2949
|
+
*/
|
|
2950
|
+
addHandler(handler) {
|
|
2951
|
+
this.handlers.push(handler);
|
|
2952
|
+
}
|
|
2953
|
+
/**
|
|
2954
|
+
* Get all registered handlers
|
|
2955
|
+
*/
|
|
2956
|
+
getHandlers() {
|
|
2957
|
+
return [...this.handlers];
|
|
2958
|
+
}
|
|
2959
|
+
/**
|
|
2960
|
+
* Get export handler if available
|
|
2961
|
+
*/
|
|
2962
|
+
getExportHandler() {
|
|
2963
|
+
return this.exportHandler;
|
|
2964
|
+
}
|
|
2965
|
+
// ===== CORE LOGGING METHODS =====
|
|
2966
|
+
/**
|
|
2967
|
+
* Checks if a log level should be output based on current verbosity
|
|
2968
|
+
*/
|
|
2969
|
+
shouldLog(level) {
|
|
2970
|
+
if (this.config.verbosity === "silent") return false;
|
|
2971
|
+
const levels = { debug: 0, info: 1, warn: 2, error: 3, critical: 4 };
|
|
2972
|
+
return levels[level] >= levels[this.config.verbosity];
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* Gets the effective prefix (global + scoped)
|
|
2976
|
+
*/
|
|
2977
|
+
getEffectivePrefix() {
|
|
2978
|
+
const parts = [this.config.globalPrefix, this.scopedPrefix].filter(Boolean);
|
|
2979
|
+
return parts.length > 0 ? parts.join(":") : void 0;
|
|
2980
|
+
}
|
|
2981
|
+
/**
|
|
2982
|
+
* Core logging method that handles styling and formatting
|
|
2983
|
+
*/
|
|
2984
|
+
log(level, ...args) {
|
|
2985
|
+
if (!this.shouldLog(level)) return;
|
|
2986
|
+
const stackInfo = this.config.enableStackTrace ? parseStackTrace() : null;
|
|
2987
|
+
const prefix = this.getEffectivePrefix();
|
|
2988
|
+
const message = args.length > 0 ? String(args[0]) : "";
|
|
2989
|
+
const additionalArgs = args.slice(1);
|
|
2990
|
+
const [format, ...styles2] = createStyledOutput(
|
|
2991
|
+
level,
|
|
2992
|
+
LEVEL_STYLES,
|
|
2993
|
+
prefix,
|
|
2994
|
+
message,
|
|
2995
|
+
this.displaySettings.showLocation ? stackInfo : null,
|
|
2996
|
+
this.config.autoDetectTheme
|
|
2997
|
+
);
|
|
2998
|
+
const groupIndent = " ".repeat(this.groupDepth);
|
|
2999
|
+
const finalFormat = groupIndent + format;
|
|
3000
|
+
if (additionalArgs.length > 0) {
|
|
3001
|
+
console.log(finalFormat, ...styles2, ...additionalArgs);
|
|
3002
|
+
} else {
|
|
3003
|
+
console.log(finalFormat, ...styles2);
|
|
3004
|
+
}
|
|
3005
|
+
if (this.exportHandler) {
|
|
3006
|
+
this.exportHandler.setGroupInfo(this.groupDepth);
|
|
3007
|
+
}
|
|
3008
|
+
const metadata = {
|
|
3009
|
+
timestamp: formatTimestamp(),
|
|
3010
|
+
level,
|
|
3011
|
+
prefix,
|
|
3012
|
+
stackInfo: stackInfo ? stackInfo : void 0
|
|
3013
|
+
};
|
|
3014
|
+
this.handlers.forEach((handler) => {
|
|
3015
|
+
try {
|
|
3016
|
+
handler.handle(level, message, args, metadata);
|
|
3017
|
+
} catch (error2) {
|
|
3018
|
+
console.error("Log handler failed:", error2);
|
|
3019
|
+
}
|
|
3020
|
+
});
|
|
3021
|
+
}
|
|
3022
|
+
/**
|
|
3023
|
+
* Logs debug information (lowest priority)
|
|
3024
|
+
*/
|
|
3025
|
+
debug(...args) {
|
|
3026
|
+
this.log("debug", ...args);
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Logs informational messages
|
|
3030
|
+
*/
|
|
3031
|
+
info(...args) {
|
|
3032
|
+
this.log("info", ...args);
|
|
3033
|
+
}
|
|
3034
|
+
/**
|
|
3035
|
+
* Logs warning messages
|
|
3036
|
+
*/
|
|
3037
|
+
warn(...args) {
|
|
3038
|
+
this.log("warn", ...args);
|
|
3039
|
+
}
|
|
3040
|
+
/**
|
|
3041
|
+
* Logs error messages
|
|
3042
|
+
*/
|
|
3043
|
+
error(...args) {
|
|
3044
|
+
this.log("error", ...args);
|
|
3045
|
+
}
|
|
3046
|
+
/**
|
|
3047
|
+
* Logs success messages (special info level)
|
|
3048
|
+
*/
|
|
3049
|
+
success(...args) {
|
|
3050
|
+
if (!this.shouldLog("info")) return;
|
|
3051
|
+
const stackInfo = this.config.enableStackTrace ? parseStackTrace() : null;
|
|
3052
|
+
const prefix = this.getEffectivePrefix();
|
|
3053
|
+
const message = args.length > 0 ? String(args[0]) : "";
|
|
3054
|
+
const additionalArgs = args.slice(1);
|
|
3055
|
+
const [format, ...styles2] = createStyledOutput(
|
|
3056
|
+
"info",
|
|
3057
|
+
LEVEL_STYLES,
|
|
3058
|
+
prefix,
|
|
3059
|
+
message,
|
|
3060
|
+
this.displaySettings.showLocation ? stackInfo : null,
|
|
3061
|
+
this.config.autoDetectTheme
|
|
3062
|
+
);
|
|
3063
|
+
const successStyle = LEVEL_STYLES.success;
|
|
3064
|
+
let emoji = "✅";
|
|
3065
|
+
let label = "SUCCESS";
|
|
3066
|
+
if (successStyle) {
|
|
3067
|
+
if (successStyle.emoji) {
|
|
3068
|
+
emoji = successStyle.emoji;
|
|
3069
|
+
}
|
|
3070
|
+
if (successStyle.label) {
|
|
3071
|
+
label = successStyle.label;
|
|
3072
|
+
}
|
|
3073
|
+
}
|
|
3074
|
+
const successFormat = format.replace(/ℹ️ INFO/, `${emoji} ${label}`);
|
|
3075
|
+
const groupIndent = " ".repeat(this.groupDepth);
|
|
3076
|
+
const finalFormat = groupIndent + successFormat;
|
|
3077
|
+
if (additionalArgs.length > 0) {
|
|
3078
|
+
console.log(finalFormat, ...styles2, ...additionalArgs);
|
|
3079
|
+
} else {
|
|
3080
|
+
console.log(finalFormat, ...styles2);
|
|
3081
|
+
}
|
|
3082
|
+
const metadata = {
|
|
3083
|
+
timestamp: formatTimestamp(),
|
|
3084
|
+
level: "info",
|
|
3085
|
+
prefix,
|
|
3086
|
+
stackInfo: stackInfo ? stackInfo : void 0
|
|
3087
|
+
};
|
|
3088
|
+
this.handlers.forEach((handler) => {
|
|
3089
|
+
try {
|
|
3090
|
+
handler.handle("info", message, args, metadata);
|
|
3091
|
+
} catch (error2) {
|
|
3092
|
+
console.error("Log handler failed:", error2);
|
|
3093
|
+
}
|
|
3094
|
+
});
|
|
3095
|
+
}
|
|
3096
|
+
/**
|
|
3097
|
+
* Logs trace information (detailed debugging)
|
|
3098
|
+
*/
|
|
3099
|
+
trace(...args) {
|
|
3100
|
+
this.log("debug", ...args);
|
|
3101
|
+
if (this.shouldLog("debug")) {
|
|
3102
|
+
console.trace(...args);
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
/**
|
|
3106
|
+
* Logs critical errors (highest priority)
|
|
3107
|
+
*/
|
|
3108
|
+
critical(...args) {
|
|
3109
|
+
this.log("critical", ...args);
|
|
3110
|
+
}
|
|
3111
|
+
// ===== ADVANCED LOGGING FEATURES =====
|
|
3112
|
+
/**
|
|
3113
|
+
* Displays data in a table format
|
|
3114
|
+
*/
|
|
3115
|
+
table(data, columns) {
|
|
3116
|
+
if (!this.shouldLog("info")) return;
|
|
3117
|
+
const prefix = this.getEffectivePrefix();
|
|
3118
|
+
const tableStyle = StylePresets.accent().build();
|
|
3119
|
+
const format = `%c📊 TABLE${prefix ? ` [${prefix}]` : ""}`;
|
|
3120
|
+
console.log(format, tableStyle);
|
|
3121
|
+
if (columns) {
|
|
3122
|
+
console.table(data, columns);
|
|
3123
|
+
} else {
|
|
3124
|
+
console.table(data);
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
3127
|
+
/**
|
|
3128
|
+
* Starts a collapsible group in the console
|
|
3129
|
+
*/
|
|
3130
|
+
group(label, collapsed = false) {
|
|
3131
|
+
const groupStyle = new StyleBuilder().bg("linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%)").color("#1565c0").border("1px solid #90caf9").padding("4px 12px").rounded("6px").bold().build();
|
|
3132
|
+
const format = `%c📁 ${label}`;
|
|
3133
|
+
if (collapsed) {
|
|
3134
|
+
console.groupCollapsed(format, groupStyle);
|
|
3135
|
+
} else {
|
|
3136
|
+
console.group(format, groupStyle);
|
|
3137
|
+
}
|
|
3138
|
+
this.groupDepth++;
|
|
3139
|
+
}
|
|
3140
|
+
/**
|
|
3141
|
+
* Ends the current console group
|
|
3142
|
+
*/
|
|
3143
|
+
groupEnd() {
|
|
3144
|
+
if (this.groupDepth > 0) {
|
|
3145
|
+
console.groupEnd();
|
|
3146
|
+
this.groupDepth--;
|
|
3147
|
+
}
|
|
3148
|
+
}
|
|
3149
|
+
// ===== PERFORMANCE TIMING =====
|
|
3150
|
+
/**
|
|
3151
|
+
* Starts a timer with the given label
|
|
3152
|
+
*/
|
|
3153
|
+
time(label) {
|
|
3154
|
+
const timer = {
|
|
3155
|
+
label,
|
|
3156
|
+
startTime: performance.now()
|
|
3157
|
+
};
|
|
3158
|
+
this.timers.set(label, timer);
|
|
3159
|
+
const timerStyle = StylePresets.warning().build();
|
|
3160
|
+
console.log(`%c⏱️ Timer started: ${label}`, timerStyle);
|
|
3161
|
+
}
|
|
3162
|
+
/**
|
|
3163
|
+
* Ends a timer and logs the elapsed time
|
|
3164
|
+
*/
|
|
3165
|
+
timeEnd(label) {
|
|
3166
|
+
const timer = this.timers.get(label);
|
|
3167
|
+
if (!timer) {
|
|
3168
|
+
this.warn(`Timer '${label}' does not exist`);
|
|
3169
|
+
return;
|
|
3170
|
+
}
|
|
3171
|
+
const elapsed = performance.now() - timer.startTime;
|
|
3172
|
+
this.timers.delete(label);
|
|
3173
|
+
const timerStyle = StylePresets.success().build();
|
|
3174
|
+
console.log(`%c⏱️ Timer ended: ${label} - ${elapsed.toFixed(2)}ms`, timerStyle);
|
|
3175
|
+
}
|
|
3176
|
+
// ===== ADVANCED VISUAL FEATURES =====
|
|
3177
|
+
/**
|
|
3178
|
+
* Display banner with specified or configured type
|
|
3179
|
+
*/
|
|
3180
|
+
showBanner(bannerType) {
|
|
3181
|
+
const effectiveBannerType = bannerType ? bannerType : this.config.bannerType;
|
|
3182
|
+
displayInitBanner(effectiveBannerType);
|
|
3183
|
+
}
|
|
3184
|
+
/**
|
|
3185
|
+
* Log with SVG background image
|
|
3186
|
+
*/
|
|
3187
|
+
logWithSVG(message, svgContent, options = {}) {
|
|
3188
|
+
const { width = 300, height = 60, padding = "30px 150px" } = options;
|
|
3189
|
+
let svgDataUri = "";
|
|
3190
|
+
if (svgContent) {
|
|
3191
|
+
const encodedSVG = encodeURIComponent(svgContent);
|
|
3192
|
+
svgDataUri = `data:image/svg+xml,${encodedSVG}`;
|
|
3193
|
+
} else {
|
|
3194
|
+
const defaultSVG = `<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${width} ${height}'><defs><linearGradient id='grad' x1='0%' y1='0%' x2='100%' y2='0%'><stop offset='0%' style='stop-color:%23667eea'/><stop offset='100%' style='stop-color:%23764ba2'/></linearGradient></defs><rect width='100%' height='100%' fill='url(%23grad)' rx='4'/><text x='${width / 2}' y='${height / 2 + 5}' text-anchor='middle' fill='white' font-family='monospace' font-size='14' font-weight='bold'>${message}</text></svg>`;
|
|
3195
|
+
svgDataUri = `data:image/svg+xml,${encodeURIComponent(defaultSVG)}`;
|
|
3196
|
+
}
|
|
3197
|
+
const svgStyle = new StyleBuilder().bg(`url("${svgDataUri}") no-repeat center center`).padding(padding).color("transparent").rounded("4px").build();
|
|
3198
|
+
console.log(`%c${message}`, svgStyle);
|
|
3199
|
+
}
|
|
3200
|
+
/**
|
|
3201
|
+
* Log with animated background gradient
|
|
3202
|
+
*/
|
|
3203
|
+
logAnimated(message, duration = 3) {
|
|
3204
|
+
if (!document.getElementById("logger-animations")) {
|
|
3205
|
+
const style = document.createElement("style");
|
|
3206
|
+
style.id = "logger-animations";
|
|
3207
|
+
style.textContent = `
|
|
3208
|
+
@keyframes loggerGradient {
|
|
3209
|
+
0% { background-position: 0% 50%; }
|
|
3210
|
+
50% { background-position: 100% 50%; }
|
|
3211
|
+
100% { background-position: 0% 50%; }
|
|
3212
|
+
}
|
|
3213
|
+
`;
|
|
3214
|
+
document.head.appendChild(style);
|
|
3215
|
+
}
|
|
3216
|
+
const animatedStyle = new StyleBuilder().bg("linear-gradient(-45deg, #667eea, #764ba2, #667eea, #764ba2)").css("background-size", "400% 400%").color("#ffffff").padding("12px 20px").rounded("8px").bold().font("Monaco, Consolas, monospace").animation(`loggerGradient ${duration}s ease infinite`).display("inline-block").build();
|
|
3217
|
+
console.log(`%c${message}`, animatedStyle);
|
|
3218
|
+
}
|
|
3219
|
+
/**
|
|
3220
|
+
* Groups logs by a specific property using modern Object.groupBy (when available)
|
|
3221
|
+
*/
|
|
3222
|
+
logGrouped(items, groupBy) {
|
|
3223
|
+
try {
|
|
3224
|
+
let grouped;
|
|
3225
|
+
if (Object.groupBy) {
|
|
3226
|
+
grouped = Object.groupBy(items, groupBy);
|
|
3227
|
+
} else {
|
|
3228
|
+
grouped = items.reduce((acc, item) => {
|
|
3229
|
+
const key = groupBy(item);
|
|
3230
|
+
if (!acc[key]) {
|
|
3231
|
+
acc[key] = [];
|
|
3232
|
+
}
|
|
3233
|
+
acc[key].push(item);
|
|
3234
|
+
return acc;
|
|
3235
|
+
}, {});
|
|
3236
|
+
}
|
|
3237
|
+
Object.entries(grouped).forEach(([group2, groupItems]) => {
|
|
3238
|
+
this.group(`Group: ${group2}`);
|
|
3239
|
+
this.table(groupItems);
|
|
3240
|
+
this.groupEnd();
|
|
3241
|
+
});
|
|
3242
|
+
} catch {
|
|
3243
|
+
this.info("Grouped data:", items);
|
|
3244
|
+
}
|
|
3245
|
+
}
|
|
3246
|
+
// ===== CLI SYSTEM =====
|
|
3247
|
+
/**
|
|
3248
|
+
* CLI command processor for logger configuration and export
|
|
3249
|
+
*/
|
|
3250
|
+
async cli(command) {
|
|
3251
|
+
if (!this.cliProcessor) {
|
|
3252
|
+
this.error("CLI processor not initialized");
|
|
3253
|
+
return;
|
|
3254
|
+
}
|
|
3255
|
+
await this.cliProcessor.processCommand(command, this);
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
new Logger({
|
|
3259
|
+
verbosity: "info",
|
|
3260
|
+
enableColors: true,
|
|
3261
|
+
enableTimestamps: true,
|
|
3262
|
+
enableStackTrace: true,
|
|
3263
|
+
bufferSize: 1e3
|
|
3264
|
+
// Enable export functionality by default
|
|
3265
|
+
});
|
|
3266
|
+
displayInitBanner();
|
|
3267
|
+
export {
|
|
3268
|
+
BANNER_VARIANTS as B,
|
|
3269
|
+
ExportLogHandler as E,
|
|
3270
|
+
Logger as L,
|
|
3271
|
+
THEME_PRESETS as T,
|
|
3272
|
+
THEME_BANNERS as a,
|
|
3273
|
+
displayInitBanner as d
|
|
3274
|
+
};
|
|
3275
|
+
//# sourceMappingURL=Logger-Didxtr23.js.map
|