@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
|
@@ -1,978 +0,0 @@
|
|
|
1
|
-
import { E as EXPORT_FORMATS, D as DEFAULT_CONFIG, a as parseStackTrace, c as createStyledOutput, b as formatTimestamp } from "./core-2opW4Pi3.js";
|
|
2
|
-
import { T as THEME_PRESETS, S as StyleBuilder, B as BANNER_VARIANTS, d as displayInitBanner, b as THEME_BANNERS, a as StylePresets } from "./styling-DhUDzwlE.js";
|
|
3
|
-
import { E as ExportLogHandler } from "./exports-BNP3R7dp.js";
|
|
4
|
-
class CommandProcessor {
|
|
5
|
-
commands = /* @__PURE__ */ new Map();
|
|
6
|
-
/**
|
|
7
|
-
* Register a command
|
|
8
|
-
*/
|
|
9
|
-
registerCommand(command) {
|
|
10
|
-
this.commands.set(command.name, command);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Get all registered commands
|
|
14
|
-
*/
|
|
15
|
-
getCommands() {
|
|
16
|
-
return Array.from(this.commands.values());
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Get a specific command
|
|
20
|
-
*/
|
|
21
|
-
getCommand(name) {
|
|
22
|
-
return this.commands.get(name);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Process a CLI command
|
|
26
|
-
*/
|
|
27
|
-
async processCommand(commandString, logger) {
|
|
28
|
-
if (!commandString.startsWith("/")) {
|
|
29
|
-
logger.error("Invalid command. Commands must start with /");
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const parts = commandString.slice(1).split(" ");
|
|
33
|
-
const commandName = parts[0] || "";
|
|
34
|
-
const args = parts.slice(1).join(" ");
|
|
35
|
-
const command = this.commands.get(commandName);
|
|
36
|
-
if (!command) {
|
|
37
|
-
logger.error(`Unknown command: ${commandName}. Type /help for available commands.`);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
await command.execute(args || "", logger);
|
|
42
|
-
} catch (error) {
|
|
43
|
-
logger.error(`Command '${commandName}' failed:`, error);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Get command suggestions for partial matches
|
|
48
|
-
*/
|
|
49
|
-
getSuggestions(partial) {
|
|
50
|
-
const commandNames = Array.from(this.commands.keys());
|
|
51
|
-
return commandNames.filter((name) => name.startsWith(partial));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
class ConfigCommand {
|
|
55
|
-
name = "config";
|
|
56
|
-
description = "Show or update logger configuration";
|
|
57
|
-
usage = "/config [json|key=value,...]";
|
|
58
|
-
execute(args, logger) {
|
|
59
|
-
if (!args) {
|
|
60
|
-
this.showStatus(logger);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
if (args.startsWith("{")) {
|
|
65
|
-
const config = JSON.parse(args);
|
|
66
|
-
this.applyConfig(config, logger);
|
|
67
|
-
} else {
|
|
68
|
-
const pairs = args.split(",").map((pair) => pair.trim().split("="));
|
|
69
|
-
const config = {};
|
|
70
|
-
pairs.forEach(([key, value]) => {
|
|
71
|
-
if (key && value) {
|
|
72
|
-
config[key.trim()] = value.trim().replace(/["']/g, "");
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
this.applyConfig(config, logger);
|
|
76
|
-
}
|
|
77
|
-
} catch (error) {
|
|
78
|
-
logger.error("Invalid config format. Use JSON or key=value pairs:", error);
|
|
79
|
-
logger.info('Examples: /config {"theme":"dark"} or /config theme=neon,verbosity=debug');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
showStatus(logger) {
|
|
83
|
-
const statusData = {
|
|
84
|
-
theme: logger.getConfig().theme || "default",
|
|
85
|
-
verbosity: logger.getConfig().verbosity,
|
|
86
|
-
colors: logger.getConfig().enableColors,
|
|
87
|
-
timestamps: logger.getConfig().enableTimestamps,
|
|
88
|
-
stackTrace: logger.getConfig().enableStackTrace,
|
|
89
|
-
globalPrefix: logger.getConfig().globalPrefix || "none",
|
|
90
|
-
bannerType: logger.getConfig().bannerType || "simple",
|
|
91
|
-
handlers: logger.getHandlers().length
|
|
92
|
-
};
|
|
93
|
-
logger.group("⚙️ Logger Configuration");
|
|
94
|
-
logger.table(statusData);
|
|
95
|
-
logger.groupEnd();
|
|
96
|
-
}
|
|
97
|
-
applyConfig(config, logger) {
|
|
98
|
-
const validKeys = ["theme", "verbosity", "enableColors", "enableTimestamps", "enableStackTrace", "globalPrefix", "bannerType"];
|
|
99
|
-
const applied = [];
|
|
100
|
-
Object.entries(config).forEach(([key, value]) => {
|
|
101
|
-
if (validKeys.includes(key)) {
|
|
102
|
-
if (key === "theme" && typeof value === "string") {
|
|
103
|
-
logger.setTheme(value);
|
|
104
|
-
applied.push(`${key}=${value}`);
|
|
105
|
-
} else if (key === "bannerType" && typeof value === "string") {
|
|
106
|
-
logger.setBannerType(value);
|
|
107
|
-
applied.push(`${key}=${value}`);
|
|
108
|
-
} else if (key === "verbosity") {
|
|
109
|
-
logger.setVerbosity(value);
|
|
110
|
-
applied.push(`${key}=${value}`);
|
|
111
|
-
} else if (key === "globalPrefix") {
|
|
112
|
-
logger.setGlobalPrefix(value);
|
|
113
|
-
applied.push(`${key}=${value}`);
|
|
114
|
-
} else {
|
|
115
|
-
logger.updateConfig({ [key]: value });
|
|
116
|
-
applied.push(`${key}=${value}`);
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
logger.warn(`Invalid config key: ${key}`);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
if (applied.length > 0) {
|
|
123
|
-
logger.success(`Configuration updated: ${applied.join(", ")}`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
class ThemesCommand {
|
|
128
|
-
name = "themes";
|
|
129
|
-
description = "Show available theme presets";
|
|
130
|
-
usage = "/themes";
|
|
131
|
-
execute(_args, logger) {
|
|
132
|
-
logger.group("🎨 Available Themes");
|
|
133
|
-
Object.keys(THEME_PRESETS).forEach((themeName) => {
|
|
134
|
-
const preview = THEME_PRESETS[themeName];
|
|
135
|
-
const previewStyle = new StyleBuilder().bg(preview.info.background).color(preview.info.color).padding("4px 8px").rounded("4px").border(preview.info.border).build();
|
|
136
|
-
console.log(`%c${themeName}`, previewStyle, `- ${themeName} theme preview`);
|
|
137
|
-
});
|
|
138
|
-
logger.groupEnd();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
class BannersCommand {
|
|
142
|
-
name = "banners";
|
|
143
|
-
description = "Show available banner types";
|
|
144
|
-
usage = "/banners";
|
|
145
|
-
execute(_args, logger) {
|
|
146
|
-
logger.group("🖼️ Available Banner Types");
|
|
147
|
-
Object.keys(BANNER_VARIANTS).forEach((bannerName) => {
|
|
148
|
-
const banner = BANNER_VARIANTS[bannerName];
|
|
149
|
-
console.log(`%c${bannerName}`, "font-weight: bold; color: #667eea;");
|
|
150
|
-
console.log(`%cPreview:`, "color: #666; font-size: 12px;");
|
|
151
|
-
if (bannerName === "simple") {
|
|
152
|
-
console.log(`%c${banner.text}`, banner.style);
|
|
153
|
-
} else if (bannerName === "ascii") {
|
|
154
|
-
console.log(`%c${banner.text.split("\n").slice(1, 4).join("\n")}...`, "font-family: monospace; color: #667eea; font-size: 10px;");
|
|
155
|
-
} else if (bannerName === "unicode") {
|
|
156
|
-
console.log(`%c${banner.text}`, banner.style);
|
|
157
|
-
} else {
|
|
158
|
-
console.log(`%c${bannerName} banner`, "color: #666; font-style: italic;");
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
logger.groupEnd();
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
class BannerCommand {
|
|
165
|
-
name = "banner";
|
|
166
|
-
description = "Change or show current banner type";
|
|
167
|
-
usage = "/banner [type]";
|
|
168
|
-
execute(args, logger) {
|
|
169
|
-
if (!args) {
|
|
170
|
-
logger.showBanner();
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
if (args in BANNER_VARIANTS) {
|
|
174
|
-
logger.setBannerType(args);
|
|
175
|
-
logger.showBanner();
|
|
176
|
-
} else {
|
|
177
|
-
logger.error(`Invalid banner type: ${args}. Available: ${Object.keys(BANNER_VARIANTS).join(", ")}`);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
class StatusCommand {
|
|
182
|
-
name = "status";
|
|
183
|
-
description = "Show current logger status and configuration";
|
|
184
|
-
usage = "/status";
|
|
185
|
-
execute(_args, logger) {
|
|
186
|
-
const config = logger.getConfig();
|
|
187
|
-
const statusData = {
|
|
188
|
-
theme: config.theme ? config.theme : "default",
|
|
189
|
-
verbosity: config.verbosity,
|
|
190
|
-
colors: config.enableColors,
|
|
191
|
-
timestamps: config.enableTimestamps,
|
|
192
|
-
stackTrace: config.enableStackTrace,
|
|
193
|
-
globalPrefix: config.globalPrefix ? config.globalPrefix : "none",
|
|
194
|
-
bannerType: config.bannerType ? config.bannerType : "simple",
|
|
195
|
-
handlers: logger.getHandlers().length,
|
|
196
|
-
bufferSize: config.bufferSize ? config.bufferSize : 1e3
|
|
197
|
-
};
|
|
198
|
-
logger.group("⚙️ Logger Configuration");
|
|
199
|
-
logger.table(statusData);
|
|
200
|
-
logger.groupEnd();
|
|
201
|
-
const exportHandler = logger.getExportHandler();
|
|
202
|
-
if (exportHandler) {
|
|
203
|
-
const bufferStats = exportHandler.getBufferStats();
|
|
204
|
-
logger.group("📊 Buffer Statistics");
|
|
205
|
-
logger.table({
|
|
206
|
-
size: `${bufferStats.size}/${bufferStats.maxSize}`,
|
|
207
|
-
usage: `${bufferStats.usage.toFixed(1)}%`,
|
|
208
|
-
oldestLog: bufferStats.oldestLog ? bufferStats.oldestLog.toISOString() : "None",
|
|
209
|
-
newestLog: bufferStats.newestLog ? bufferStats.newestLog.toISOString() : "None",
|
|
210
|
-
errorCount: bufferStats.levelCounts.error + bufferStats.levelCounts.critical,
|
|
211
|
-
warningCount: bufferStats.levelCounts.warn
|
|
212
|
-
});
|
|
213
|
-
logger.groupEnd();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
class ResetCommand {
|
|
218
|
-
name = "reset";
|
|
219
|
-
description = "Reset logger configuration to defaults";
|
|
220
|
-
usage = "/reset";
|
|
221
|
-
execute(_args, logger) {
|
|
222
|
-
logger.resetConfig();
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
class DemoCommand {
|
|
226
|
-
name = "demo";
|
|
227
|
-
description = "Show comprehensive feature demonstration";
|
|
228
|
-
usage = "/demo";
|
|
229
|
-
execute(_args, logger) {
|
|
230
|
-
logger.group("🎪 Advanced Logger Demo");
|
|
231
|
-
logger.debug("Debug message with detailed information");
|
|
232
|
-
logger.info("Informational message about system state");
|
|
233
|
-
logger.warn("Warning about deprecated feature");
|
|
234
|
-
logger.error("Error processing user request");
|
|
235
|
-
logger.success("Operation completed successfully");
|
|
236
|
-
logger.critical("Critical system failure detected");
|
|
237
|
-
logger.group("📊 Advanced Features Demo");
|
|
238
|
-
logger.table([
|
|
239
|
-
{ feature: "Styled Console", status: "✅ Active", performance: "Excellent" },
|
|
240
|
-
{ feature: "Theme System", status: "✅ Active", performance: "Great" },
|
|
241
|
-
{ feature: "CLI Interface", status: "✅ Active", performance: "Good" },
|
|
242
|
-
{ feature: "Export System", status: "✅ Active", performance: "Excellent" }
|
|
243
|
-
]);
|
|
244
|
-
logger.time("demo-operation");
|
|
245
|
-
setTimeout(() => {
|
|
246
|
-
logger.timeEnd("demo-operation");
|
|
247
|
-
}, 100);
|
|
248
|
-
logger.logWithSVG("SVG Demo");
|
|
249
|
-
logger.logAnimated("🌟 Animated Logger Demo 🌟", 2);
|
|
250
|
-
logger.groupEnd();
|
|
251
|
-
logger.groupEnd();
|
|
252
|
-
logger.info("Demo completed! Check the console for styled output.");
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function parseArguments(args) {
|
|
256
|
-
const filters = {};
|
|
257
|
-
const options = {};
|
|
258
|
-
let format;
|
|
259
|
-
if (!args.trim()) return { filters, options };
|
|
260
|
-
const argParts = args.match(/(?:[^\s"]+|"[^"]*")+/g) || [];
|
|
261
|
-
for (let i = 0; i < argParts.length; i++) {
|
|
262
|
-
const arg = argParts[i];
|
|
263
|
-
if (!arg) {
|
|
264
|
-
continue;
|
|
265
|
-
}
|
|
266
|
-
if (i === 0 && !arg.startsWith("--") && arg in EXPORT_FORMATS) {
|
|
267
|
-
format = arg;
|
|
268
|
-
continue;
|
|
269
|
-
}
|
|
270
|
-
if (arg.startsWith("--")) {
|
|
271
|
-
const [flag, value] = arg.slice(2).split("=");
|
|
272
|
-
switch (flag) {
|
|
273
|
-
case "level":
|
|
274
|
-
case "levels":
|
|
275
|
-
if (value) {
|
|
276
|
-
filters.levels = value.split(",").map((l) => l.trim());
|
|
277
|
-
}
|
|
278
|
-
break;
|
|
279
|
-
case "since":
|
|
280
|
-
if (value) filters.since = value;
|
|
281
|
-
break;
|
|
282
|
-
case "until":
|
|
283
|
-
if (value) filters.until = value;
|
|
284
|
-
break;
|
|
285
|
-
case "prefix":
|
|
286
|
-
case "prefixes":
|
|
287
|
-
if (value) {
|
|
288
|
-
filters.prefixes = value.split(",").map((p) => p.trim());
|
|
289
|
-
}
|
|
290
|
-
break;
|
|
291
|
-
case "exclude-prefix":
|
|
292
|
-
case "exclude-prefixes":
|
|
293
|
-
if (value) {
|
|
294
|
-
filters.excludePrefixes = value.split(",").map((p) => p.trim());
|
|
295
|
-
}
|
|
296
|
-
break;
|
|
297
|
-
case "last":
|
|
298
|
-
if (value) filters.last = parseInt(value, 10);
|
|
299
|
-
break;
|
|
300
|
-
case "first":
|
|
301
|
-
if (value) filters.first = parseInt(value, 10);
|
|
302
|
-
break;
|
|
303
|
-
case "search":
|
|
304
|
-
if (value) filters.search = value.replace(/['"]/g, "");
|
|
305
|
-
break;
|
|
306
|
-
case "with-stack":
|
|
307
|
-
filters.withStackTrace = true;
|
|
308
|
-
break;
|
|
309
|
-
case "errors-only":
|
|
310
|
-
filters.errorsOnly = true;
|
|
311
|
-
break;
|
|
312
|
-
case "group-by":
|
|
313
|
-
if (value) {
|
|
314
|
-
filters.groupBy = value;
|
|
315
|
-
options.groupBy = value;
|
|
316
|
-
}
|
|
317
|
-
break;
|
|
318
|
-
case "minimal":
|
|
319
|
-
options.minimal = true;
|
|
320
|
-
break;
|
|
321
|
-
case "compact":
|
|
322
|
-
options.compact = true;
|
|
323
|
-
break;
|
|
324
|
-
case "styled":
|
|
325
|
-
options.styled = true;
|
|
326
|
-
break;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
return { filters, options, format };
|
|
331
|
-
}
|
|
332
|
-
class ExportCommand {
|
|
333
|
-
name = "export";
|
|
334
|
-
description = "Export logs to various formats";
|
|
335
|
-
usage = "/export <format> [--filter=value] [--option]";
|
|
336
|
-
execute(args, logger) {
|
|
337
|
-
const exportHandler = logger.getExportHandler();
|
|
338
|
-
if (!exportHandler) {
|
|
339
|
-
logger.error("Export handler not available. Make sure ExportLogHandler is registered.");
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
const { filters, options, format } = parseArguments(args);
|
|
343
|
-
if (!format) {
|
|
344
|
-
logger.error("Format required. Available formats: " + Object.keys(EXPORT_FORMATS).join(", "));
|
|
345
|
-
logger.info("Usage: /export <format> [--filter=value]");
|
|
346
|
-
logger.info("Example: /export json --level=error,warn --last=50");
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
try {
|
|
350
|
-
const result = exportHandler.export(format, filters, options);
|
|
351
|
-
logger.success(`✅ Export completed: ${result.metadata.filteredLogs} logs exported in ${format} format`);
|
|
352
|
-
if (result.data.length < 1e3) {
|
|
353
|
-
logger.group(`📄 Preview (${format.toUpperCase()})`);
|
|
354
|
-
console.log(result.data);
|
|
355
|
-
logger.groupEnd();
|
|
356
|
-
} else {
|
|
357
|
-
logger.info(`📄 Export size: ${(result.data.length / 1024).toFixed(2)}KB`);
|
|
358
|
-
}
|
|
359
|
-
logger.table({
|
|
360
|
-
format: result.format,
|
|
361
|
-
totalLogs: result.metadata.totalLogs,
|
|
362
|
-
filtered: result.metadata.filteredLogs,
|
|
363
|
-
exported: result.metadata.exportedAt
|
|
364
|
-
});
|
|
365
|
-
} catch (error) {
|
|
366
|
-
logger.error("Export failed:", error);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
class CopyCommand {
|
|
371
|
-
name = "copy";
|
|
372
|
-
description = "Copy logs to clipboard";
|
|
373
|
-
usage = "/copy <format> [--filter=value] [--option]";
|
|
374
|
-
async execute(args, logger) {
|
|
375
|
-
const exportHandler = logger.getExportHandler();
|
|
376
|
-
if (!exportHandler) {
|
|
377
|
-
logger.error("Export handler not available. Make sure ExportLogHandler is registered.");
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
const { filters, options, format } = parseArguments(args);
|
|
381
|
-
if (!format) {
|
|
382
|
-
logger.error("Format required. Available formats: " + Object.keys(EXPORT_FORMATS).join(", "));
|
|
383
|
-
logger.info("Usage: /copy <format> [--filter=value]");
|
|
384
|
-
logger.info("Example: /copy plain --level=error --last=25");
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
try {
|
|
388
|
-
const success = await exportHandler.copyToClipboard(format, filters, options);
|
|
389
|
-
if (success) {
|
|
390
|
-
const result = exportHandler.export(format, filters, options);
|
|
391
|
-
logger.success(`📋 Copied ${result.metadata.filteredLogs} logs to clipboard (${format} format)`);
|
|
392
|
-
} else {
|
|
393
|
-
logger.error("Failed to copy to clipboard. Browser may not support clipboard API.");
|
|
394
|
-
}
|
|
395
|
-
} catch (error) {
|
|
396
|
-
logger.error("Copy failed:", error);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
class BufferSizeCommand {
|
|
401
|
-
name = "buffer-size";
|
|
402
|
-
description = "Set log buffer size";
|
|
403
|
-
usage = "/buffer-size <size>";
|
|
404
|
-
execute(args, logger) {
|
|
405
|
-
const exportHandler = logger.getExportHandler();
|
|
406
|
-
if (!exportHandler) {
|
|
407
|
-
logger.error("Export handler not available.");
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
const size = parseInt(args.trim(), 10);
|
|
411
|
-
if (isNaN(size) || size <= 0) {
|
|
412
|
-
logger.error("Invalid buffer size. Must be a positive number.");
|
|
413
|
-
logger.info("Example: /buffer-size 2000");
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
exportHandler.setBufferSize(size);
|
|
417
|
-
logger.success(`Buffer size set to ${size}`);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
class ClearBufferCommand {
|
|
421
|
-
name = "clear-buffer";
|
|
422
|
-
description = "Clear the log buffer";
|
|
423
|
-
usage = "/clear-buffer";
|
|
424
|
-
execute(_args, logger) {
|
|
425
|
-
const exportHandler = logger.getExportHandler();
|
|
426
|
-
if (!exportHandler) {
|
|
427
|
-
logger.error("Export handler not available.");
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
const stats = exportHandler.getBufferStats();
|
|
431
|
-
exportHandler.clearBuffer();
|
|
432
|
-
logger.success(`✅ Buffer cleared. Removed ${stats.size} log entries.`);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
class BufferInfoCommand {
|
|
436
|
-
name = "buffer-info";
|
|
437
|
-
description = "Show buffer statistics and information";
|
|
438
|
-
usage = "/buffer-info";
|
|
439
|
-
execute(_args, logger) {
|
|
440
|
-
const exportHandler = logger.getExportHandler();
|
|
441
|
-
if (!exportHandler) {
|
|
442
|
-
logger.error("Export handler not available.");
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
const stats = exportHandler.getBufferStats();
|
|
446
|
-
logger.group("📊 Buffer Information");
|
|
447
|
-
logger.table({
|
|
448
|
-
size: `${stats.size}/${stats.maxSize}`,
|
|
449
|
-
usage: `${stats.usage.toFixed(1)}%`,
|
|
450
|
-
oldestLog: stats.oldestLog?.toLocaleString() || "None",
|
|
451
|
-
newestLog: stats.newestLog?.toLocaleString() || "None"
|
|
452
|
-
});
|
|
453
|
-
logger.group("📈 Log Level Counts");
|
|
454
|
-
logger.table(stats.levelCounts);
|
|
455
|
-
logger.groupEnd();
|
|
456
|
-
logger.groupEnd();
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
class HelpCommand {
|
|
460
|
-
name = "help";
|
|
461
|
-
description = "Show CLI help and available commands";
|
|
462
|
-
usage = "/help [command]";
|
|
463
|
-
execute(_args, logger) {
|
|
464
|
-
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();
|
|
465
|
-
const helpText = `
|
|
466
|
-
╭─────────────── ADVANCED LOGGER CLI COMMANDS ─────────────────╮
|
|
467
|
-
│ │
|
|
468
|
-
│ CONFIGURATION │
|
|
469
|
-
│ /config Show current configuration │
|
|
470
|
-
│ /config {json} Apply JSON configuration │
|
|
471
|
-
│ /config key=val Apply key-value configuration │
|
|
472
|
-
│ /themes Show available themes │
|
|
473
|
-
│ /banners Show available banner types │
|
|
474
|
-
│ /banner [type] Change/show banner type │
|
|
475
|
-
│ /status Show logger status & buffer stats │
|
|
476
|
-
│ /demo Show feature demonstration │
|
|
477
|
-
│ /reset Reset to default configuration │
|
|
478
|
-
│ │
|
|
479
|
-
│ EXPORT & CLIPBOARD │
|
|
480
|
-
│ /export <format> Export logs (json|csv|md|plain|html) │
|
|
481
|
-
│ /copy <format> Copy logs to clipboard │
|
|
482
|
-
│ /buffer-size N Set log buffer size │
|
|
483
|
-
│ /buffer-info Show buffer statistics │
|
|
484
|
-
│ /clear-buffer Clear stored logs │
|
|
485
|
-
│ │
|
|
486
|
-
│ EXPORT FILTERS (for export/copy commands) │
|
|
487
|
-
│ --level error,warn Filter by log levels │
|
|
488
|
-
│ --since 2h Logs from last 2 hours │
|
|
489
|
-
│ --until 1h Logs until 1 hour ago │
|
|
490
|
-
│ --prefix API,DB Filter by prefixes │
|
|
491
|
-
│ --exclude-prefix INT Exclude prefixes │
|
|
492
|
-
│ --last 50 Last 50 logs only │
|
|
493
|
-
│ --first 25 First 25 logs only │
|
|
494
|
-
│ --search "error" Search in log messages │
|
|
495
|
-
│ --with-stack Only logs with stack traces │
|
|
496
|
-
│ --errors-only Only error + critical logs │
|
|
497
|
-
│ --group-by level Group by level/prefix/hour │
|
|
498
|
-
│ │
|
|
499
|
-
│ EXPORT OPTIONS │
|
|
500
|
-
│ --minimal Minimal output format │
|
|
501
|
-
│ --compact Remove extra whitespace │
|
|
502
|
-
│ --styled Include styling (HTML format) │
|
|
503
|
-
│ │
|
|
504
|
-
├──────────────────── CONFIGURATION OPTIONS ─────────────────┤
|
|
505
|
-
│ │
|
|
506
|
-
│ theme: default | dark | light | neon | minimal | cyberpunk│
|
|
507
|
-
│ bannerType: simple | ascii | unicode | svg | animated │
|
|
508
|
-
│ verbosity: debug | info | warn | error | critical | silent│
|
|
509
|
-
│ enableColors: true | false │
|
|
510
|
-
│ enableTimestamps: true | false │
|
|
511
|
-
│ enableStackTrace: true | false │
|
|
512
|
-
│ globalPrefix: "string" │
|
|
513
|
-
│ bufferSize: number (50-10000) │
|
|
514
|
-
│ │
|
|
515
|
-
├──────────────────────── EXAMPLES ──────────────────────────┤
|
|
516
|
-
│ │
|
|
517
|
-
│ Basic Configuration: │
|
|
518
|
-
│ /config {"theme":"dark","verbosity":"debug"} │
|
|
519
|
-
│ /config theme=neon,bufferSize=2000 │
|
|
520
|
-
│ /banner animated Change to animated banner │
|
|
521
|
-
│ │
|
|
522
|
-
│ Export Examples: │
|
|
523
|
-
│ /export json --level=error,warn --last=25 │
|
|
524
|
-
│ /export csv --since=2h --prefix=API │
|
|
525
|
-
│ /export markdown --group-by=level --errors-only │
|
|
526
|
-
│ /export html --styled --since=1h │
|
|
527
|
-
│ │
|
|
528
|
-
│ Clipboard Examples: │
|
|
529
|
-
│ /copy plain --minimal --last=10 │
|
|
530
|
-
│ /copy json --search="authentication" --compact │
|
|
531
|
-
│ /copy csv --since=30m --exclude-prefix=DEBUG │
|
|
532
|
-
│ │
|
|
533
|
-
│ Buffer Management: │
|
|
534
|
-
│ /buffer-size 5000 Increase buffer to 5000 logs │
|
|
535
|
-
│ /buffer-info Show detailed buffer statistics │
|
|
536
|
-
│ /clear-buffer Clear all stored logs │
|
|
537
|
-
│ │
|
|
538
|
-
│ Time Formats: │
|
|
539
|
-
│ --since=2h 2 hours ago │
|
|
540
|
-
│ --since=30m 30 minutes ago │
|
|
541
|
-
│ --since=1d 1 day ago │
|
|
542
|
-
│ --since="2024-01-01T10:00:00Z" Specific ISO date │
|
|
543
|
-
│ │
|
|
544
|
-
╰─────────────────────────────────────────────────────────────╯`;
|
|
545
|
-
console.log(`%c${helpText}`, helpStyle);
|
|
546
|
-
logger.group("💡 Quick Tips");
|
|
547
|
-
const tips = [
|
|
548
|
-
"Use /demo to see all logger features in action",
|
|
549
|
-
"Logs are automatically stored in a circular buffer for export",
|
|
550
|
-
"Export formats: JSON (structured), CSV (Excel), Markdown (readable), Plain (simple), HTML (styled)",
|
|
551
|
-
"Time filters support relative (2h, 30m) and absolute (ISO) formats",
|
|
552
|
-
'Combine multiple filters: /export json --level=error --since=1h --search="auth"',
|
|
553
|
-
"Use /copy for quick clipboard access instead of /export"
|
|
554
|
-
];
|
|
555
|
-
tips.forEach((tip) => {
|
|
556
|
-
logger.info(`• ${tip}`);
|
|
557
|
-
});
|
|
558
|
-
logger.groupEnd();
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
function createDefaultCLI() {
|
|
562
|
-
const processor = new CommandProcessor();
|
|
563
|
-
processor.registerCommand(new HelpCommand());
|
|
564
|
-
processor.registerCommand(new ConfigCommand());
|
|
565
|
-
processor.registerCommand(new ThemesCommand());
|
|
566
|
-
processor.registerCommand(new BannersCommand());
|
|
567
|
-
processor.registerCommand(new BannerCommand());
|
|
568
|
-
processor.registerCommand(new StatusCommand());
|
|
569
|
-
processor.registerCommand(new ResetCommand());
|
|
570
|
-
processor.registerCommand(new DemoCommand());
|
|
571
|
-
processor.registerCommand(new ExportCommand());
|
|
572
|
-
processor.registerCommand(new CopyCommand());
|
|
573
|
-
processor.registerCommand(new BufferSizeCommand());
|
|
574
|
-
processor.registerCommand(new ClearBufferCommand());
|
|
575
|
-
processor.registerCommand(new BufferInfoCommand());
|
|
576
|
-
return processor;
|
|
577
|
-
}
|
|
578
|
-
let LEVEL_STYLES = THEME_PRESETS.default;
|
|
579
|
-
class Logger {
|
|
580
|
-
config;
|
|
581
|
-
scopedPrefix;
|
|
582
|
-
handlers = [];
|
|
583
|
-
timers = /* @__PURE__ */ new Map();
|
|
584
|
-
groupDepth = 0;
|
|
585
|
-
exportHandler;
|
|
586
|
-
cliProcessor;
|
|
587
|
-
/**
|
|
588
|
-
* Creates a new Logger instance
|
|
589
|
-
*/
|
|
590
|
-
constructor(config = {}) {
|
|
591
|
-
this.config = {
|
|
592
|
-
...DEFAULT_CONFIG,
|
|
593
|
-
...config
|
|
594
|
-
};
|
|
595
|
-
if (this.config.bufferSize) {
|
|
596
|
-
this.exportHandler = new ExportLogHandler(this.config.bufferSize);
|
|
597
|
-
this.handlers.push(this.exportHandler);
|
|
598
|
-
}
|
|
599
|
-
this.cliProcessor = createDefaultCLI();
|
|
600
|
-
}
|
|
601
|
-
// ===== CONFIGURATION METHODS =====
|
|
602
|
-
/**
|
|
603
|
-
* Get current configuration
|
|
604
|
-
*/
|
|
605
|
-
getConfig() {
|
|
606
|
-
return { ...this.config };
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* Update configuration
|
|
610
|
-
*/
|
|
611
|
-
updateConfig(updates) {
|
|
612
|
-
this.config = { ...this.config, ...updates };
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
* Sets the global prefix for all log messages
|
|
616
|
-
*/
|
|
617
|
-
setGlobalPrefix(prefix) {
|
|
618
|
-
this.config.globalPrefix = prefix;
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Sets the verbosity level for filtering log output
|
|
622
|
-
*/
|
|
623
|
-
setVerbosity(level) {
|
|
624
|
-
this.config.verbosity = level;
|
|
625
|
-
}
|
|
626
|
-
/**
|
|
627
|
-
* Sets the logger theme
|
|
628
|
-
*/
|
|
629
|
-
setTheme(theme) {
|
|
630
|
-
if (theme in THEME_PRESETS) {
|
|
631
|
-
LEVEL_STYLES = THEME_PRESETS[theme];
|
|
632
|
-
this.config.theme = theme;
|
|
633
|
-
if (theme in THEME_BANNERS) {
|
|
634
|
-
const themeBanner = THEME_BANNERS[theme];
|
|
635
|
-
console.log(`%c${themeBanner.simple}`, themeBanner.style);
|
|
636
|
-
}
|
|
637
|
-
this.success(`Theme changed to: ${theme}`);
|
|
638
|
-
} else {
|
|
639
|
-
this.error(`Invalid theme: ${theme}. Available themes:`, Object.keys(THEME_PRESETS));
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* Set banner type for initialization display
|
|
644
|
-
*/
|
|
645
|
-
setBannerType(bannerType) {
|
|
646
|
-
this.config.bannerType = bannerType;
|
|
647
|
-
this.success(`Banner type changed to: ${bannerType}`);
|
|
648
|
-
}
|
|
649
|
-
/**
|
|
650
|
-
* Reset logger to default configuration
|
|
651
|
-
*/
|
|
652
|
-
resetConfig() {
|
|
653
|
-
this.config = { ...DEFAULT_CONFIG };
|
|
654
|
-
LEVEL_STYLES = THEME_PRESETS.default;
|
|
655
|
-
this.success("Logger configuration reset to defaults");
|
|
656
|
-
}
|
|
657
|
-
// ===== SCOPED LOGGER =====
|
|
658
|
-
/**
|
|
659
|
-
* Creates a scoped logger with a specific prefix
|
|
660
|
-
*/
|
|
661
|
-
createScopedLogger(prefix) {
|
|
662
|
-
const scopedLogger = new Logger(this.config);
|
|
663
|
-
scopedLogger.scopedPrefix = prefix;
|
|
664
|
-
scopedLogger.handlers = [...this.handlers];
|
|
665
|
-
scopedLogger.exportHandler = this.exportHandler;
|
|
666
|
-
return scopedLogger;
|
|
667
|
-
}
|
|
668
|
-
// ===== HANDLER MANAGEMENT =====
|
|
669
|
-
/**
|
|
670
|
-
* Adds a custom log handler for extensibility
|
|
671
|
-
*/
|
|
672
|
-
addHandler(handler) {
|
|
673
|
-
this.handlers.push(handler);
|
|
674
|
-
}
|
|
675
|
-
/**
|
|
676
|
-
* Get all registered handlers
|
|
677
|
-
*/
|
|
678
|
-
getHandlers() {
|
|
679
|
-
return [...this.handlers];
|
|
680
|
-
}
|
|
681
|
-
/**
|
|
682
|
-
* Get export handler if available
|
|
683
|
-
*/
|
|
684
|
-
getExportHandler() {
|
|
685
|
-
return this.exportHandler;
|
|
686
|
-
}
|
|
687
|
-
// ===== CORE LOGGING METHODS =====
|
|
688
|
-
/**
|
|
689
|
-
* Checks if a log level should be output based on current verbosity
|
|
690
|
-
*/
|
|
691
|
-
shouldLog(level) {
|
|
692
|
-
if (this.config.verbosity === "silent") return false;
|
|
693
|
-
const levels = { debug: 0, info: 1, warn: 2, error: 3, critical: 4 };
|
|
694
|
-
return levels[level] >= levels[this.config.verbosity];
|
|
695
|
-
}
|
|
696
|
-
/**
|
|
697
|
-
* Gets the effective prefix (global + scoped)
|
|
698
|
-
*/
|
|
699
|
-
getEffectivePrefix() {
|
|
700
|
-
const parts = [this.config.globalPrefix, this.scopedPrefix].filter(Boolean);
|
|
701
|
-
return parts.length > 0 ? parts.join(":") : void 0;
|
|
702
|
-
}
|
|
703
|
-
/**
|
|
704
|
-
* Core logging method that handles styling and formatting
|
|
705
|
-
*/
|
|
706
|
-
log(level, ...args) {
|
|
707
|
-
if (!this.shouldLog(level)) return;
|
|
708
|
-
const stackInfo = this.config.enableStackTrace ? parseStackTrace() : null;
|
|
709
|
-
const prefix = this.getEffectivePrefix();
|
|
710
|
-
const message = args.length > 0 ? String(args[0]) : "";
|
|
711
|
-
const additionalArgs = args.slice(1);
|
|
712
|
-
const [format, ...styles] = createStyledOutput(level, LEVEL_STYLES, prefix, message, stackInfo);
|
|
713
|
-
const groupIndent = " ".repeat(this.groupDepth);
|
|
714
|
-
const finalFormat = groupIndent + format;
|
|
715
|
-
if (additionalArgs.length > 0) {
|
|
716
|
-
console.log(finalFormat, ...styles, ...additionalArgs);
|
|
717
|
-
} else {
|
|
718
|
-
console.log(finalFormat, ...styles);
|
|
719
|
-
}
|
|
720
|
-
if (this.exportHandler) {
|
|
721
|
-
this.exportHandler.setGroupInfo(this.groupDepth);
|
|
722
|
-
}
|
|
723
|
-
const metadata = {
|
|
724
|
-
timestamp: formatTimestamp(),
|
|
725
|
-
level,
|
|
726
|
-
prefix,
|
|
727
|
-
stackInfo: stackInfo ? stackInfo : void 0
|
|
728
|
-
};
|
|
729
|
-
this.handlers.forEach((handler) => {
|
|
730
|
-
try {
|
|
731
|
-
handler.handle(level, message, args, metadata);
|
|
732
|
-
} catch (error2) {
|
|
733
|
-
console.error("Log handler failed:", error2);
|
|
734
|
-
}
|
|
735
|
-
});
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Logs debug information (lowest priority)
|
|
739
|
-
*/
|
|
740
|
-
debug(...args) {
|
|
741
|
-
this.log("debug", ...args);
|
|
742
|
-
}
|
|
743
|
-
/**
|
|
744
|
-
* Logs informational messages
|
|
745
|
-
*/
|
|
746
|
-
info(...args) {
|
|
747
|
-
this.log("info", ...args);
|
|
748
|
-
}
|
|
749
|
-
/**
|
|
750
|
-
* Logs warning messages
|
|
751
|
-
*/
|
|
752
|
-
warn(...args) {
|
|
753
|
-
this.log("warn", ...args);
|
|
754
|
-
}
|
|
755
|
-
/**
|
|
756
|
-
* Logs error messages
|
|
757
|
-
*/
|
|
758
|
-
error(...args) {
|
|
759
|
-
this.log("error", ...args);
|
|
760
|
-
}
|
|
761
|
-
/**
|
|
762
|
-
* Logs success messages (special info level)
|
|
763
|
-
*/
|
|
764
|
-
success(...args) {
|
|
765
|
-
if (!this.shouldLog("info")) return;
|
|
766
|
-
const stackInfo = this.config.enableStackTrace ? parseStackTrace() : null;
|
|
767
|
-
const prefix = this.getEffectivePrefix();
|
|
768
|
-
const message = args.length > 0 ? String(args[0]) : "";
|
|
769
|
-
const additionalArgs = args.slice(1);
|
|
770
|
-
const [format, ...styles] = createStyledOutput("info", LEVEL_STYLES, prefix, message, stackInfo);
|
|
771
|
-
const successStyle = LEVEL_STYLES.success;
|
|
772
|
-
let emoji = "✅";
|
|
773
|
-
let label = "SUCCESS";
|
|
774
|
-
if (successStyle) {
|
|
775
|
-
if (successStyle.emoji) {
|
|
776
|
-
emoji = successStyle.emoji;
|
|
777
|
-
}
|
|
778
|
-
if (successStyle.label) {
|
|
779
|
-
label = successStyle.label;
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
const successFormat = format.replace(/ℹ️ INFO/, `${emoji} ${label}`);
|
|
783
|
-
const groupIndent = " ".repeat(this.groupDepth);
|
|
784
|
-
const finalFormat = groupIndent + successFormat;
|
|
785
|
-
if (additionalArgs.length > 0) {
|
|
786
|
-
console.log(finalFormat, ...styles, ...additionalArgs);
|
|
787
|
-
} else {
|
|
788
|
-
console.log(finalFormat, ...styles);
|
|
789
|
-
}
|
|
790
|
-
const metadata = {
|
|
791
|
-
timestamp: formatTimestamp(),
|
|
792
|
-
level: "info",
|
|
793
|
-
prefix,
|
|
794
|
-
stackInfo: stackInfo ? stackInfo : void 0
|
|
795
|
-
};
|
|
796
|
-
this.handlers.forEach((handler) => {
|
|
797
|
-
try {
|
|
798
|
-
handler.handle("info", message, args, metadata);
|
|
799
|
-
} catch (error2) {
|
|
800
|
-
console.error("Log handler failed:", error2);
|
|
801
|
-
}
|
|
802
|
-
});
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* Logs trace information (detailed debugging)
|
|
806
|
-
*/
|
|
807
|
-
trace(...args) {
|
|
808
|
-
this.log("debug", ...args);
|
|
809
|
-
if (this.shouldLog("debug")) {
|
|
810
|
-
console.trace(...args);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
/**
|
|
814
|
-
* Logs critical errors (highest priority)
|
|
815
|
-
*/
|
|
816
|
-
critical(...args) {
|
|
817
|
-
this.log("critical", ...args);
|
|
818
|
-
}
|
|
819
|
-
// ===== ADVANCED LOGGING FEATURES =====
|
|
820
|
-
/**
|
|
821
|
-
* Displays data in a table format
|
|
822
|
-
*/
|
|
823
|
-
table(data, columns) {
|
|
824
|
-
if (!this.shouldLog("info")) return;
|
|
825
|
-
const prefix = this.getEffectivePrefix();
|
|
826
|
-
const tableStyle = StylePresets.accent().build();
|
|
827
|
-
const format = `%c📊 TABLE${prefix ? ` [${prefix}]` : ""}`;
|
|
828
|
-
console.log(format, tableStyle);
|
|
829
|
-
if (columns) {
|
|
830
|
-
console.table(data, columns);
|
|
831
|
-
} else {
|
|
832
|
-
console.table(data);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
/**
|
|
836
|
-
* Starts a collapsible group in the console
|
|
837
|
-
*/
|
|
838
|
-
group(label, collapsed = false) {
|
|
839
|
-
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();
|
|
840
|
-
const format = `%c📁 ${label}`;
|
|
841
|
-
if (collapsed) {
|
|
842
|
-
console.groupCollapsed(format, groupStyle);
|
|
843
|
-
} else {
|
|
844
|
-
console.group(format, groupStyle);
|
|
845
|
-
}
|
|
846
|
-
this.groupDepth++;
|
|
847
|
-
}
|
|
848
|
-
/**
|
|
849
|
-
* Ends the current console group
|
|
850
|
-
*/
|
|
851
|
-
groupEnd() {
|
|
852
|
-
if (this.groupDepth > 0) {
|
|
853
|
-
console.groupEnd();
|
|
854
|
-
this.groupDepth--;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
// ===== PERFORMANCE TIMING =====
|
|
858
|
-
/**
|
|
859
|
-
* Starts a timer with the given label
|
|
860
|
-
*/
|
|
861
|
-
time(label) {
|
|
862
|
-
const timer = {
|
|
863
|
-
label,
|
|
864
|
-
startTime: performance.now()
|
|
865
|
-
};
|
|
866
|
-
this.timers.set(label, timer);
|
|
867
|
-
const timerStyle = StylePresets.warning().build();
|
|
868
|
-
console.log(`%c⏱️ Timer started: ${label}`, timerStyle);
|
|
869
|
-
}
|
|
870
|
-
/**
|
|
871
|
-
* Ends a timer and logs the elapsed time
|
|
872
|
-
*/
|
|
873
|
-
timeEnd(label) {
|
|
874
|
-
const timer = this.timers.get(label);
|
|
875
|
-
if (!timer) {
|
|
876
|
-
this.warn(`Timer '${label}' does not exist`);
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
879
|
-
const elapsed = performance.now() - timer.startTime;
|
|
880
|
-
this.timers.delete(label);
|
|
881
|
-
const timerStyle = StylePresets.success().build();
|
|
882
|
-
console.log(`%c⏱️ Timer ended: ${label} - ${elapsed.toFixed(2)}ms`, timerStyle);
|
|
883
|
-
}
|
|
884
|
-
// ===== ADVANCED VISUAL FEATURES =====
|
|
885
|
-
/**
|
|
886
|
-
* Display banner with specified or configured type
|
|
887
|
-
*/
|
|
888
|
-
showBanner(bannerType) {
|
|
889
|
-
const effectiveBannerType = bannerType ? bannerType : this.config.bannerType;
|
|
890
|
-
displayInitBanner(effectiveBannerType);
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* Log with SVG background image
|
|
894
|
-
*/
|
|
895
|
-
logWithSVG(message, svgContent, options = {}) {
|
|
896
|
-
const { width = 300, height = 60, padding = "30px 150px" } = options;
|
|
897
|
-
let svgDataUri = "";
|
|
898
|
-
if (svgContent) {
|
|
899
|
-
const encodedSVG = encodeURIComponent(svgContent);
|
|
900
|
-
svgDataUri = `data:image/svg+xml,${encodedSVG}`;
|
|
901
|
-
} else {
|
|
902
|
-
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>`;
|
|
903
|
-
svgDataUri = `data:image/svg+xml,${encodeURIComponent(defaultSVG)}`;
|
|
904
|
-
}
|
|
905
|
-
const svgStyle = new StyleBuilder().bg(`url("${svgDataUri}") no-repeat center center`).padding(padding).color("transparent").rounded("4px").build();
|
|
906
|
-
console.log(`%c${message}`, svgStyle);
|
|
907
|
-
}
|
|
908
|
-
/**
|
|
909
|
-
* Log with animated background gradient
|
|
910
|
-
*/
|
|
911
|
-
logAnimated(message, duration = 3) {
|
|
912
|
-
if (!document.getElementById("logger-animations")) {
|
|
913
|
-
const style = document.createElement("style");
|
|
914
|
-
style.id = "logger-animations";
|
|
915
|
-
style.textContent = `
|
|
916
|
-
@keyframes loggerGradient {
|
|
917
|
-
0% { background-position: 0% 50%; }
|
|
918
|
-
50% { background-position: 100% 50%; }
|
|
919
|
-
100% { background-position: 0% 50%; }
|
|
920
|
-
}
|
|
921
|
-
`;
|
|
922
|
-
document.head.appendChild(style);
|
|
923
|
-
}
|
|
924
|
-
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();
|
|
925
|
-
console.log(`%c${message}`, animatedStyle);
|
|
926
|
-
}
|
|
927
|
-
/**
|
|
928
|
-
* Groups logs by a specific property using modern Object.groupBy (when available)
|
|
929
|
-
*/
|
|
930
|
-
logGrouped(items, groupBy) {
|
|
931
|
-
try {
|
|
932
|
-
let grouped;
|
|
933
|
-
if (Object.groupBy) {
|
|
934
|
-
grouped = Object.groupBy(items, groupBy);
|
|
935
|
-
} else {
|
|
936
|
-
grouped = items.reduce((acc, item) => {
|
|
937
|
-
const key = groupBy(item);
|
|
938
|
-
if (!acc[key]) {
|
|
939
|
-
acc[key] = [];
|
|
940
|
-
}
|
|
941
|
-
acc[key].push(item);
|
|
942
|
-
return acc;
|
|
943
|
-
}, {});
|
|
944
|
-
}
|
|
945
|
-
Object.entries(grouped).forEach(([group2, groupItems]) => {
|
|
946
|
-
this.group(`Group: ${group2}`);
|
|
947
|
-
this.table(groupItems);
|
|
948
|
-
this.groupEnd();
|
|
949
|
-
});
|
|
950
|
-
} catch {
|
|
951
|
-
this.info("Grouped data:", items);
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
// ===== CLI SYSTEM =====
|
|
955
|
-
/**
|
|
956
|
-
* CLI command processor for logger configuration and export
|
|
957
|
-
*/
|
|
958
|
-
async cli(command) {
|
|
959
|
-
if (!this.cliProcessor) {
|
|
960
|
-
this.error("CLI processor not initialized");
|
|
961
|
-
return;
|
|
962
|
-
}
|
|
963
|
-
await this.cliProcessor.processCommand(command, this);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
new Logger({
|
|
967
|
-
verbosity: "info",
|
|
968
|
-
enableColors: true,
|
|
969
|
-
enableTimestamps: true,
|
|
970
|
-
enableStackTrace: true,
|
|
971
|
-
bufferSize: 1e3
|
|
972
|
-
// Enable export functionality by default
|
|
973
|
-
});
|
|
974
|
-
displayInitBanner();
|
|
975
|
-
export {
|
|
976
|
-
Logger as L
|
|
977
|
-
};
|
|
978
|
-
//# sourceMappingURL=Logger-BrFKFZcD.js.map
|