@mks2508/better-logger 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{Logger-Cbi1f10o.js → Logger-CKqzXDh3.js} +2 -2
- package/dist/chunks/{Logger-Cbi1f10o.js.map → Logger-CKqzXDh3.js.map} +1 -1
- package/dist/chunks/{Logger-BZ7B7OXE.js → Logger-D_vuKP4l.js} +2 -2
- package/dist/chunks/{Logger-BZ7B7OXE.js.map → Logger-D_vuKP4l.js.map} +1 -1
- package/dist/chunks/cli-module-B-njrTWb.js +2 -0
- package/dist/chunks/cli-module-B-njrTWb.js.map +1 -0
- package/dist/chunks/{cli-module-ClIJmaT8.js → cli-module-Cx7qotPY.js} +16 -9
- package/dist/chunks/cli-module-Cx7qotPY.js.map +1 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/exports.cjs +1 -1
- package/dist/exports.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/styling.cjs +1 -1
- package/dist/styling.js +2 -2
- package/dist/terminal/formatter.d.ts.map +1 -1
- package/package.json +5 -1
- package/.claude/settings.local.json +0 -48
- package/.github/workflows/ci-quality.yml +0 -357
- package/.github/workflows/docs-demo.yml +0 -119
- package/.github/workflows/releases-core.yml +0 -512
- package/.github/workflows/releases-full.yml +0 -582
- package/.github/workflows-backup/ci.yml +0 -221
- package/.github/workflows-backup/nightly.yml +0 -196
- package/.github/workflows-backup/release-optimized.yml +0 -373
- package/.github/workflows-backup/release.yml +0 -269
- package/.release-notes-0.2.0.md +0 -129
- package/.yamllint +0 -28
- package/CHANGELOG.json +0 -1076
- package/CHANGELOG.md +0 -209
- package/CLAUDE.md +0 -217
- package/bun.lock +0 -333
- package/demo.html +0 -847
- package/dist/chunks/cli-module-CadqgZ1Z.js +0 -2
- package/dist/chunks/cli-module-CadqgZ1Z.js.map +0 -1
- package/dist/chunks/cli-module-ClIJmaT8.js.map +0 -1
- package/docs/API.md +0 -918
- package/docs/CORE.md +0 -264
- package/docs/DEVELOPMENT.md +0 -731
- package/docs/EXPORTS.md +0 -467
- package/docs/PACKAGES.md +0 -244
- package/docs/STYLING.md +0 -405
- package/docs/_config.yml +0 -36
- package/docs/index.md +0 -179
- package/examples/README.md +0 -208
- package/examples/basic-logging.js +0 -75
- package/examples/data-export.js +0 -234
- package/examples/package.json +0 -16
- package/examples/performance-timing.js +0 -170
- package/examples/simplified-api.js +0 -124
- package/examples/styling-themes.js +0 -207
- package/index.html +0 -358
- package/packages/core/package.json +0 -57
- package/packages/exports/package.json +0 -41
- package/packages/nodejs-opentui/README.md +0 -232
- package/packages/nodejs-opentui/package.json +0 -72
- package/packages/nodejs-opentui/src/LogRenderer.ts +0 -171
- package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +0 -178
- package/packages/nodejs-opentui/src/components/LogBadge.tsx +0 -131
- package/packages/nodejs-opentui/src/index.ts +0 -133
- package/packages/nodejs-opentui/src/types.ts +0 -158
- package/packages/nodejs-opentui/tsconfig.json +0 -20
- package/packages/styling/package.json +0 -41
- package/playground/demo-all.ts +0 -95
- package/playground/demo-box.ts +0 -85
- package/playground/demo-levels.ts +0 -56
- package/playground/demo-real-world.ts +0 -98
- package/playground/demo-spinner.ts +0 -77
- package/playground/demo-steps.ts +0 -72
- package/playground/demo-table.ts +0 -83
- package/project-utils/README.md +0 -172
- package/project-utils/auto-release-gemini.ts +0 -1193
- package/project-utils/auto-release-ui.ts +0 -1329
- package/project-utils/commit-generator.ts +0 -1385
- package/project-utils/commit-ui.ts +0 -264
- package/project-utils/git-utils.ts +0 -199
- package/project-utils/github-release-manager.ts +0 -466
- package/project-utils/project-config.ts +0 -260
- package/project-utils/prompt-templates.js +0 -345
- package/project-utils/prompt-templates.ts +0 -422
- package/project-utils/version-manager.ts +0 -1078
- package/public/vite.svg +0 -1
- package/src/Logger.ts +0 -1858
- package/src/ScopedLogger.ts +0 -256
- package/src/cli/CommandProcessor.ts +0 -248
- package/src/cli/commands/ConfigCommand.ts +0 -93
- package/src/cli/commands/ExportCommand.ts +0 -276
- package/src/cli/commands/HistoryCommand.ts +0 -117
- package/src/cli/commands/StatusCommand.ts +0 -112
- package/src/cli/commands/ThemeCommand.ts +0 -88
- package/src/cli/help.ts +0 -127
- package/src/cli/index.ts +0 -71
- package/src/cli-module.ts +0 -21
- package/src/cli-primitives/box.ts +0 -86
- package/src/cli-primitives/cli-table.ts +0 -62
- package/src/cli-primitives/divider.ts +0 -17
- package/src/cli-primitives/header.ts +0 -18
- package/src/cli-primitives/index.ts +0 -13
- package/src/cli-primitives/server-fallback.ts +0 -54
- package/src/cli-primitives/spinner.ts +0 -133
- package/src/cli-primitives/step.ts +0 -22
- package/src/constants.ts +0 -313
- package/src/core.ts +0 -397
- package/src/example.ts +0 -210
- package/src/exports-module.ts +0 -311
- package/src/handlers/AnalyticsLogHandler.ts +0 -22
- package/src/handlers/ExportLogHandler.ts +0 -610
- package/src/handlers/FileLogHandler.ts +0 -169
- package/src/handlers/RemoteLogHandler.ts +0 -42
- package/src/handlers/index.ts +0 -8
- package/src/hooks/HookManager.ts +0 -177
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +0 -395
- package/src/main.ts +0 -196
- package/src/serializers/SerializerRegistry.ts +0 -173
- package/src/serializers/index.ts +0 -1
- package/src/style.css +0 -96
- package/src/styling/LogStyleBuilder.ts +0 -355
- package/src/styling/SemanticStyles.ts +0 -380
- package/src/styling/SmartPresets.ts +0 -288
- package/src/styling/StyleBuilder.ts +0 -319
- package/src/styling/StyleCache.ts +0 -131
- package/src/styling/banners.ts +0 -168
- package/src/styling/index.ts +0 -27
- package/src/styling/themes.ts +0 -235
- package/src/styling-module.ts +0 -244
- package/src/terminal/color-converter.ts +0 -315
- package/src/terminal/formatter.ts +0 -236
- package/src/terminal/terminal-renderer.ts +0 -342
- package/src/transports/ConsoleTransport.ts +0 -28
- package/src/transports/FileTransport.ts +0 -53
- package/src/transports/HttpTransport.ts +0 -56
- package/src/transports/TransportManager.ts +0 -130
- package/src/transports/index.ts +0 -4
- package/src/types/core.ts +0 -417
- package/src/types/handlers.ts +0 -95
- package/src/types/hooks.ts +0 -45
- package/src/types/index.ts +0 -83
- package/src/types/serializers.ts +0 -30
- package/src/types/transports.ts +0 -52
- package/src/typescript.svg +0 -1
- package/src/utils/adapter.ts +0 -291
- package/src/utils/ansi-colors.ts +0 -333
- package/src/utils/environment-detector.ts +0 -170
- package/src/utils/environment.ts +0 -94
- package/src/utils/formatting.ts +0 -332
- package/src/utils/index.ts +0 -33
- package/src/utils/opentui-detection.ts +0 -138
- package/src/utils/output.ts +0 -227
- package/src/utils/stackTrace.ts +0 -144
- package/src/utils/timestamps.ts +0 -80
- package/src/vite-env.d.ts +0 -1
- package/src/writers/BufferWriter.ts +0 -157
- package/src/writers/index.ts +0 -6
- package/test-core-browser.html +0 -237
- package/test-core-node.js +0 -63
- package/tests/test-conflict-resolution.ts +0 -391
- package/tests/validate-workflows.sh +0 -131
- package/tests/yaml-autofix.sh +0 -146
- package/tsconfig.json +0 -50
- package/vite.config.ts +0 -256
package/src/index.ts
DELETED
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Better Logger - Librería completa con todas las características
|
|
3
|
-
* @version 0.3.0
|
|
4
|
-
* @since 2024
|
|
5
|
-
*
|
|
6
|
-
* Punto de entrada principal que proporciona la experiencia completa de Better Logger
|
|
7
|
-
* con características avanzadas incluyendo estilos CSS, soporte SVG, animaciones,
|
|
8
|
-
* capacidades de exportación y logging remoto.
|
|
9
|
-
*
|
|
10
|
-
* @module @mks2508/better-logger
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// Main Logger class with all features
|
|
14
|
-
import { Logger } from './Logger.js';
|
|
15
|
-
import type {
|
|
16
|
-
LogLevel,
|
|
17
|
-
Verbosity,
|
|
18
|
-
ThemeVariant,
|
|
19
|
-
BannerType,
|
|
20
|
-
StyleOptions,
|
|
21
|
-
ILogHandler,
|
|
22
|
-
CLILogLevel,
|
|
23
|
-
IBoxOptions,
|
|
24
|
-
ITableOptions,
|
|
25
|
-
} from './types/index.js';
|
|
26
|
-
|
|
27
|
-
// Lazy singleton - se inicializa solo cuando se necesita
|
|
28
|
-
let _logger: Logger | null = null;
|
|
29
|
-
|
|
30
|
-
function getLogger(): Logger {
|
|
31
|
-
if (!_logger) {
|
|
32
|
-
_logger = new Logger();
|
|
33
|
-
}
|
|
34
|
-
return _logger;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Clase principal Logger con conjunto completo de características
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* // Importación y uso básico
|
|
42
|
-
* import { Logger } from '@mks2508/better-logger';
|
|
43
|
-
*
|
|
44
|
-
* const logger = new Logger();
|
|
45
|
-
* logger.preset('cyberpunk'); // Aplicar preset completo
|
|
46
|
-
* logger.info('¡Hola mundo!');
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* // Logger con scope para componentes
|
|
50
|
-
* const auth = logger.component('Auth');
|
|
51
|
-
* auth.info('Usuario autenticando...');
|
|
52
|
-
* auth.success('Login exitoso');
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* // Logger para APIs con badges
|
|
56
|
-
* const api = logger.api('GraphQL');
|
|
57
|
-
* api.badges(['v2', 'cached']).info('Query ejecutada');
|
|
58
|
-
*
|
|
59
|
-
* @since 0.3.0
|
|
60
|
-
*/
|
|
61
|
-
export { Logger };
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Instancia singleton del logger lista para usar
|
|
65
|
-
* @default
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* // Uso directo sin crear instancia
|
|
69
|
-
* import logger from '@mks2508/better-logger';
|
|
70
|
-
*
|
|
71
|
-
* logger.info('Aplicación iniciada');
|
|
72
|
-
* logger.success('Conexión establecida');
|
|
73
|
-
* logger.warn('Memoria al 80%');
|
|
74
|
-
* logger.error('Fallo en conexión');
|
|
75
|
-
*/
|
|
76
|
-
export default getLogger();
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Métodos de logging individuales (enlazados al singleton)
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* // Importar solo los métodos necesarios
|
|
83
|
-
* import { info, error, success } from '@mks2508/better-logger';
|
|
84
|
-
*
|
|
85
|
-
* info('Proceso iniciado');
|
|
86
|
-
* success('✓ Completado exitosamente');
|
|
87
|
-
* error('Error:', errorDetails);
|
|
88
|
-
*
|
|
89
|
-
* @since 0.3.0
|
|
90
|
-
*/
|
|
91
|
-
export const debug = (...args: any[]) => getLogger().debug(...args);
|
|
92
|
-
export const info = (...args: any[]) => getLogger().info(...args);
|
|
93
|
-
export const warn = (...args: any[]) => getLogger().warn(...args);
|
|
94
|
-
export const error = (...args: any[]) => getLogger().error(...args);
|
|
95
|
-
export const success = (...args: any[]) => getLogger().success(...args);
|
|
96
|
-
export const critical = (...args: any[]) => getLogger().critical(...args);
|
|
97
|
-
export const trace = (...args: any[]) => getLogger().trace(...args);
|
|
98
|
-
export const table = (data: any, columns?: string[]) => getLogger().table(data, columns);
|
|
99
|
-
export const group = (label: string, collapsed?: boolean) => getLogger().group(label, collapsed);
|
|
100
|
-
export const groupEnd = () => getLogger().groupEnd();
|
|
101
|
-
export const time = (label: string) => getLogger().time(label);
|
|
102
|
-
export const timeEnd = (label: string) => getLogger().timeEnd(label);
|
|
103
|
-
export const setGlobalPrefix = (prefix: string) => getLogger().setGlobalPrefix(prefix);
|
|
104
|
-
export const scope = (name: string) => getLogger().scope(name);
|
|
105
|
-
export const component = (name: string) => getLogger().component(name);
|
|
106
|
-
export const api = (name: string) => getLogger().api(name);
|
|
107
|
-
export const badges = (badgeList: string[]) => getLogger().badges(badgeList);
|
|
108
|
-
export const badge = (badgeName: string) => getLogger().badge(badgeName);
|
|
109
|
-
export const clearBadges = () => getLogger().clearBadges();
|
|
110
|
-
export const setVerbosity = (level: Verbosity) => getLogger().setVerbosity(level);
|
|
111
|
-
export const addHandler = (handler: ILogHandler) => getLogger().addHandler(handler);
|
|
112
|
-
export const setTheme = (theme: ThemeVariant) => getLogger().setTheme(theme);
|
|
113
|
-
export const setBannerType = (bannerType: BannerType) => getLogger().setBannerType(bannerType);
|
|
114
|
-
export const showBanner = (bannerType?: BannerType) => getLogger().showBanner(bannerType);
|
|
115
|
-
export const logWithSVG = (message: string, svgContent?: string, options?: StyleOptions) =>
|
|
116
|
-
getLogger().logWithSVG(message, svgContent, options);
|
|
117
|
-
export const logAnimated = (message: string, duration?: number) =>
|
|
118
|
-
getLogger().logAnimated(message, duration);
|
|
119
|
-
export const cli = (command: string) => getLogger().cli(command);
|
|
120
|
-
|
|
121
|
-
// CLI Primitives (v5.0)
|
|
122
|
-
export const step = (current: number, total: number, message: string) => getLogger().step(current, total, message);
|
|
123
|
-
export const spinner = (message: string) => getLogger().spinner(message);
|
|
124
|
-
export const box = (content: string, options?: IBoxOptions) => getLogger().box(content, options);
|
|
125
|
-
export const cliTable = (rows: Record<string, unknown>[], options?: ITableOptions) => getLogger().cliTable(rows, options);
|
|
126
|
-
export const header = (title: string, subtitle?: string) => getLogger().header(title, subtitle);
|
|
127
|
-
export const divider = () => getLogger().divider();
|
|
128
|
-
export const blank = () => getLogger().blank();
|
|
129
|
-
export const setCLILevel = (level: CLILogLevel) => getLogger().setCLILevel(level);
|
|
130
|
-
|
|
131
|
-
// Type exports
|
|
132
|
-
export type {
|
|
133
|
-
LogLevel,
|
|
134
|
-
Verbosity,
|
|
135
|
-
ThemeVariant,
|
|
136
|
-
BannerType,
|
|
137
|
-
StyleOptions,
|
|
138
|
-
ILogHandler,
|
|
139
|
-
LoggerConfig,
|
|
140
|
-
LogMetadata,
|
|
141
|
-
StackInfo,
|
|
142
|
-
TimerEntry,
|
|
143
|
-
TimerResult,
|
|
144
|
-
OutputFormat,
|
|
145
|
-
IScopedLogger,
|
|
146
|
-
IAPILogger,
|
|
147
|
-
IComponentLogger,
|
|
148
|
-
Bindings,
|
|
149
|
-
SerializerFn,
|
|
150
|
-
SerializerContext,
|
|
151
|
-
SerializerConfig,
|
|
152
|
-
ISerializerRegistry,
|
|
153
|
-
HookLogEntry,
|
|
154
|
-
HookEvent,
|
|
155
|
-
HookCallback,
|
|
156
|
-
MiddlewareFn,
|
|
157
|
-
IHookManager,
|
|
158
|
-
TransportRecord,
|
|
159
|
-
TransportOptions,
|
|
160
|
-
TransportTarget,
|
|
161
|
-
ITransport,
|
|
162
|
-
StyleCacheConfig,
|
|
163
|
-
BadgeStyle,
|
|
164
|
-
TimestampFormat,
|
|
165
|
-
ColumnAlign,
|
|
166
|
-
ColumnConfig,
|
|
167
|
-
LogOptions,
|
|
168
|
-
CLILogLevel,
|
|
169
|
-
ISpinnerHandle,
|
|
170
|
-
IBoxOptions,
|
|
171
|
-
ITableOptions,
|
|
172
|
-
} from './types/index.js';
|
|
173
|
-
|
|
174
|
-
// Styling utilities
|
|
175
|
-
export {
|
|
176
|
-
StyleBuilder,
|
|
177
|
-
StylePresets,
|
|
178
|
-
THEME_PRESETS,
|
|
179
|
-
THEME_BANNERS,
|
|
180
|
-
BANNER_VARIANTS
|
|
181
|
-
} from './styling/index.js';
|
|
182
|
-
|
|
183
|
-
// Handler exports
|
|
184
|
-
export {
|
|
185
|
-
FileLogHandler,
|
|
186
|
-
RemoteLogHandler,
|
|
187
|
-
AnalyticsLogHandler
|
|
188
|
-
} from './handlers/index.js';
|
|
189
|
-
|
|
190
|
-
// Serializers
|
|
191
|
-
export { SerializerRegistry } from './serializers/index.js';
|
|
192
|
-
|
|
193
|
-
// Hooks & Middleware
|
|
194
|
-
export { HookManager } from './hooks/index.js';
|
|
195
|
-
|
|
196
|
-
// Transports
|
|
197
|
-
export {
|
|
198
|
-
TransportManager,
|
|
199
|
-
ConsoleTransport,
|
|
200
|
-
FileTransport,
|
|
201
|
-
HttpTransport
|
|
202
|
-
} from './transports/index.js';
|
|
203
|
-
|
|
204
|
-
// Style Cache
|
|
205
|
-
export { StyleCache, getStyleCache } from './styling/StyleCache.js';
|
|
206
|
-
|
|
207
|
-
// Enterprise feature function exports
|
|
208
|
-
import type { SerializerFn, HookEvent, HookCallback, MiddlewareFn, TransportTarget } from './types/index.js';
|
|
209
|
-
export const addSerializer = <T>(
|
|
210
|
-
type: new (...args: any[]) => T,
|
|
211
|
-
serializer: SerializerFn<T>,
|
|
212
|
-
priority?: number
|
|
213
|
-
) => getLogger().addSerializer(type, serializer, priority);
|
|
214
|
-
export const removeSerializer = <T>(type: new (...args: any[]) => T) =>
|
|
215
|
-
getLogger().removeSerializer(type);
|
|
216
|
-
export const on = (event: HookEvent, callback: HookCallback, priority?: number) =>
|
|
217
|
-
getLogger().on(event, callback, priority);
|
|
218
|
-
export const once = (event: HookEvent, callback: HookCallback, priority?: number) =>
|
|
219
|
-
getLogger().once(event, callback, priority);
|
|
220
|
-
export const off = (event: HookEvent, callback: HookCallback) =>
|
|
221
|
-
getLogger().off(event, callback);
|
|
222
|
-
export const use = (middleware: MiddlewareFn, priority?: number) =>
|
|
223
|
-
getLogger().use(middleware, priority);
|
|
224
|
-
export const addTransport = (target: TransportTarget) =>
|
|
225
|
-
getLogger().addTransport(target);
|
|
226
|
-
export const removeTransport = (id: string) =>
|
|
227
|
-
getLogger().removeTransport(id);
|
|
228
|
-
export const flushTransports = () =>
|
|
229
|
-
getLogger().flushTransports();
|
|
230
|
-
export const closeTransports = () =>
|
|
231
|
-
getLogger().closeTransports();
|
|
232
|
-
|
|
233
|
-
// Scoped loggers
|
|
234
|
-
export {
|
|
235
|
-
ScopedLogger,
|
|
236
|
-
APILogger,
|
|
237
|
-
ComponentLogger,
|
|
238
|
-
ContextLogger
|
|
239
|
-
} from './ScopedLogger.js';
|
|
240
|
-
|
|
241
|
-
// Constants
|
|
242
|
-
export { DEFAULT_CONFIG } from './constants.js';
|
|
243
|
-
|
|
244
|
-
// Utility exports
|
|
245
|
-
export {
|
|
246
|
-
parseStackTrace,
|
|
247
|
-
formatTimestamp,
|
|
248
|
-
detectOptimalFormat,
|
|
249
|
-
createOutput,
|
|
250
|
-
createANSIOutput,
|
|
251
|
-
createBuildOutput,
|
|
252
|
-
createCIOutput
|
|
253
|
-
} from './utils/index.js';
|
|
254
|
-
|
|
255
|
-
// ANSI color utilities
|
|
256
|
-
export {
|
|
257
|
-
ansiStyle,
|
|
258
|
-
ansiColor,
|
|
259
|
-
ansiBackground,
|
|
260
|
-
ansiBold,
|
|
261
|
-
ansiDim,
|
|
262
|
-
ansiUnderline,
|
|
263
|
-
formatLogLevelANSI,
|
|
264
|
-
formatSuccessANSI,
|
|
265
|
-
BUILD_FORMATTERS,
|
|
266
|
-
sanitizeEmojis
|
|
267
|
-
} from './utils/ansi-colors.js';
|
|
268
|
-
|
|
269
|
-
// Environment detection and presets
|
|
270
|
-
export {
|
|
271
|
-
BUILD_PRESETS,
|
|
272
|
-
ENVIRONMENT_DETECTION,
|
|
273
|
-
detectEnvironmentPreset,
|
|
274
|
-
getOptimalConfig
|
|
275
|
-
} from './constants.js';
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Utilidades de estilo para crear estilos personalizados de consola
|
|
279
|
-
*
|
|
280
|
-
* @example
|
|
281
|
-
* // Crear estilo personalizado
|
|
282
|
-
* import { createStyle, stylePresets } from '@mks2508/better-logger';
|
|
283
|
-
*
|
|
284
|
-
* const miEstilo = createStyle()
|
|
285
|
-
* .bg('linear-gradient(45deg, #ff6b6b, #feca57)')
|
|
286
|
-
* .color('white')
|
|
287
|
-
* .padding('10px')
|
|
288
|
-
* .rounded('8px')
|
|
289
|
-
* .bold()
|
|
290
|
-
* .build();
|
|
291
|
-
*
|
|
292
|
-
* console.log('%cMensaje estilizado', miEstilo);
|
|
293
|
-
*
|
|
294
|
-
* @example
|
|
295
|
-
* // Usar presets predefinidos
|
|
296
|
-
* console.log('%cÉxito!', stylePresets.success);
|
|
297
|
-
* console.log('%cError!', stylePresets.error);
|
|
298
|
-
*
|
|
299
|
-
* @since 0.3.0
|
|
300
|
-
*/
|
|
301
|
-
import { StyleBuilder, StylePresets } from './styling/index.js';
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Crea una nueva instancia de StyleBuilder para estilos personalizados de consola
|
|
305
|
-
*
|
|
306
|
-
* @returns {StyleBuilder} Constructor de estilos encadenable
|
|
307
|
-
*
|
|
308
|
-
* @example
|
|
309
|
-
* const estilo = createStyle()
|
|
310
|
-
* .gradient('#667eea', '#764ba2')
|
|
311
|
-
* .color('white')
|
|
312
|
-
* .padding('8px 16px')
|
|
313
|
-
* .rounded('4px')
|
|
314
|
-
* .shadow('0 2px 4px rgba(0,0,0,0.2)')
|
|
315
|
-
* .build();
|
|
316
|
-
*
|
|
317
|
-
* @since 0.3.0
|
|
318
|
-
*/
|
|
319
|
-
export const createStyle = () => new StyleBuilder();
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Presets de estilo predefinidos para casos de uso comunes
|
|
323
|
-
*
|
|
324
|
-
* @constant {Object} stylePresets
|
|
325
|
-
*
|
|
326
|
-
* @example
|
|
327
|
-
* console.log('%cOperación exitosa', stylePresets.success);
|
|
328
|
-
* console.log('%cAdvertencia', stylePresets.warning);
|
|
329
|
-
* console.log('%cError crítico', stylePresets.error);
|
|
330
|
-
* console.log('%cInformación', stylePresets.info);
|
|
331
|
-
* console.log('%cDestacado', stylePresets.accent);
|
|
332
|
-
*
|
|
333
|
-
* @since 0.3.0
|
|
334
|
-
*/
|
|
335
|
-
export const stylePresets = {
|
|
336
|
-
success: StylePresets.success().build(),
|
|
337
|
-
error: StylePresets.error().build(),
|
|
338
|
-
warning: StylePresets.warning().build(),
|
|
339
|
-
info: StylePresets.info().build(),
|
|
340
|
-
accent: StylePresets.accent().build(),
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
// Terminal formatting utilities
|
|
344
|
-
export {
|
|
345
|
-
formatWithRightAlign,
|
|
346
|
-
formatColumns,
|
|
347
|
-
formatKeyValue,
|
|
348
|
-
formatBadge,
|
|
349
|
-
formatTimestamp as formatTimestampExt,
|
|
350
|
-
formatRelativeTime,
|
|
351
|
-
formatElapsedTime,
|
|
352
|
-
resetStartTime,
|
|
353
|
-
isKeyValueObject,
|
|
354
|
-
stripAnsi,
|
|
355
|
-
getVisibleLength,
|
|
356
|
-
padToWidth,
|
|
357
|
-
applyLogOptions,
|
|
358
|
-
} from './terminal/formatter.js';
|
|
359
|
-
|
|
360
|
-
// Color converter utilities
|
|
361
|
-
export {
|
|
362
|
-
hexToRgb,
|
|
363
|
-
rgbToHex,
|
|
364
|
-
hexTo256,
|
|
365
|
-
colorToHex,
|
|
366
|
-
getANSIForeground,
|
|
367
|
-
getANSIBackground,
|
|
368
|
-
getANSI256Foreground,
|
|
369
|
-
getANSI256Background,
|
|
370
|
-
cssColorToANSI,
|
|
371
|
-
ANSI,
|
|
372
|
-
} from './terminal/color-converter.js';
|
|
373
|
-
|
|
374
|
-
export type { RGB, ColorCapability } from './terminal/color-converter.js';
|
|
375
|
-
|
|
376
|
-
// Terminal renderer
|
|
377
|
-
export { TerminalRenderer } from './terminal/terminal-renderer.js';
|
|
378
|
-
export type { ANSIStyle, ChalkLikeInterface } from './terminal/terminal-renderer.js';
|
|
379
|
-
|
|
380
|
-
// Environment detection
|
|
381
|
-
export {
|
|
382
|
-
getEnvironment,
|
|
383
|
-
isRunningInTerminal,
|
|
384
|
-
supportsANSI,
|
|
385
|
-
getColorCapability,
|
|
386
|
-
getTerminalWidth,
|
|
387
|
-
getTerminalHeight,
|
|
388
|
-
getEnvironmentInfo,
|
|
389
|
-
} from './utils/environment-detector.js';
|
|
390
|
-
|
|
391
|
-
export type { Environment } from './utils/environment-detector.js';
|
|
392
|
-
|
|
393
|
-
// Output writers for custom log destinations
|
|
394
|
-
export { BufferWriter, type BufferEntry } from './writers/index.js';
|
|
395
|
-
export type { OutputWriter, OutputMode } from './types/core.js';
|
package/src/main.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
debug,
|
|
3
|
-
info,
|
|
4
|
-
warn,
|
|
5
|
-
error,
|
|
6
|
-
success,
|
|
7
|
-
critical,
|
|
8
|
-
table,
|
|
9
|
-
group,
|
|
10
|
-
groupEnd,
|
|
11
|
-
time,
|
|
12
|
-
timeEnd,
|
|
13
|
-
trace,
|
|
14
|
-
scope,
|
|
15
|
-
cli,
|
|
16
|
-
setTheme,
|
|
17
|
-
setBannerType,
|
|
18
|
-
showBanner,
|
|
19
|
-
logWithSVG,
|
|
20
|
-
logAnimated,
|
|
21
|
-
createStyle,
|
|
22
|
-
stylePresets
|
|
23
|
-
} from './index.js';
|
|
24
|
-
|
|
25
|
-
import {
|
|
26
|
-
demonstrateBanners,
|
|
27
|
-
demonstrateThemes,
|
|
28
|
-
demonstrateSVG,
|
|
29
|
-
demonstrateAnimations,
|
|
30
|
-
demonstrateCLI,
|
|
31
|
-
demonstrateExports,
|
|
32
|
-
demonstrateAllFeatures as demoAllFeatures
|
|
33
|
-
} from './example.js';
|
|
34
|
-
|
|
35
|
-
console.log('%cBetter Logger Demo Ready! 🚀',
|
|
36
|
-
'background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 10px 20px; border-radius: 8px; font-weight: bold; font-size: 14px;');
|
|
37
|
-
|
|
38
|
-
console.log('📋 Available test functions: testDebug(), testBanners(), testThemes(), and more!');
|
|
39
|
-
console.log('💻 CLI Available: cli("/help") for commands');
|
|
40
|
-
|
|
41
|
-
function testDebug() {
|
|
42
|
-
debug("This is a debug message.", { user: "test", id: 123 });
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function testInfo() {
|
|
46
|
-
info("This is an info message with an object.", { data: "payload" });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function testWarn() {
|
|
50
|
-
warn("This is a warning message about a deprecated API.");
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function testError() {
|
|
54
|
-
error("This is an error message.", new Error("Failed to fetch resource."));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function testSuccess() {
|
|
58
|
-
success("Operation completed successfully.");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function testCritical() {
|
|
62
|
-
critical("This is a CRITICAL message. System integrity compromised!");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function testTable() {
|
|
66
|
-
table([
|
|
67
|
-
{ feature: "Debug Log", status: "Implemented", priority: "Low" },
|
|
68
|
-
{ feature: "Info Log", status: "Implemented", priority: "Medium" },
|
|
69
|
-
{ feature: "Warning Log", status: "Implemented", priority: "High" },
|
|
70
|
-
]);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function testGrouping() {
|
|
74
|
-
group("User Authentication Flow", true); // Start collapsed
|
|
75
|
-
info("User 'testuser' attempting to log in...");
|
|
76
|
-
warn("Password nearing expiration.");
|
|
77
|
-
success("Login successful.");
|
|
78
|
-
groupEnd();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function testTiming() {
|
|
82
|
-
time("dataProcessing");
|
|
83
|
-
setTimeout(() => {
|
|
84
|
-
timeEnd("dataProcessing");
|
|
85
|
-
}, 750); // Simulate a 750ms operation
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function testScopedLogger() {
|
|
89
|
-
info("Demonstrating scoped loggers...");
|
|
90
|
-
const apiLogger = scope("API");
|
|
91
|
-
apiLogger.info("Fetching user data...");
|
|
92
|
-
const uiLogger = scope("UI");
|
|
93
|
-
uiLogger.debug("Rendering user profile component.");
|
|
94
|
-
apiLogger.success("User data fetched successfully.");
|
|
95
|
-
apiLogger.error("Failed to update settings.");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function testTrace() {
|
|
99
|
-
function innerFunction() {
|
|
100
|
-
function deepFunction() {
|
|
101
|
-
trace("Trace from a deeply nested function.");
|
|
102
|
-
}
|
|
103
|
-
deepFunction();
|
|
104
|
-
}
|
|
105
|
-
innerFunction();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Visual feature tests
|
|
109
|
-
function testBanners() {
|
|
110
|
-
demonstrateBanners();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function testThemes() {
|
|
114
|
-
demonstrateThemes();
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function testSVG() {
|
|
118
|
-
demonstrateSVG();
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function testAnimations() {
|
|
122
|
-
demonstrateAnimations();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function testCLI() {
|
|
126
|
-
demonstrateCLI();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function testExports() {
|
|
130
|
-
demonstrateExports();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function testAllFeatures() {
|
|
134
|
-
group("🌟 Demonstrating Core Logger Features");
|
|
135
|
-
testDebug();
|
|
136
|
-
testInfo();
|
|
137
|
-
testWarn();
|
|
138
|
-
testError();
|
|
139
|
-
testSuccess();
|
|
140
|
-
testCritical();
|
|
141
|
-
testTable();
|
|
142
|
-
testGrouping();
|
|
143
|
-
testTiming();
|
|
144
|
-
testScopedLogger();
|
|
145
|
-
testTrace();
|
|
146
|
-
groupEnd();
|
|
147
|
-
|
|
148
|
-
setTimeout(() => {
|
|
149
|
-
info('🎨 Running visual features demo...');
|
|
150
|
-
demoAllFeatures();
|
|
151
|
-
}, 2000);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Expose functions to global scope for onclick attributes in index.html
|
|
155
|
-
if (typeof window !== 'undefined') {
|
|
156
|
-
// Core logging tests
|
|
157
|
-
(window as any).testDebug = testDebug;
|
|
158
|
-
(window as any).testInfo = testInfo;
|
|
159
|
-
(window as any).testWarn = testWarn;
|
|
160
|
-
(window as any).testError = testError;
|
|
161
|
-
(window as any).testSuccess = testSuccess;
|
|
162
|
-
(window as any).testCritical = testCritical;
|
|
163
|
-
(window as any).testTable = testTable;
|
|
164
|
-
(window as any).testGrouping = testGrouping;
|
|
165
|
-
(window as any).testTiming = testTiming;
|
|
166
|
-
(window as any).testScopedLogger = testScopedLogger;
|
|
167
|
-
(window as any).testTrace = testTrace;
|
|
168
|
-
(window as any).testAllFeatures = testAllFeatures;
|
|
169
|
-
|
|
170
|
-
// Visual feature tests
|
|
171
|
-
(window as any).testBanners = testBanners;
|
|
172
|
-
(window as any).testThemes = testThemes;
|
|
173
|
-
(window as any).testSVG = testSVG;
|
|
174
|
-
(window as any).testAnimations = testAnimations;
|
|
175
|
-
(window as any).testCLI = testCLI;
|
|
176
|
-
(window as any).testExports = testExports;
|
|
177
|
-
|
|
178
|
-
// Direct access to library functions
|
|
179
|
-
(window as any).cli = cli;
|
|
180
|
-
(window as any).setTheme = setTheme;
|
|
181
|
-
(window as any).setBannerType = setBannerType;
|
|
182
|
-
(window as any).showBanner = showBanner;
|
|
183
|
-
(window as any).logWithSVG = logWithSVG;
|
|
184
|
-
(window as any).logAnimated = logAnimated;
|
|
185
|
-
(window as any).createStyle = createStyle;
|
|
186
|
-
(window as any).stylePresets = stylePresets;
|
|
187
|
-
|
|
188
|
-
// Display welcome info
|
|
189
|
-
setTimeout(() => {
|
|
190
|
-
console.log('%c💡 Quick Start Guide', stylePresets.info);
|
|
191
|
-
console.log('🎨 Visual: testBanners(), testThemes(), testSVG(), testAnimations()');
|
|
192
|
-
console.log('📊 Core: testTable(), testGrouping(), testTiming(), testTrace()');
|
|
193
|
-
console.log('💻 CLI: cli("/help") - Try commands like "/theme neon", "/banner ascii"');
|
|
194
|
-
console.log('🌟 Full Demo: testAllFeatures()');
|
|
195
|
-
}, 1000);
|
|
196
|
-
}
|