@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
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/handlers/FileLogHandler.ts","../src/handlers/AnalyticsLogHandler.ts","../src/index.ts"],"sourcesContent":["/**\n * @fileoverview File-based log handler for Advanced Logger\n */\n\nimport type { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';\n\n/**\n * File-based log handler for persistent logging\n */\nexport class FileLogHandler implements ILogHandler {\n private filename: string;\n\n constructor(filename: string = 'app.log') {\n this.filename = filename;\n }\n\n handle(level: LogLevel, message: string, args: any[], metadata: LogMetadata): void {\n const logEntry = {\n filename: this.filename,\n timestamp: metadata.timestamp,\n level: level.toUpperCase(),\n prefix: metadata.prefix,\n message,\n args: args.slice(1),\n location: metadata.stackInfo,\n };\n\n console.debug('File log entry:', logEntry);\n }\n}","/**\n * @fileoverview Analytics log handler for Advanced Logger\n */\n\nimport type { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';\n\n/**\n * Example custom handler for analytics demonstration\n */\nexport class AnalyticsLogHandler implements ILogHandler {\n handle(level: LogLevel, message: string, _args: any[], metadata: LogMetadata): void {\n // In a real implementation, this could send analytics data\n if (level === 'error' || level === 'critical') {\n // Track errors for analytics\n console.debug('Analytics: Error tracked', { \n level, \n message, \n timestamp: metadata.timestamp \n });\n }\n }\n}","/**\n * @fileoverview Better Logger - Complete library with all features\n * @version 0.0.1\n * \n * This is the main entry point that provides the complete Better Logger experience\n * with all advanced features including styling, SVG support, animations, export \n * capabilities, and remote logging.\n */\n\n// Main Logger class with all features\nimport { Logger } from './Logger.js';\nimport type {\n LogLevel,\n Verbosity,\n ThemeVariant,\n BannerType,\n StyleOptions,\n ILogHandler\n} from './types/index.js';\n\n// Create singleton instance with all features enabled\nconst logger = new Logger();\n\n/**\n * Main Logger class with complete feature set\n * \n * @example\n * ```typescript\n * import { Logger } from '@mks2508/better-logger';\n * \n * const logger = new Logger();\n * logger.setTheme('neon');\n * logger.info('Hello world!');\n * logger.logWithSVG('Custom SVG', svgContent);\n * ```\n */\nexport { Logger };\n\n// Export the singleton as default\nexport default logger;\n\n// Individual logging methods (bound to singleton)\nexport const debug = (...args: any[]) => logger.debug(...args);\nexport const info = (...args: any[]) => logger.info(...args);\nexport const warn = (...args: any[]) => logger.warn(...args);\nexport const error = (...args: any[]) => logger.error(...args);\nexport const success = (...args: any[]) => logger.success(...args);\nexport const critical = (...args: any[]) => logger.critical(...args);\nexport const trace = (...args: any[]) => logger.trace(...args);\nexport const table = (data: any, columns?: string[]) => logger.table(data, columns);\nexport const group = (label: string, collapsed?: boolean) => logger.group(label, collapsed);\nexport const groupEnd = () => logger.groupEnd();\nexport const time = (label: string) => logger.time(label);\nexport const timeEnd = (label: string) => logger.timeEnd(label);\nexport const setGlobalPrefix = (prefix: string) => logger.setGlobalPrefix(prefix);\nexport const createScopedLogger = (prefix: string) => logger.createScopedLogger(prefix);\nexport const setVerbosity = (level: Verbosity) => logger.setVerbosity(level);\nexport const addHandler = (handler: ILogHandler) => logger.addHandler(handler);\nexport const setTheme = (theme: ThemeVariant) => logger.setTheme(theme);\nexport const setBannerType = (bannerType: BannerType) => logger.setBannerType(bannerType);\nexport const showBanner = (bannerType?: BannerType) => logger.showBanner(bannerType);\nexport const logWithSVG = (message: string, svgContent?: string, options?: StyleOptions) => \n logger.logWithSVG(message, svgContent, options);\nexport const logAnimated = (message: string, duration?: number) => \n logger.logAnimated(message, duration);\nexport const cli = (command: string) => logger.cli(command);\n\n// Type exports\nexport type {\n LogLevel,\n Verbosity,\n ThemeVariant,\n BannerType,\n StyleOptions,\n ILogHandler,\n LoggerConfig,\n LogMetadata,\n StackInfo,\n TimerEntry\n} from './types/index.js';\n\n// Styling utilities\nexport { \n StyleBuilder,\n StylePresets,\n THEME_PRESETS,\n THEME_BANNERS,\n BANNER_VARIANTS\n} from './styling/index.js';\n\n// Handler exports\nexport {\n FileLogHandler,\n RemoteLogHandler,\n AnalyticsLogHandler\n} from './handlers/index.js';\n\n// Constants\nexport { DEFAULT_CONFIG } from './constants.js';\n\n// Utility exports\nexport {\n parseStackTrace,\n formatTimestamp\n} from './utils/index.js';\n\n/**\n * Styling utilities for creating custom console styles\n * \n * @example\n * ```typescript\n * import { createStyle, stylePresets } from '@mks2508/better-logger';\n * \n * const customStyle = createStyle()\n * .bg('linear-gradient(45deg, #ff6b6b, #feca57)')\n * .color('white')\n * .padding('10px')\n * .build();\n * \n * console.log('%cStyled message', customStyle);\n * console.log('%cSuccess!', stylePresets.success);\n * ```\n */\nimport { StyleBuilder, StylePresets } from './styling/index.js';\n\n/**\n * Creates a new StyleBuilder instance for custom console styling\n */\nexport const createStyle = () => new StyleBuilder();\n\n/**\n * Pre-built style presets for common use cases\n */\nexport const stylePresets = {\n success: StylePresets.success().build(),\n error: StylePresets.error().build(),\n warning: StylePresets.warning().build(),\n info: StylePresets.info().build(),\n accent: StylePresets.accent().build(),\n};"],"names":["StyleBuilder","StylePresets"],"mappings":";;;;;AASO,MAAM,eAAsC;AAAA,EACvC;AAAA,EAER,YAAY,WAAmB,WAAW;AACtC,SAAK,WAAW;AAAA,EACpB;AAAA,EAEA,OAAO,OAAiB,SAAiB,MAAa,UAA6B;AAC/E,UAAM,WAAW;AAAA,MACb,UAAU,KAAK;AAAA,MACf,WAAW,SAAS;AAAA,MACpB,OAAO,MAAM,YAAA;AAAA,MACb,QAAQ,SAAS;AAAA,MACjB;AAAA,MACA,MAAM,KAAK,MAAM,CAAC;AAAA,MAClB,UAAU,SAAS;AAAA,IAAA;AAGvB,YAAQ,MAAM,mBAAmB,QAAQ;AAAA,EAC7C;AACJ;ACpBO,MAAM,oBAA2C;AAAA,EACpD,OAAO,OAAiB,SAAiB,OAAc,UAA6B;AAEhF,QAAI,UAAU,WAAW,UAAU,YAAY;AAE3C,cAAQ,MAAM,4BAA4B;AAAA,QACtC;AAAA,QACA;AAAA,QACA,WAAW,SAAS;AAAA,MAAA,CACvB;AAAA,IACL;AAAA,EACJ;AACJ;ACAA,MAAM,SAAS,IAAI,OAAA;AAqBZ,MAAM,QAAQ,IAAI,SAAgB,OAAO,MAAM,GAAG,IAAI;AACtD,MAAM,OAAO,IAAI,SAAgB,OAAO,KAAK,GAAG,IAAI;AACpD,MAAM,OAAO,IAAI,SAAgB,OAAO,KAAK,GAAG,IAAI;AACpD,MAAM,QAAQ,IAAI,SAAgB,OAAO,MAAM,GAAG,IAAI;AACtD,MAAM,UAAU,IAAI,SAAgB,OAAO,QAAQ,GAAG,IA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"version":3,"file":"index.js","sources":["../src/handlers/FileLogHandler.ts","../src/handlers/AnalyticsLogHandler.ts","../src/index.ts"],"sourcesContent":["/**\n * @fileoverview File-based log handler for Advanced Logger\n */\n\nimport type { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';\nimport { isNode, isBrowser } from '../utils/environment.js';\nimport { safeSerialize } from '../utils/formatting.js';\n\n/**\n * Universal file-based log handler for persistent logging\n * Works in both Node.js (real files) and browser (localStorage)\n */\nexport class FileLogHandler implements ILogHandler {\n private filename: string;\n private maxSize?: number;\n private fs?: any; // Node.js fs module\n\n constructor(filename: string = 'app.log', maxSize?: number) {\n this.filename = filename;\n this.maxSize = maxSize;\n \n // Load Node.js fs module if in Node environment\n if (isNode) {\n try {\n this.fs = require('fs');\n } catch (error) {\n console.warn('FileLogHandler: Unable to load fs module:', error);\n }\n }\n }\n\n handle(level: LogLevel, message: string, args: any[], metadata: LogMetadata): void {\n const logEntry = {\n timestamp: metadata.timestamp,\n level: level.toUpperCase(),\n prefix: metadata.prefix,\n message,\n args: args.slice(1).map(arg => safeSerialize(arg)),\n location: metadata.stackInfo,\n };\n\n const logLine = this.formatLogLine(logEntry);\n\n if (isNode && this.fs) {\n this.writeToFileNode(logLine);\n } else if (isBrowser) {\n this.writeToFileLocal(logLine);\n } else {\n // Fallback - just console output\n console.log(`[FILE-LOG] ${logLine}`);\n }\n }\n\n /**\n * Format log entry as a single line for file storage\n */\n private formatLogLine(entry: any): string {\n const parts = [\n entry.timestamp,\n `[${entry.level}]`,\n entry.prefix ? `[${entry.prefix}]` : '',\n entry.message\n ].filter(Boolean);\n\n let line = parts.join(' ');\n \n if (entry.args && entry.args.length > 0) {\n line += ' ' + entry.args.map((arg: any) => \n typeof arg === 'object' ? JSON.stringify(arg) : String(arg)\n ).join(' ');\n }\n \n if (entry.location) {\n line += ` (${entry.location.file}:${entry.location.line}:${entry.location.column})`;\n }\n \n return line;\n }\n\n /**\n * Write to actual file in Node.js environment\n */\n private writeToFileNode(logLine: string): void {\n if (!this.fs) return;\n\n try {\n // Check file size if maxSize is set\n if (this.maxSize) {\n try {\n const stats = this.fs.statSync(this.filename);\n if (stats.size > this.maxSize) {\n // Simple rotation: backup current file and start fresh\n const backupName = `${this.filename}.bak`;\n this.fs.renameSync(this.filename, backupName);\n }\n } catch (error) {\n // File doesn't exist yet, that's fine\n }\n }\n\n // Append to file\n this.fs.appendFileSync(this.filename, logLine + '\\n', 'utf8');\n } catch (error) {\n console.error('FileLogHandler: Failed to write to file:', error);\n }\n }\n\n /**\n * Write to localStorage in browser environment\n */\n private writeToFileLocal(logLine: string): void {\n try {\n const storageKey = `logger_${this.filename}`;\n const existingLogs = localStorage.getItem(storageKey) || '';\n \n let newLogs = existingLogs;\n if (existingLogs.length > 0) {\n newLogs += '\\n';\n }\n newLogs += logLine;\n \n // Simple size management - keep last 1000 lines max\n if (this.maxSize || newLogs.split('\\n').length > 1000) {\n const lines = newLogs.split('\\n');\n const maxLines = this.maxSize ? Math.floor(this.maxSize / 100) : 1000;\n if (lines.length > maxLines) {\n newLogs = lines.slice(-maxLines).join('\\n');\n }\n }\n \n localStorage.setItem(storageKey, newLogs);\n } catch (error) {\n console.error('FileLogHandler: Failed to write to localStorage:', error);\n }\n }\n\n /**\n * Get stored logs (useful for debugging)\n */\n getLogs(): string | null {\n if (isNode && this.fs) {\n try {\n return this.fs.readFileSync(this.filename, 'utf8');\n } catch (error) {\n return null;\n }\n } else if (isBrowser) {\n const storageKey = `logger_${this.filename}`;\n return localStorage.getItem(storageKey);\n }\n return null;\n }\n\n /**\n * Clear stored logs\n */\n clearLogs(): void {\n if (isNode && this.fs) {\n try {\n this.fs.writeFileSync(this.filename, '', 'utf8');\n } catch (error) {\n console.error('FileLogHandler: Failed to clear file:', error);\n }\n } else if (isBrowser) {\n const storageKey = `logger_${this.filename}`;\n localStorage.removeItem(storageKey);\n }\n }\n}","/**\n * @fileoverview Analytics log handler for Advanced Logger\n */\n\nimport type { ILogHandler, LogLevel, LogMetadata } from '../types/index.js';\n\n/**\n * Example custom handler for analytics demonstration\n */\nexport class AnalyticsLogHandler implements ILogHandler {\n handle(level: LogLevel, message: string, _args: any[], metadata: LogMetadata): void {\n // In a real implementation, this could send analytics data\n if (level === 'error' || level === 'critical') {\n // Track errors for analytics\n console.debug('Analytics: Error tracked', { \n level, \n message, \n timestamp: metadata.timestamp \n });\n }\n }\n}","/**\n * @fileoverview Better Logger - Complete library with all features\n * @version 0.0.1\n * \n * This is the main entry point that provides the complete Better Logger experience\n * with all advanced features including styling, SVG support, animations, export \n * capabilities, and remote logging.\n */\n\n// Main Logger class with all features\nimport { Logger } from './Logger.js';\nimport type {\n LogLevel,\n Verbosity,\n ThemeVariant,\n BannerType,\n StyleOptions,\n ILogHandler\n} from './types/index.js';\n\n// Create singleton instance with all features enabled\nconst logger = new Logger();\n\n/**\n * Main Logger class with complete feature set\n * \n * @example\n * ```typescript\n * import { Logger } from '@mks2508/better-logger';\n * \n * const logger = new Logger();\n * logger.setTheme('neon');\n * logger.info('Hello world!');\n * logger.logWithSVG('Custom SVG', svgContent);\n * ```\n */\nexport { Logger };\n\n// Export the singleton as default\nexport default logger;\n\n// Individual logging methods (bound to singleton)\nexport const debug = (...args: any[]) => logger.debug(...args);\nexport const info = (...args: any[]) => logger.info(...args);\nexport const warn = (...args: any[]) => logger.warn(...args);\nexport const error = (...args: any[]) => logger.error(...args);\nexport const success = (...args: any[]) => logger.success(...args);\nexport const critical = (...args: any[]) => logger.critical(...args);\nexport const trace = (...args: any[]) => logger.trace(...args);\nexport const table = (data: any, columns?: string[]) => logger.table(data, columns);\nexport const group = (label: string, collapsed?: boolean) => logger.group(label, collapsed);\nexport const groupEnd = () => logger.groupEnd();\nexport const time = (label: string) => logger.time(label);\nexport const timeEnd = (label: string) => logger.timeEnd(label);\nexport const setGlobalPrefix = (prefix: string) => logger.setGlobalPrefix(prefix);\nexport const scope = (prefix: string) => logger.scope(prefix);\nexport const setVerbosity = (level: Verbosity) => logger.setVerbosity(level);\nexport const addHandler = (handler: ILogHandler) => logger.addHandler(handler);\nexport const setTheme = (theme: ThemeVariant) => logger.setTheme(theme);\nexport const setBannerType = (bannerType: BannerType) => logger.setBannerType(bannerType);\nexport const showBanner = (bannerType?: BannerType) => logger.showBanner(bannerType);\nexport const logWithSVG = (message: string, svgContent?: string, options?: StyleOptions) => \n logger.logWithSVG(message, svgContent, options);\nexport const logAnimated = (message: string, duration?: number) => \n logger.logAnimated(message, duration);\nexport const cli = (command: string) => logger.cli(command);\n\n// Type exports\nexport type {\n LogLevel,\n Verbosity,\n ThemeVariant,\n BannerType,\n StyleOptions,\n ILogHandler,\n LoggerConfig,\n LogMetadata,\n StackInfo,\n TimerEntry\n} from './types/index.js';\n\n// Styling utilities\nexport { \n StyleBuilder,\n StylePresets,\n THEME_PRESETS,\n THEME_BANNERS,\n BANNER_VARIANTS\n} from './styling/index.js';\n\n// Handler exports\nexport {\n FileLogHandler,\n RemoteLogHandler,\n AnalyticsLogHandler\n} from './handlers/index.js';\n\n// Constants\nexport { DEFAULT_CONFIG } from './constants.js';\n\n// Utility exports\nexport {\n parseStackTrace,\n formatTimestamp\n} from './utils/index.js';\n\n/**\n * Styling utilities for creating custom console styles\n * \n * @example\n * ```typescript\n * import { createStyle, stylePresets } from '@mks2508/better-logger';\n * \n * const customStyle = createStyle()\n * .bg('linear-gradient(45deg, #ff6b6b, #feca57)')\n * .color('white')\n * .padding('10px')\n * .build();\n * \n * console.log('%cStyled message', customStyle);\n * console.log('%cSuccess!', stylePresets.success);\n * ```\n */\nimport { StyleBuilder, StylePresets } from './styling/index.js';\n\n/**\n * Creates a new StyleBuilder instance for custom console styling\n */\nexport const createStyle = () => new StyleBuilder();\n\n/**\n * Pre-built style presets for common use cases\n */\nexport const stylePresets = {\n success: StylePresets.success().build(),\n error: StylePresets.error().build(),\n warning: StylePresets.warning().build(),\n info: StylePresets.info().build(),\n accent: StylePresets.accent().build(),\n};"],"names":["error","StyleBuilder","StylePresets"],"mappings":";;;;;;AA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","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { debug, info, warn, error, success, critical, table, group, groupEnd, time, timeEnd, trace, scope, cli, setTheme, setBannerType, showBanner, logWithSVG, logAnimated, createStyle, stylePresets } from './index.js';
|
|
2
|
+
import { demonstrateBanners, demonstrateThemes, demonstrateSVG, demonstrateAnimations, demonstrateCLI, demonstrateExports, demonstrateAllFeatures as demoAllFeatures } from './example.js';
|
|
3
|
+
console.log('%cBetter Logger Demo Ready! 🚀', 'background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 10px 20px; border-radius: 8px; font-weight: bold; font-size: 14px;');
|
|
4
|
+
console.log('📋 Available test functions: testDebug(), testBanners(), testThemes(), and more!');
|
|
5
|
+
console.log('💻 CLI Available: cli("/help") for commands');
|
|
6
|
+
function testDebug() {
|
|
7
|
+
debug("This is a debug message.", { user: "test", id: 123 });
|
|
8
|
+
}
|
|
9
|
+
function testInfo() {
|
|
10
|
+
info("This is an info message with an object.", { data: "payload" });
|
|
11
|
+
}
|
|
12
|
+
function testWarn() {
|
|
13
|
+
warn("This is a warning message about a deprecated API.");
|
|
14
|
+
}
|
|
15
|
+
function testError() {
|
|
16
|
+
error("This is an error message.", new Error("Failed to fetch resource."));
|
|
17
|
+
}
|
|
18
|
+
function testSuccess() {
|
|
19
|
+
success("Operation completed successfully.");
|
|
20
|
+
}
|
|
21
|
+
function testCritical() {
|
|
22
|
+
critical("This is a CRITICAL message. System integrity compromised!");
|
|
23
|
+
}
|
|
24
|
+
function testTable() {
|
|
25
|
+
table([
|
|
26
|
+
{ feature: "Debug Log", status: "Implemented", priority: "Low" },
|
|
27
|
+
{ feature: "Info Log", status: "Implemented", priority: "Medium" },
|
|
28
|
+
{ feature: "Warning Log", status: "Implemented", priority: "High" },
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
function testGrouping() {
|
|
32
|
+
group("User Authentication Flow", true); // Start collapsed
|
|
33
|
+
info("User 'testuser' attempting to log in...");
|
|
34
|
+
warn("Password nearing expiration.");
|
|
35
|
+
success("Login successful.");
|
|
36
|
+
groupEnd();
|
|
37
|
+
}
|
|
38
|
+
function testTiming() {
|
|
39
|
+
time("dataProcessing");
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
timeEnd("dataProcessing");
|
|
42
|
+
}, 750); // Simulate a 750ms operation
|
|
43
|
+
}
|
|
44
|
+
function testScopedLogger() {
|
|
45
|
+
info("Demonstrating scoped loggers...");
|
|
46
|
+
const apiLogger = scope("API");
|
|
47
|
+
apiLogger.info("Fetching user data...");
|
|
48
|
+
const uiLogger = scope("UI");
|
|
49
|
+
uiLogger.debug("Rendering user profile component.");
|
|
50
|
+
apiLogger.success("User data fetched successfully.");
|
|
51
|
+
apiLogger.error("Failed to update settings.");
|
|
52
|
+
}
|
|
53
|
+
function testTrace() {
|
|
54
|
+
function innerFunction() {
|
|
55
|
+
function deepFunction() {
|
|
56
|
+
trace("Trace from a deeply nested function.");
|
|
57
|
+
}
|
|
58
|
+
deepFunction();
|
|
59
|
+
}
|
|
60
|
+
innerFunction();
|
|
61
|
+
}
|
|
62
|
+
// Visual feature tests
|
|
63
|
+
function testBanners() {
|
|
64
|
+
demonstrateBanners();
|
|
65
|
+
}
|
|
66
|
+
function testThemes() {
|
|
67
|
+
demonstrateThemes();
|
|
68
|
+
}
|
|
69
|
+
function testSVG() {
|
|
70
|
+
demonstrateSVG();
|
|
71
|
+
}
|
|
72
|
+
function testAnimations() {
|
|
73
|
+
demonstrateAnimations();
|
|
74
|
+
}
|
|
75
|
+
function testCLI() {
|
|
76
|
+
demonstrateCLI();
|
|
77
|
+
}
|
|
78
|
+
function testExports() {
|
|
79
|
+
demonstrateExports();
|
|
80
|
+
}
|
|
81
|
+
function testAllFeatures() {
|
|
82
|
+
group("🌟 Demonstrating Core Logger Features");
|
|
83
|
+
testDebug();
|
|
84
|
+
testInfo();
|
|
85
|
+
testWarn();
|
|
86
|
+
testError();
|
|
87
|
+
testSuccess();
|
|
88
|
+
testCritical();
|
|
89
|
+
testTable();
|
|
90
|
+
testGrouping();
|
|
91
|
+
testTiming();
|
|
92
|
+
testScopedLogger();
|
|
93
|
+
testTrace();
|
|
94
|
+
groupEnd();
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
info('🎨 Running visual features demo...');
|
|
97
|
+
demoAllFeatures();
|
|
98
|
+
}, 2000);
|
|
99
|
+
}
|
|
100
|
+
// Expose functions to global scope for onclick attributes in index.html
|
|
101
|
+
if (typeof window !== 'undefined') {
|
|
102
|
+
// Core logging tests
|
|
103
|
+
window.testDebug = testDebug;
|
|
104
|
+
window.testInfo = testInfo;
|
|
105
|
+
window.testWarn = testWarn;
|
|
106
|
+
window.testError = testError;
|
|
107
|
+
window.testSuccess = testSuccess;
|
|
108
|
+
window.testCritical = testCritical;
|
|
109
|
+
window.testTable = testTable;
|
|
110
|
+
window.testGrouping = testGrouping;
|
|
111
|
+
window.testTiming = testTiming;
|
|
112
|
+
window.testScopedLogger = testScopedLogger;
|
|
113
|
+
window.testTrace = testTrace;
|
|
114
|
+
window.testAllFeatures = testAllFeatures;
|
|
115
|
+
// Visual feature tests
|
|
116
|
+
window.testBanners = testBanners;
|
|
117
|
+
window.testThemes = testThemes;
|
|
118
|
+
window.testSVG = testSVG;
|
|
119
|
+
window.testAnimations = testAnimations;
|
|
120
|
+
window.testCLI = testCLI;
|
|
121
|
+
window.testExports = testExports;
|
|
122
|
+
// Direct access to library functions
|
|
123
|
+
window.cli = cli;
|
|
124
|
+
window.setTheme = setTheme;
|
|
125
|
+
window.setBannerType = setBannerType;
|
|
126
|
+
window.showBanner = showBanner;
|
|
127
|
+
window.logWithSVG = logWithSVG;
|
|
128
|
+
window.logAnimated = logAnimated;
|
|
129
|
+
window.createStyle = createStyle;
|
|
130
|
+
window.stylePresets = stylePresets;
|
|
131
|
+
// Display welcome info
|
|
132
|
+
setTimeout(() => {
|
|
133
|
+
console.log('%c💡 Quick Start Guide', stylePresets.info);
|
|
134
|
+
console.log('🎨 Visual: testBanners(), testThemes(), testSVG(), testAnimations()');
|
|
135
|
+
console.log('📊 Core: testTable(), testGrouping(), testTiming(), testTrace()');
|
|
136
|
+
console.log('💻 CLI: cli("/help") - Try commands like "/theme neon", "/banner ascii"');
|
|
137
|
+
console.log('🌟 Full Demo: testAllFeatures()');
|
|
138
|
+
}, 1000);
|
|
139
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview LogStyleBuilder for fluent log styling API
|
|
3
|
+
*/
|
|
4
|
+
import type { Logger } from '../Logger.js';
|
|
5
|
+
import type { LogStyles, SpacingType } from '../types/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Fluent API builder for log styling with semantic methods
|
|
8
|
+
*/
|
|
9
|
+
export declare class LogStyleBuilder {
|
|
10
|
+
private logStyles;
|
|
11
|
+
private logger;
|
|
12
|
+
constructor(logger: Logger);
|
|
13
|
+
/**
|
|
14
|
+
* Configure timestamp styling
|
|
15
|
+
*/
|
|
16
|
+
timestamp(): TimestampStyleBuilderProxy;
|
|
17
|
+
/**
|
|
18
|
+
* Configure level badge styling
|
|
19
|
+
*/
|
|
20
|
+
level(): LevelStyleBuilderProxy;
|
|
21
|
+
/**
|
|
22
|
+
* Configure prefix styling
|
|
23
|
+
*/
|
|
24
|
+
prefix(): PrefixStyleBuilderProxy;
|
|
25
|
+
/**
|
|
26
|
+
* Configure message text styling
|
|
27
|
+
*/
|
|
28
|
+
message(): MessageStyleBuilderProxy;
|
|
29
|
+
/**
|
|
30
|
+
* Configure location info styling
|
|
31
|
+
*/
|
|
32
|
+
location(): LocationStyleBuilderProxy;
|
|
33
|
+
/**
|
|
34
|
+
* Use a predefined preset
|
|
35
|
+
*/
|
|
36
|
+
usePreset(presetName: string): LogStyleBuilder;
|
|
37
|
+
/**
|
|
38
|
+
* Customize with partial configuration
|
|
39
|
+
*/
|
|
40
|
+
customize(overrides: Partial<LogStyles>): LogStyleBuilder;
|
|
41
|
+
/**
|
|
42
|
+
* Set layout spacing
|
|
43
|
+
*/
|
|
44
|
+
spacing(type: SpacingType): LogStyleBuilder;
|
|
45
|
+
/**
|
|
46
|
+
* Set backdrop filter for glassmorphism effects
|
|
47
|
+
*/
|
|
48
|
+
backdrop(filter: string): LogStyleBuilder;
|
|
49
|
+
/**
|
|
50
|
+
* Set overall transparency
|
|
51
|
+
*/
|
|
52
|
+
transparency(value: number): LogStyleBuilder;
|
|
53
|
+
/**
|
|
54
|
+
* Apply the configured styles to the logger
|
|
55
|
+
*/
|
|
56
|
+
apply(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Get current configuration (for debugging)
|
|
59
|
+
*/
|
|
60
|
+
getConfig(): LogStyles;
|
|
61
|
+
/**
|
|
62
|
+
* Internal method to update part configuration
|
|
63
|
+
*/
|
|
64
|
+
_updatePartConfig(part: keyof LogStyles, styles: string): void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Base proxy class for part-specific styling
|
|
68
|
+
*/
|
|
69
|
+
declare abstract class PartStyleBuilderProxy {
|
|
70
|
+
protected parentBuilder: LogStyleBuilder;
|
|
71
|
+
protected partName: keyof LogStyles;
|
|
72
|
+
constructor(parentBuilder: LogStyleBuilder, partName: keyof LogStyles);
|
|
73
|
+
/**
|
|
74
|
+
* Return to the main builder for chaining other parts
|
|
75
|
+
*/
|
|
76
|
+
and(): LogStyleBuilder;
|
|
77
|
+
/**
|
|
78
|
+
* Apply styles and finish configuration
|
|
79
|
+
*/
|
|
80
|
+
apply(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Helper to apply styles to the parent builder
|
|
83
|
+
*/
|
|
84
|
+
protected applyStyles(styler: any): this;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Timestamp styling proxy with fluent API
|
|
88
|
+
*/
|
|
89
|
+
declare class TimestampStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
90
|
+
constructor(parentBuilder: LogStyleBuilder);
|
|
91
|
+
default(): TimestampStyleBuilderProxy;
|
|
92
|
+
hidden(): TimestampStyleBuilderProxy;
|
|
93
|
+
minimal(): TimestampStyleBuilderProxy;
|
|
94
|
+
muted(): TimestampStyleBuilderProxy;
|
|
95
|
+
mono(): TimestampStyleBuilderProxy;
|
|
96
|
+
compact(): TimestampStyleBuilderProxy;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Level badge styling proxy with fluent API
|
|
100
|
+
*/
|
|
101
|
+
declare class LevelStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
102
|
+
constructor(parentBuilder: LogStyleBuilder);
|
|
103
|
+
badge(): LevelStyleBuilderProxy;
|
|
104
|
+
gradient(from?: string, to?: string): LevelStyleBuilderProxy;
|
|
105
|
+
glowing(): LevelStyleBuilderProxy;
|
|
106
|
+
flat(): LevelStyleBuilderProxy;
|
|
107
|
+
bold(): LevelStyleBuilderProxy;
|
|
108
|
+
uppercase(): LevelStyleBuilderProxy;
|
|
109
|
+
neon(): LevelStyleBuilderProxy;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Prefix styling proxy with fluent API
|
|
113
|
+
*/
|
|
114
|
+
declare class PrefixStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
115
|
+
constructor(parentBuilder: LogStyleBuilder);
|
|
116
|
+
dark(): PrefixStyleBuilderProxy;
|
|
117
|
+
light(): PrefixStyleBuilderProxy;
|
|
118
|
+
compact(): PrefixStyleBuilderProxy;
|
|
119
|
+
muted(): PrefixStyleBuilderProxy;
|
|
120
|
+
mono(): PrefixStyleBuilderProxy;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Message styling proxy with fluent API
|
|
124
|
+
*/
|
|
125
|
+
declare class MessageStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
126
|
+
constructor(parentBuilder: LogStyleBuilder);
|
|
127
|
+
readable(): MessageStyleBuilderProxy;
|
|
128
|
+
code(): MessageStyleBuilderProxy;
|
|
129
|
+
large(): MessageStyleBuilderProxy;
|
|
130
|
+
system(): MessageStyleBuilderProxy;
|
|
131
|
+
mono(): MessageStyleBuilderProxy;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Location styling proxy with fluent API
|
|
135
|
+
*/
|
|
136
|
+
declare class LocationStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
137
|
+
constructor(parentBuilder: LogStyleBuilder);
|
|
138
|
+
subtle(): LocationStyleBuilderProxy;
|
|
139
|
+
hidden(): LocationStyleBuilderProxy;
|
|
140
|
+
clickable(): LocationStyleBuilderProxy;
|
|
141
|
+
muted(): LocationStyleBuilderProxy;
|
|
142
|
+
mono(): LocationStyleBuilderProxy;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Create a new LogStyleBuilder instance
|
|
146
|
+
*/
|
|
147
|
+
export declare function createLogStyleBuilder(logger: Logger): LogStyleBuilder;
|
|
148
|
+
export {};
|
|
149
|
+
//# sourceMappingURL=LogStyleBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogStyleBuilder.d.ts","sourceRoot":"","sources":["../../src/styling/LogStyleBuilder.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAa,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAS3E;;GAEG;AACH,qBAAa,eAAe;IACxB,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,MAAM;IAI1B;;OAEG;IACH,SAAS,IAAI,0BAA0B;IAIvC;;OAEG;IACH,KAAK,IAAI,sBAAsB;IAI/B;;OAEG;IACH,MAAM,IAAI,uBAAuB;IAIjC;;OAEG;IACH,OAAO,IAAI,wBAAwB;IAInC;;OAEG;IACH,QAAQ,IAAI,yBAAyB;IAI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CAAC,EAAE,MAAM,GAAG,sBAAsB;IAI5D,OAAO,IAAI,sBAAsB;IAIjC,IAAI,IAAI,sBAAsB;IAI9B,IAAI,IAAI,sBAAsB;IAI9B,SAAS,IAAI,sBAAsB;IAInC,IAAI,IAAI,sBAAsB;CAGjC;AAED;;GAEG;AACH,cAAM,uBAAwB,SAAQ,qBAAqB;gBAC3C,aAAa,EAAE,eAAe;IAI1C,IAAI,IAAI,uBAAuB;IAI/B,KAAK,IAAI,uBAAuB;IAIhC,OAAO,IAAI,uBAAuB;IAIlC,KAAK,IAAI,uBAAuB;IAIhC,IAAI,IAAI,uBAAuB;CAGlC;AAED;;GAEG;AACH,cAAM,wBAAyB,SAAQ,qBAAqB;gBAC5C,aAAa,EAAE,eAAe;IAI1C,QAAQ,IAAI,wBAAwB;IAIpC,IAAI,IAAI,wBAAwB;IAIhC,KAAK,IAAI,wBAAwB;IAIjC,MAAM,IAAI,wBAAwB;IAIlC,IAAI,IAAI,wBAAwB;CAGnC;AAED;;GAEG;AACH,cAAM,yBAA0B,SAAQ,qBAAqB;gBAC7C,aAAa,EAAE,eAAe;IAI1C,MAAM,IAAI,yBAAyB;IAInC,MAAM,IAAI,yBAAyB;IAInC,SAAS,IAAI,yBAAyB;IAItC,KAAK,IAAI,yBAAyB;IAIlC,IAAI,IAAI,yBAAyB;CAGpC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,CAErE"}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview LogStyleBuilder for fluent log styling API
|
|
3
|
+
*/
|
|
4
|
+
import { TimestampStyler, LevelStyler, PrefixStyler, MessageStyler, LocationStyler } from './SemanticStyles.js';
|
|
5
|
+
/**
|
|
6
|
+
* Fluent API builder for log styling with semantic methods
|
|
7
|
+
*/
|
|
8
|
+
export class LogStyleBuilder {
|
|
9
|
+
logStyles = {};
|
|
10
|
+
logger;
|
|
11
|
+
constructor(logger) {
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Configure timestamp styling
|
|
16
|
+
*/
|
|
17
|
+
timestamp() {
|
|
18
|
+
return new TimestampStyleBuilderProxy(this);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Configure level badge styling
|
|
22
|
+
*/
|
|
23
|
+
level() {
|
|
24
|
+
return new LevelStyleBuilderProxy(this);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Configure prefix styling
|
|
28
|
+
*/
|
|
29
|
+
prefix() {
|
|
30
|
+
return new PrefixStyleBuilderProxy(this);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Configure message text styling
|
|
34
|
+
*/
|
|
35
|
+
message() {
|
|
36
|
+
return new MessageStyleBuilderProxy(this);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Configure location info styling
|
|
40
|
+
*/
|
|
41
|
+
location() {
|
|
42
|
+
return new LocationStyleBuilderProxy(this);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Use a predefined preset
|
|
46
|
+
*/
|
|
47
|
+
usePreset(presetName) {
|
|
48
|
+
// Will be implemented when we create the presets
|
|
49
|
+
console.warn(`Preset '${presetName}' will be available in next implementation phase`);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Customize with partial configuration
|
|
54
|
+
*/
|
|
55
|
+
customize(overrides) {
|
|
56
|
+
this.logStyles = { ...this.logStyles, ...overrides };
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Set layout spacing
|
|
61
|
+
*/
|
|
62
|
+
spacing(type) {
|
|
63
|
+
if (!this.logStyles.layout) {
|
|
64
|
+
this.logStyles.layout = { spacing: type };
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.logStyles.layout.spacing = type;
|
|
68
|
+
}
|
|
69
|
+
// Apply spacing-specific configurations
|
|
70
|
+
switch (type) {
|
|
71
|
+
case 'compact':
|
|
72
|
+
this.logStyles.layout.innerPadding = '1px';
|
|
73
|
+
this.logStyles.layout.outerMargin = '0px';
|
|
74
|
+
break;
|
|
75
|
+
case 'spacious':
|
|
76
|
+
this.logStyles.layout.innerPadding = '4px';
|
|
77
|
+
this.logStyles.layout.outerMargin = '2px';
|
|
78
|
+
break;
|
|
79
|
+
default: // normal
|
|
80
|
+
this.logStyles.layout.innerPadding = '2px';
|
|
81
|
+
this.logStyles.layout.outerMargin = '1px';
|
|
82
|
+
}
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Set backdrop filter for glassmorphism effects
|
|
87
|
+
*/
|
|
88
|
+
backdrop(filter) {
|
|
89
|
+
this.logStyles.backdrop = filter;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Set overall transparency
|
|
94
|
+
*/
|
|
95
|
+
transparency(value) {
|
|
96
|
+
this.logStyles.transparency = Math.max(0, Math.min(1, value));
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Apply the configured styles to the logger
|
|
101
|
+
*/
|
|
102
|
+
apply() {
|
|
103
|
+
// Store the configuration in the logger
|
|
104
|
+
// This will be implemented when we integrate with the main Logger
|
|
105
|
+
this.logger._customLogStyles = this.logStyles;
|
|
106
|
+
console.log('Applied log styles:', this.logStyles);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get current configuration (for debugging)
|
|
110
|
+
*/
|
|
111
|
+
getConfig() {
|
|
112
|
+
return { ...this.logStyles };
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Internal method to update part configuration
|
|
116
|
+
*/
|
|
117
|
+
_updatePartConfig(part, styles) {
|
|
118
|
+
if (part === 'layout' || part === 'backdrop' || part === 'transparency') {
|
|
119
|
+
return; // Skip these non-part configs
|
|
120
|
+
}
|
|
121
|
+
if (!this.logStyles[part]) {
|
|
122
|
+
this.logStyles[part] = {};
|
|
123
|
+
}
|
|
124
|
+
// Parse basic CSS styles into config
|
|
125
|
+
// This is a simplified approach - in production might want more sophisticated parsing
|
|
126
|
+
this.logStyles[part].style = styles;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Base proxy class for part-specific styling
|
|
131
|
+
*/
|
|
132
|
+
class PartStyleBuilderProxy {
|
|
133
|
+
parentBuilder;
|
|
134
|
+
partName;
|
|
135
|
+
constructor(parentBuilder, partName) {
|
|
136
|
+
this.parentBuilder = parentBuilder;
|
|
137
|
+
this.partName = partName;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Return to the main builder for chaining other parts
|
|
141
|
+
*/
|
|
142
|
+
and() {
|
|
143
|
+
return this.parentBuilder;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Apply styles and finish configuration
|
|
147
|
+
*/
|
|
148
|
+
apply() {
|
|
149
|
+
this.parentBuilder.apply();
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Helper to apply styles to the parent builder
|
|
153
|
+
*/
|
|
154
|
+
applyStyles(styler) {
|
|
155
|
+
const styles = styler.build();
|
|
156
|
+
this.parentBuilder._updatePartConfig(this.partName, styles);
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Timestamp styling proxy with fluent API
|
|
162
|
+
*/
|
|
163
|
+
class TimestampStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
164
|
+
constructor(parentBuilder) {
|
|
165
|
+
super(parentBuilder, 'timestamp');
|
|
166
|
+
}
|
|
167
|
+
default() {
|
|
168
|
+
return this.applyStyles(new TimestampStyler().default());
|
|
169
|
+
}
|
|
170
|
+
hidden() {
|
|
171
|
+
return this.applyStyles(new TimestampStyler().hidden());
|
|
172
|
+
}
|
|
173
|
+
minimal() {
|
|
174
|
+
return this.applyStyles(new TimestampStyler().minimal());
|
|
175
|
+
}
|
|
176
|
+
muted() {
|
|
177
|
+
return this.applyStyles(new TimestampStyler().muted());
|
|
178
|
+
}
|
|
179
|
+
mono() {
|
|
180
|
+
return this.applyStyles(new TimestampStyler().mono());
|
|
181
|
+
}
|
|
182
|
+
compact() {
|
|
183
|
+
return this.applyStyles(new TimestampStyler().compact());
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Level badge styling proxy with fluent API
|
|
188
|
+
*/
|
|
189
|
+
class LevelStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
190
|
+
constructor(parentBuilder) {
|
|
191
|
+
super(parentBuilder, 'level');
|
|
192
|
+
}
|
|
193
|
+
badge() {
|
|
194
|
+
return this.applyStyles(new LevelStyler().badge());
|
|
195
|
+
}
|
|
196
|
+
gradient(from, to) {
|
|
197
|
+
return this.applyStyles(new LevelStyler().gradient(from, to));
|
|
198
|
+
}
|
|
199
|
+
glowing() {
|
|
200
|
+
return this.applyStyles(new LevelStyler().glowing());
|
|
201
|
+
}
|
|
202
|
+
flat() {
|
|
203
|
+
return this.applyStyles(new LevelStyler().flat());
|
|
204
|
+
}
|
|
205
|
+
bold() {
|
|
206
|
+
return this.applyStyles(new LevelStyler().bold());
|
|
207
|
+
}
|
|
208
|
+
uppercase() {
|
|
209
|
+
return this.applyStyles(new LevelStyler().uppercase());
|
|
210
|
+
}
|
|
211
|
+
neon() {
|
|
212
|
+
return this.applyStyles(new LevelStyler().neon());
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Prefix styling proxy with fluent API
|
|
217
|
+
*/
|
|
218
|
+
class PrefixStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
219
|
+
constructor(parentBuilder) {
|
|
220
|
+
super(parentBuilder, 'prefix');
|
|
221
|
+
}
|
|
222
|
+
dark() {
|
|
223
|
+
return this.applyStyles(new PrefixStyler().dark());
|
|
224
|
+
}
|
|
225
|
+
light() {
|
|
226
|
+
return this.applyStyles(new PrefixStyler().light());
|
|
227
|
+
}
|
|
228
|
+
compact() {
|
|
229
|
+
return this.applyStyles(new PrefixStyler().compact());
|
|
230
|
+
}
|
|
231
|
+
muted() {
|
|
232
|
+
return this.applyStyles(new PrefixStyler().muted());
|
|
233
|
+
}
|
|
234
|
+
mono() {
|
|
235
|
+
return this.applyStyles(new PrefixStyler().mono());
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Message styling proxy with fluent API
|
|
240
|
+
*/
|
|
241
|
+
class MessageStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
242
|
+
constructor(parentBuilder) {
|
|
243
|
+
super(parentBuilder, 'message');
|
|
244
|
+
}
|
|
245
|
+
readable() {
|
|
246
|
+
return this.applyStyles(new MessageStyler().readable());
|
|
247
|
+
}
|
|
248
|
+
code() {
|
|
249
|
+
return this.applyStyles(new MessageStyler().code());
|
|
250
|
+
}
|
|
251
|
+
large() {
|
|
252
|
+
return this.applyStyles(new MessageStyler().large());
|
|
253
|
+
}
|
|
254
|
+
system() {
|
|
255
|
+
return this.applyStyles(new MessageStyler().system());
|
|
256
|
+
}
|
|
257
|
+
mono() {
|
|
258
|
+
return this.applyStyles(new MessageStyler().mono());
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Location styling proxy with fluent API
|
|
263
|
+
*/
|
|
264
|
+
class LocationStyleBuilderProxy extends PartStyleBuilderProxy {
|
|
265
|
+
constructor(parentBuilder) {
|
|
266
|
+
super(parentBuilder, 'location');
|
|
267
|
+
}
|
|
268
|
+
subtle() {
|
|
269
|
+
return this.applyStyles(new LocationStyler().subtle());
|
|
270
|
+
}
|
|
271
|
+
hidden() {
|
|
272
|
+
return this.applyStyles(new LocationStyler().hidden());
|
|
273
|
+
}
|
|
274
|
+
clickable() {
|
|
275
|
+
return this.applyStyles(new LocationStyler().clickable());
|
|
276
|
+
}
|
|
277
|
+
muted() {
|
|
278
|
+
return this.applyStyles(new LocationStyler().muted());
|
|
279
|
+
}
|
|
280
|
+
mono() {
|
|
281
|
+
return this.applyStyles(new LocationStyler().mono());
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Create a new LogStyleBuilder instance
|
|
286
|
+
*/
|
|
287
|
+
export function createLogStyleBuilder(logger) {
|
|
288
|
+
return new LogStyleBuilder(logger);
|
|
289
|
+
}
|