@mks2508/better-logger 0.14.0-alpha.2 → 1.1.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 +2 -1
- package/dist/Logger.d.ts +12 -16
- package/dist/Logger.d.ts.map +1 -1
- package/dist/ScopedLogger.d.ts +1 -9
- package/dist/chunks/{Logger-D_p3xnbq.js → Logger-C9zTFYBh.js} +2 -2
- package/dist/chunks/Logger-C9zTFYBh.js.map +1 -0
- package/dist/chunks/{Logger-Crw1woqR.js → Logger-Th9SfADL.js} +50 -17
- package/dist/chunks/Logger-Th9SfADL.js.map +1 -0
- package/dist/chunks/ScopedLogger-HgV_J-ug.js +2 -0
- package/dist/chunks/ScopedLogger-HgV_J-ug.js.map +1 -0
- package/dist/chunks/ScopedLogger-uAAeJkfA.js +361 -0
- package/dist/chunks/ScopedLogger-uAAeJkfA.js.map +1 -0
- package/dist/chunks/environment-5I5unY89.js +4 -0
- package/dist/chunks/environment-5I5unY89.js.map +1 -0
- package/dist/chunks/{environment-Bxbnw4pd.js → environment-wXLQvk5g.js} +103 -11
- package/dist/chunks/environment-wXLQvk5g.js.map +1 -0
- package/dist/chunks/formatting-CiFnwe1I.js +2 -0
- package/dist/chunks/formatting-CiFnwe1I.js.map +1 -0
- package/dist/chunks/formatting-DIhpRCCk.js +380 -0
- package/dist/chunks/formatting-DIhpRCCk.js.map +1 -0
- package/dist/cli/CommandProcessor.d.ts +1 -4
- package/dist/cli/commands/ConfigCommand.d.ts +2 -5
- package/dist/cli/commands/ExportCommand.d.ts +2 -5
- package/dist/cli/commands/HistoryCommand.d.ts +2 -5
- package/dist/cli/commands/StatusCommand.d.ts +2 -5
- package/dist/cli/commands/ThemeCommand.d.ts +2 -5
- package/dist/cli/help.d.ts +2 -5
- package/dist/cli/index.d.ts +1 -1
- package/dist/constants.d.ts +110 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +1 -8
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +281 -307
- package/dist/core.js.map +1 -1
- package/dist/exports-module.d.ts +1 -8
- package/dist/exports.cjs +1 -1
- package/dist/exports.js +2 -2
- package/dist/handlers/AnalyticsLogHandler.d.ts +1 -4
- package/dist/handlers/ExportLogHandler.d.ts +1 -4
- package/dist/handlers/ExportLogHandler.d.ts.map +1 -1
- package/dist/handlers/FileLogHandler.d.ts +1 -4
- package/dist/handlers/RemoteLogHandler.d.ts +1 -4
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -41
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +246 -159
- package/dist/index.js.map +1 -1
- package/dist/styling/LogStyleBuilder.d.ts +2 -5
- package/dist/styling/SemanticStyles.d.ts +0 -3
- package/dist/styling/SmartPresets.d.ts +1 -4
- package/dist/styling/banners.d.ts +1 -4
- package/dist/styling/themes.d.ts +2 -5
- package/dist/styling-module.d.ts +1 -8
- package/dist/styling.cjs +1 -1
- package/dist/styling.js +3 -3
- package/dist/types/core.d.ts +13 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/handlers.d.ts +1 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/ansi-colors.d.ts +156 -0
- package/dist/utils/ansi-colors.d.ts.map +1 -0
- package/dist/utils/formatting.d.ts +20 -2
- package/dist/utils/formatting.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/output.d.ts +1 -4
- package/dist/utils/stackTrace.d.ts +1 -4
- package/package.json +2 -1
- package/src/Logger.ts +102 -64
- package/src/constants.ts +131 -1
- package/src/core.ts +11 -7
- package/src/handlers/ExportLogHandler.ts +2 -1
- package/src/index.ts +62 -27
- package/src/styling/SemanticStyles.ts +1 -1
- package/src/types/core.ts +15 -1
- package/src/types/index.ts +1 -0
- package/src/utils/ansi-colors.ts +333 -0
- package/src/utils/formatting.ts +196 -6
- package/src/utils/index.ts +23 -11
- package/vite.config.ts +1 -1
- package/dist/.tsbuildinfo +0 -1
- package/dist/Logger.js +0 -1124
- package/dist/ScopedLogger.js +0 -426
- package/dist/chunks/Logger-Crw1woqR.js.map +0 -1
- package/dist/chunks/Logger-D_p3xnbq.js.map +0 -1
- package/dist/chunks/environment-Bxbnw4pd.js.map +0 -1
- package/dist/chunks/environment-Dm66zOML.js +0 -4
- package/dist/chunks/environment-Dm66zOML.js.map +0 -1
- package/dist/chunks/formatting-C0riPC5_.js +0 -95
- package/dist/chunks/formatting-C0riPC5_.js.map +0 -1
- package/dist/chunks/formatting-DNCAV66-.js +0 -2
- package/dist/chunks/formatting-DNCAV66-.js.map +0 -1
- package/dist/cli/CommandProcessor.js +0 -184
- package/dist/cli/commands/ConfigCommand.js +0 -88
- package/dist/cli/commands/ExportCommand.js +0 -243
- package/dist/cli/commands/HistoryCommand.js +0 -96
- package/dist/cli/commands/StatusCommand.js +0 -93
- package/dist/cli/commands/ThemeCommand.js +0 -79
- package/dist/cli/help.js +0 -118
- package/dist/cli/index.js +0 -46
- package/dist/constants.js +0 -159
- package/dist/example.js +0 -154
- package/dist/exports-module.js +0 -260
- package/dist/handlers/AnalyticsLogHandler.js +0 -19
- package/dist/handlers/ExportLogHandler.js +0 -516
- package/dist/handlers/FileLogHandler.js +0 -156
- package/dist/handlers/RemoteLogHandler.js +0 -37
- package/dist/handlers/index.js +0 -7
- package/dist/main.js +0 -139
- package/dist/styling/LogStyleBuilder.js +0 -289
- package/dist/styling/SemanticStyles.js +0 -339
- package/dist/styling/SmartPresets.js +0 -276
- package/dist/styling/StyleBuilder.js +0 -280
- package/dist/styling/banners.js +0 -155
- package/dist/styling/index.js +0 -9
- package/dist/styling/themes.js +0 -231
- package/dist/styling-module.js +0 -199
- package/dist/types/Logger.d.ts +0 -700
- package/dist/types/Logger.d.ts.map +0 -1
- package/dist/types/ScopedLogger.d.ts +0 -310
- package/dist/types/ScopedLogger.d.ts.map +0 -1
- package/dist/types/cli/CommandProcessor.d.ts +0 -100
- package/dist/types/cli/CommandProcessor.d.ts.map +0 -1
- package/dist/types/cli/commands/ConfigCommand.d.ts +0 -14
- package/dist/types/cli/commands/ConfigCommand.d.ts.map +0 -1
- package/dist/types/cli/commands/ExportCommand.d.ts +0 -48
- package/dist/types/cli/commands/ExportCommand.d.ts.map +0 -1
- package/dist/types/cli/commands/HistoryCommand.d.ts +0 -47
- package/dist/types/cli/commands/HistoryCommand.d.ts.map +0 -1
- package/dist/types/cli/commands/StatusCommand.d.ts +0 -30
- package/dist/types/cli/commands/StatusCommand.d.ts.map +0 -1
- package/dist/types/cli/commands/ThemeCommand.d.ts +0 -30
- package/dist/types/cli/commands/ThemeCommand.d.ts.map +0 -1
- package/dist/types/cli/help.d.ts +0 -12
- package/dist/types/cli/help.d.ts.map +0 -1
- package/dist/types/cli/index.d.ts +0 -15
- package/dist/types/cli/index.d.ts.map +0 -1
- package/dist/types/constants.d.ts +0 -119
- package/dist/types/constants.d.ts.map +0 -1
- package/dist/types/core.js +0 -28
- package/dist/types/example.d.ts +0 -18
- package/dist/types/example.d.ts.map +0 -1
- package/dist/types/exports-module.d.ts +0 -196
- package/dist/types/exports-module.d.ts.map +0 -1
- package/dist/types/handlers/AnalyticsLogHandler.d.ts +0 -8
- package/dist/types/handlers/AnalyticsLogHandler.d.ts.map +0 -1
- package/dist/types/handlers/ExportLogHandler.d.ts +0 -100
- package/dist/types/handlers/ExportLogHandler.d.ts.map +0 -1
- package/dist/types/handlers/FileLogHandler.d.ts +0 -33
- package/dist/types/handlers/FileLogHandler.d.ts.map +0 -1
- package/dist/types/handlers/RemoteLogHandler.d.ts +0 -11
- package/dist/types/handlers/RemoteLogHandler.d.ts.map +0 -1
- package/dist/types/handlers/index.d.ts +0 -8
- package/dist/types/handlers/index.d.ts.map +0 -1
- package/dist/types/handlers.js +0 -4
- package/dist/types/index.js +0 -4
- package/dist/types/main.d.ts +0 -2
- package/dist/types/main.d.ts.map +0 -1
- package/dist/types/styling/LogStyleBuilder.d.ts +0 -146
- package/dist/types/styling/LogStyleBuilder.d.ts.map +0 -1
- package/dist/types/styling/SemanticStyles.d.ts +0 -178
- package/dist/types/styling/SemanticStyles.d.ts.map +0 -1
- package/dist/types/styling/SmartPresets.d.ts +0 -22
- package/dist/types/styling/SmartPresets.d.ts.map +0 -1
- package/dist/types/styling/StyleBuilder.d.ts +0 -140
- package/dist/types/styling/StyleBuilder.d.ts.map +0 -1
- package/dist/types/styling/banners.d.ts +0 -42
- package/dist/types/styling/banners.d.ts.map +0 -1
- package/dist/types/styling/index.d.ts +0 -10
- package/dist/types/styling/index.d.ts.map +0 -1
- package/dist/types/styling/themes.d.ts +0 -7
- package/dist/types/styling/themes.d.ts.map +0 -1
- package/dist/types/styling-module.d.ts +0 -178
- package/dist/types/styling-module.d.ts.map +0 -1
- package/dist/types/types/core.d.ts +0 -221
- package/dist/types/types/core.d.ts.map +0 -1
- package/dist/types/types/handlers.d.ts +0 -85
- package/dist/types/types/handlers.d.ts.map +0 -1
- package/dist/types/types/index.d.ts +0 -7
- package/dist/types/types/index.d.ts.map +0 -1
- package/dist/types/utils/environment.d.ts +0 -47
- package/dist/types/utils/environment.d.ts.map +0 -1
- package/dist/types/utils/formatting.d.ts +0 -37
- package/dist/types/utils/formatting.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts +0 -7
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/types/utils/opentui-detection.d.ts +0 -34
- package/dist/types/utils/opentui-detection.d.ts.map +0 -1
- package/dist/types/utils/output.d.ts +0 -41
- package/dist/types/utils/output.d.ts.map +0 -1
- package/dist/types/utils/stackTrace.d.ts +0 -6
- package/dist/types/utils/stackTrace.d.ts.map +0 -1
- package/dist/types/utils/timestamps.d.ts +0 -20
- package/dist/types/utils/timestamps.d.ts.map +0 -1
- package/dist/utils/environment.js +0 -85
- package/dist/utils/formatting.js +0 -117
- package/dist/utils/index.js +0 -6
- package/dist/utils/opentui-detection.js +0 -116
- package/dist/utils/output.js +0 -150
- package/dist/utils/stackTrace.js +0 -81
- package/dist/utils/timestamps.js +0 -71
package/dist/types/handlers.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Type definitions exports for Advanced Logger
|
|
3
3
|
*/
|
|
4
|
-
export type { LogLevel, Verbosity, ThemeVariant, DevToolsTheme, BannerType, ExportFormat, LoggerConfig, StackInfo, TimerEntry, StyleOptions, AdaptiveColors, SpacingType, LogLayout, LogPartConfig, LogStyles, } from './core.js';
|
|
4
|
+
export type { LogLevel, Verbosity, ThemeVariant, DevToolsTheme, BannerType, ExportFormat, OutputFormat, LoggerConfig, StackInfo, TimerEntry, StyleOptions, AdaptiveColors, SpacingType, LogLayout, LogPartConfig, LogStyles, } from './core.js';
|
|
5
5
|
export { LOG_LEVELS } from './core.js';
|
|
6
6
|
export type { LogMetadata, ILogHandler, LogEntry, ExportFilters, ExportOptions, ExportResult, BufferStats, } from './handlers.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACR,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,UAAU,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,SAAS,EACT,aAAa,EACb,SAAS,GACZ,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,YAAY,EACR,WAAW,EACX,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,GACd,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,YAAY,EACR,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,aAAa,EACb,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,UAAU,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,SAAS,EACT,aAAa,EACb,SAAS,GACZ,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,YAAY,EACR,WAAW,EACX,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,GACd,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { LogLevel } from '../types/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* ANSI color codes for terminal styling
|
|
4
|
+
*/
|
|
5
|
+
export declare const ANSI_CODES: {
|
|
6
|
+
readonly black: 30;
|
|
7
|
+
readonly red: 31;
|
|
8
|
+
readonly green: 32;
|
|
9
|
+
readonly yellow: 33;
|
|
10
|
+
readonly blue: 34;
|
|
11
|
+
readonly magenta: 35;
|
|
12
|
+
readonly cyan: 36;
|
|
13
|
+
readonly white: 37;
|
|
14
|
+
readonly brightBlack: 90;
|
|
15
|
+
readonly brightRed: 91;
|
|
16
|
+
readonly brightGreen: 92;
|
|
17
|
+
readonly brightYellow: 93;
|
|
18
|
+
readonly brightBlue: 94;
|
|
19
|
+
readonly brightMagenta: 95;
|
|
20
|
+
readonly brightCyan: 96;
|
|
21
|
+
readonly brightWhite: 97;
|
|
22
|
+
readonly bgBlack: 40;
|
|
23
|
+
readonly bgRed: 41;
|
|
24
|
+
readonly bgGreen: 42;
|
|
25
|
+
readonly bgYellow: 43;
|
|
26
|
+
readonly bgBlue: 44;
|
|
27
|
+
readonly bgMagenta: 45;
|
|
28
|
+
readonly bgCyan: 46;
|
|
29
|
+
readonly bgWhite: 47;
|
|
30
|
+
readonly bgBrightBlack: 100;
|
|
31
|
+
readonly bgBrightRed: 101;
|
|
32
|
+
readonly bgBrightGreen: 102;
|
|
33
|
+
readonly bgBrightYellow: 103;
|
|
34
|
+
readonly bgBrightBlue: 104;
|
|
35
|
+
readonly bgBrightMagenta: 105;
|
|
36
|
+
readonly bgBrightCyan: 106;
|
|
37
|
+
readonly bgBrightWhite: 107;
|
|
38
|
+
readonly reset: 0;
|
|
39
|
+
readonly bold: 1;
|
|
40
|
+
readonly dim: 2;
|
|
41
|
+
readonly italic: 3;
|
|
42
|
+
readonly underline: 4;
|
|
43
|
+
readonly blink: 5;
|
|
44
|
+
readonly inverse: 7;
|
|
45
|
+
readonly hidden: 8;
|
|
46
|
+
readonly strikethrough: 9;
|
|
47
|
+
readonly resetBold: 22;
|
|
48
|
+
readonly resetDim: 22;
|
|
49
|
+
readonly resetItalic: 23;
|
|
50
|
+
readonly resetUnderline: 24;
|
|
51
|
+
readonly resetBlink: 25;
|
|
52
|
+
readonly resetInverse: 27;
|
|
53
|
+
readonly resetHidden: 28;
|
|
54
|
+
readonly resetStrikethrough: 29;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* ANSI color presets for different log levels
|
|
58
|
+
*/
|
|
59
|
+
export declare const ANSI_LEVEL_STYLES: Record<LogLevel | 'success', {
|
|
60
|
+
color: number;
|
|
61
|
+
background?: number;
|
|
62
|
+
styles: number[];
|
|
63
|
+
emoji: string;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Applies ANSI styling to text
|
|
67
|
+
*/
|
|
68
|
+
export declare function ansiStyle(text: string, codes: number[]): string;
|
|
69
|
+
/**
|
|
70
|
+
* Applies color to text
|
|
71
|
+
*/
|
|
72
|
+
export declare function ansiColor(text: string, color: number): string;
|
|
73
|
+
/**
|
|
74
|
+
* Applies background color to text
|
|
75
|
+
*/
|
|
76
|
+
export declare function ansiBackground(text: string, bg: number, color?: number): string;
|
|
77
|
+
/**
|
|
78
|
+
* Makes text bold
|
|
79
|
+
*/
|
|
80
|
+
export declare function ansiBold(text: string): string;
|
|
81
|
+
/**
|
|
82
|
+
* Makes text dim
|
|
83
|
+
*/
|
|
84
|
+
export declare function ansiDim(text: string): string;
|
|
85
|
+
/**
|
|
86
|
+
* Underlines text
|
|
87
|
+
*/
|
|
88
|
+
export declare function ansiUnderline(text: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Specialized formatters for different contexts
|
|
91
|
+
*/
|
|
92
|
+
/**
|
|
93
|
+
* Format timestamp for terminal
|
|
94
|
+
*/
|
|
95
|
+
export declare function formatTimestampANSI(timestamp: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Format log level for terminal
|
|
98
|
+
*/
|
|
99
|
+
export declare function formatLogLevelANSI(level: LogLevel, useEmojis?: boolean): string;
|
|
100
|
+
/**
|
|
101
|
+
* Format success message for terminal
|
|
102
|
+
*/
|
|
103
|
+
export declare function formatSuccessANSI(message: string, useEmojis?: boolean): string;
|
|
104
|
+
/**
|
|
105
|
+
* Format prefix for terminal
|
|
106
|
+
*/
|
|
107
|
+
export declare function formatPrefixANSI(prefix: string): string;
|
|
108
|
+
/**
|
|
109
|
+
* Format file location for terminal
|
|
110
|
+
*/
|
|
111
|
+
export declare function formatLocationANSI(location: string): string;
|
|
112
|
+
/**
|
|
113
|
+
* Format build-specific messages
|
|
114
|
+
*/
|
|
115
|
+
export declare const BUILD_FORMATTERS: {
|
|
116
|
+
/**
|
|
117
|
+
* Format compilation step
|
|
118
|
+
*/
|
|
119
|
+
compilation: (step: string, status?: "starting" | "completed" | "failed") => string;
|
|
120
|
+
/**
|
|
121
|
+
* Format warning message
|
|
122
|
+
*/
|
|
123
|
+
warning: (message: string) => string;
|
|
124
|
+
/**
|
|
125
|
+
* Format error message
|
|
126
|
+
*/
|
|
127
|
+
error: (message: string) => string;
|
|
128
|
+
/**
|
|
129
|
+
* Format success message
|
|
130
|
+
*/
|
|
131
|
+
success: (message: string) => string;
|
|
132
|
+
/**
|
|
133
|
+
* Format info message
|
|
134
|
+
*/
|
|
135
|
+
info: (message: string) => string;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Terminal-friendly emoji alternatives for environments that don't support them
|
|
139
|
+
*/
|
|
140
|
+
export declare const EMOJI_ALTERNATIVES: {
|
|
141
|
+
'\uD83D\uDD0D': string;
|
|
142
|
+
ℹ️: string;
|
|
143
|
+
'\u26A0\uFE0F': string;
|
|
144
|
+
'\u274C': string;
|
|
145
|
+
'\uD83D\uDEA8': string;
|
|
146
|
+
'\u2705': string;
|
|
147
|
+
'\u2713': string;
|
|
148
|
+
'\u2717': string;
|
|
149
|
+
'\u2699\uFE0F': string;
|
|
150
|
+
'\uD83D\uDCE6': string;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Replace emojis with text alternatives for non-emoji terminals
|
|
154
|
+
*/
|
|
155
|
+
export declare function sanitizeEmojis(text: string): string;
|
|
156
|
+
//# sourceMappingURL=ansi-colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ansi-colors.d.ts","sourceRoot":"","sources":["../../src/utils/ansi-colors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Db,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,QAAQ,GAAG,SAAS,EAAE;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACjB,CAmCA,CAAC;AAUF;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAG/D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAK/E;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;GAEG;AAEH;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,GAAE,OAAc,GAAG,MAAM,CAerF;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,GAAE,OAAc,GAAG,MAAM,CAUpF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAMvD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM3D;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB;IACzB;;OAEG;wBACiB,MAAM,WAAU,UAAU,GAAG,WAAW,GAAG,QAAQ;IAevE;;OAEG;uBACgB,MAAM;IAIzB;;OAEG;qBACc,MAAM;IAIvB;;OAEG;uBACgB,MAAM;IAIzB;;OAEG;oBACa,MAAM;CAGzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;CAW9B,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqBnD"}
|
|
@@ -1,12 +1,30 @@
|
|
|
1
|
+
import { LogLevel, StackInfo, OutputFormat } from '../types/index.js';
|
|
2
|
+
export type { OutputFormat } from '../types/index.js';
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* Creates output based on environment and format preference
|
|
3
5
|
*/
|
|
4
|
-
|
|
6
|
+
export declare function createOutput(level: LogLevel, message: string, prefix?: string, stackInfo?: StackInfo | null, format?: OutputFormat): string;
|
|
5
7
|
/**
|
|
6
8
|
* Creates plain text output for any environment
|
|
7
9
|
* No colors, no styling - maximum compatibility
|
|
8
10
|
*/
|
|
9
11
|
export declare function createPlainOutput(level: LogLevel, message: string, prefix?: string, stackInfo?: StackInfo | null): string;
|
|
12
|
+
/**
|
|
13
|
+
* Creates ANSI-colored output for terminals
|
|
14
|
+
*/
|
|
15
|
+
export declare function createANSIOutput(level: LogLevel, message: string, prefix?: string, stackInfo?: StackInfo | null): string;
|
|
16
|
+
/**
|
|
17
|
+
* Creates build-friendly output (optimized for Next.js builds, webpack, etc.)
|
|
18
|
+
*/
|
|
19
|
+
export declare function createBuildOutput(level: LogLevel, message: string, prefix?: string, stackInfo?: StackInfo | null): string;
|
|
20
|
+
/**
|
|
21
|
+
* Creates CI-friendly output (no emojis, simple formatting)
|
|
22
|
+
*/
|
|
23
|
+
export declare function createCIOutput(level: LogLevel, message: string, prefix?: string, stackInfo?: StackInfo | null): string;
|
|
24
|
+
/**
|
|
25
|
+
* Detects the optimal output format based on environment
|
|
26
|
+
*/
|
|
27
|
+
export declare function detectOptimalFormat(): OutputFormat;
|
|
10
28
|
/**
|
|
11
29
|
* Gets the appropriate log method for the level
|
|
12
30
|
* Uses different console methods for better semantics
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAa3E,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,wBAAgB,YAAY,CACxB,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,EAC5B,MAAM,GAAE,YAAqB,GAC9B,MAAM,CAcR;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,GAC7B,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC5B,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,GAC7B,MAAM,CA0BR;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,GAC7B,MAAM,CAyCR;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,GAC7B,MAAM,CAkBR;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,YAAY,CAiClD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAcnF;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,GAAG,EAAE,EACX,MAAM,CAAC,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI;;;;;;;;;;;;;EAgB/B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CA+BtE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,GAAE,MAAU,EAAE,YAAY,GAAE,MAAU,GAAG,GAAG,CAqB3F"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@
|
|
|
4
4
|
export { parseStackTrace } from './stackTrace.js';
|
|
5
5
|
export { formatTimestamp, parseRelativeTime, parseTimeInput, formatDisplayTime } from './timestamps.js';
|
|
6
6
|
export { createStyledOutput, generateLogId, escapeHtml, safeStringify, detectDevToolsTheme, getAdaptiveColor, setupThemeChangeListener, type LevelStyleConfig } from './output.js';
|
|
7
|
+
export { createPlainOutput, createOutput, createANSIOutput, createBuildOutput, createCIOutput, detectOptimalFormat, getConsoleMethod, createLogEntry, formatTablePlain, safeSerialize } from './formatting.js';
|
|
7
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,gBAAgB,EACxB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACH,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,KAAK,gBAAgB,EACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACH,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,aAAa,EAChB,MAAM,iBAAiB,CAAC"}
|
package/dist/utils/output.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* @fileoverview Styled output creation utilities for Advanced Logger
|
|
3
|
-
*/
|
|
4
|
-
import type { LogLevel, StackInfo, DevToolsTheme, AdaptiveColors } from '../types/index.js';
|
|
1
|
+
import { LogLevel, StackInfo, DevToolsTheme, AdaptiveColors } from '../types/index.js';
|
|
5
2
|
/**
|
|
6
3
|
* Style configuration for each log level
|
|
7
4
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mks2508/better-logger",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Logger avanzado para consola con estilos CSS, temas adaptativos, badges automáticos, SVG, animaciones y CLI integrado",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"workflow:release": "npm run version:auto && npm run build:all && npm run release:github"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
+
"@types/node": "^24.5.2",
|
|
86
87
|
"terser": "^5.43.1",
|
|
87
88
|
"typescript": "~5.8.3",
|
|
88
89
|
"vite": "^7.1.2",
|
package/src/Logger.ts
CHANGED
|
@@ -21,12 +21,9 @@ import type {
|
|
|
21
21
|
} from './types/index.js';
|
|
22
22
|
|
|
23
23
|
// Utility imports
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
createStyledOutput,
|
|
28
|
-
setupThemeChangeListener
|
|
29
|
-
} from './utils/index.js';
|
|
24
|
+
import { parseStackTrace } from './utils/stackTrace.js';
|
|
25
|
+
import { formatTimestamp } from './utils/timestamps.js';
|
|
26
|
+
import { createStyledOutput, setupThemeChangeListener } from './utils/output.js';
|
|
30
27
|
|
|
31
28
|
// Styling imports
|
|
32
29
|
import {
|
|
@@ -328,6 +325,35 @@ export class Logger {
|
|
|
328
325
|
}
|
|
329
326
|
}
|
|
330
327
|
|
|
328
|
+
/**
|
|
329
|
+
* Factory method para crear loggers con scope evitando dependencias circulares
|
|
330
|
+
* @private
|
|
331
|
+
* @param {string} type - Tipo de logger ('scope' | 'api' | 'component')
|
|
332
|
+
* @param {string} name - Nombre del scope
|
|
333
|
+
* @returns {Promise<any>} Logger con scope
|
|
334
|
+
*/
|
|
335
|
+
private async createScopedLogger(type: string, name: string): Promise<any> {
|
|
336
|
+
try {
|
|
337
|
+
const { ScopedLogger, APILogger, ComponentLogger } = await import('./ScopedLogger.js');
|
|
338
|
+
|
|
339
|
+
switch (type) {
|
|
340
|
+
case 'component':
|
|
341
|
+
return new ComponentLogger(this, name);
|
|
342
|
+
case 'api':
|
|
343
|
+
return new APILogger(this, name);
|
|
344
|
+
case 'scope':
|
|
345
|
+
default:
|
|
346
|
+
return new ScopedLogger(this, name);
|
|
347
|
+
}
|
|
348
|
+
} catch (error) {
|
|
349
|
+
// Fallback: crear logger básico con prefijo
|
|
350
|
+
this.error('Failed to load ScopedLogger, using basic logger with prefix:', error);
|
|
351
|
+
const basicLogger = new Logger(this.getConfig());
|
|
352
|
+
basicLogger.setGlobalPrefix(`${this.config.globalPrefix || ''}:${name}`);
|
|
353
|
+
return basicLogger;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
331
357
|
// ===== SIMPLIFIED API =====
|
|
332
358
|
|
|
333
359
|
/**
|
|
@@ -488,9 +514,8 @@ export class Logger {
|
|
|
488
514
|
* @since 0.3.0
|
|
489
515
|
*/
|
|
490
516
|
component(name: string): any {
|
|
491
|
-
//
|
|
492
|
-
|
|
493
|
-
return new ComponentLogger(this, name);
|
|
517
|
+
// Lazy dynamic import to avoid circular dependency
|
|
518
|
+
return this.createScopedLogger('component', name);
|
|
494
519
|
}
|
|
495
520
|
|
|
496
521
|
/**
|
|
@@ -511,9 +536,8 @@ export class Logger {
|
|
|
511
536
|
* @since 0.3.0
|
|
512
537
|
*/
|
|
513
538
|
api(name: string): any {
|
|
514
|
-
//
|
|
515
|
-
|
|
516
|
-
return new APILogger(this, name);
|
|
539
|
+
// Lazy dynamic import to avoid circular dependency
|
|
540
|
+
return this.createScopedLogger('api', name);
|
|
517
541
|
}
|
|
518
542
|
|
|
519
543
|
/**
|
|
@@ -534,9 +558,8 @@ export class Logger {
|
|
|
534
558
|
* @since 0.3.0
|
|
535
559
|
*/
|
|
536
560
|
scope(name: string): any {
|
|
537
|
-
//
|
|
538
|
-
|
|
539
|
-
return new ScopedLogger(this, name);
|
|
561
|
+
// Lazy dynamic import to avoid circular dependency
|
|
562
|
+
return this.createScopedLogger('scope', name);
|
|
540
563
|
}
|
|
541
564
|
|
|
542
565
|
// ===== SIMPLE CUSTOMIZATION =====
|
|
@@ -1207,67 +1230,82 @@ export class Logger {
|
|
|
1207
1230
|
}
|
|
1208
1231
|
|
|
1209
1232
|
/**
|
|
1210
|
-
*
|
|
1211
|
-
* @
|
|
1233
|
+
* Lazy singleton instance - se inicializa solo cuando se necesita
|
|
1234
|
+
* @private
|
|
1212
1235
|
*/
|
|
1213
|
-
|
|
1214
|
-
verbosity: 'info',
|
|
1215
|
-
enableColors: true,
|
|
1216
|
-
enableTimestamps: true,
|
|
1217
|
-
enableStackTrace: true,
|
|
1218
|
-
bufferSize: 1000, // Enable export functionality by default
|
|
1219
|
-
});
|
|
1236
|
+
let _defaultLogger: Logger | null = null;
|
|
1220
1237
|
|
|
1221
|
-
|
|
1222
|
-
|
|
1238
|
+
/**
|
|
1239
|
+
* Obtiene o crea la instancia singleton del logger
|
|
1240
|
+
* @returns {Logger} Instancia singleton del logger
|
|
1241
|
+
*/
|
|
1242
|
+
function getDefaultLogger(): Logger {
|
|
1243
|
+
if (!_defaultLogger) {
|
|
1244
|
+
_defaultLogger = new Logger({
|
|
1245
|
+
verbosity: 'info',
|
|
1246
|
+
enableColors: true,
|
|
1247
|
+
enableTimestamps: true,
|
|
1248
|
+
enableStackTrace: true,
|
|
1249
|
+
bufferSize: 1000, // Enable export functionality by default
|
|
1250
|
+
});
|
|
1251
|
+
|
|
1252
|
+
// Display initialization banner only once
|
|
1253
|
+
try {
|
|
1254
|
+
displayInitBanner();
|
|
1255
|
+
} catch (error) {
|
|
1256
|
+
// Silent fail if banner cannot be displayed
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
return _defaultLogger;
|
|
1260
|
+
}
|
|
1223
1261
|
|
|
1224
|
-
// Export the singleton
|
|
1225
|
-
export default
|
|
1262
|
+
// Export the lazy singleton getter as default
|
|
1263
|
+
export default getDefaultLogger();
|
|
1226
1264
|
|
|
1227
1265
|
/**
|
|
1228
1266
|
* Métodos individuales exportados para conveniencia
|
|
1229
|
-
* @description Todos los métodos están correctamente enlazados al singleton
|
|
1267
|
+
* @description Todos los métodos están correctamente enlazados al singleton lazy
|
|
1230
1268
|
* @since 0.3.0
|
|
1231
1269
|
*/
|
|
1232
|
-
export const debug = (...args: any[]) =>
|
|
1233
|
-
export const info = (...args: any[]) =>
|
|
1234
|
-
export const warn = (...args: any[]) =>
|
|
1235
|
-
export const error = (...args: any[]) =>
|
|
1236
|
-
export const success = (...args: any[]) =>
|
|
1237
|
-
export const trace = (...args: any[]) =>
|
|
1238
|
-
export const critical = (...args: any[]) =>
|
|
1239
|
-
export const table = (data: any, columns?: string[]) =>
|
|
1240
|
-
export const group = (label: string, collapsed?: boolean) =>
|
|
1241
|
-
export const groupEnd = () =>
|
|
1242
|
-
export const time = (label: string) =>
|
|
1243
|
-
export const timeEnd = (label: string) =>
|
|
1244
|
-
export const setGlobalPrefix = (prefix: string) =>
|
|
1245
|
-
export const setVerbosity = (level: Verbosity) =>
|
|
1246
|
-
export const addHandler = (handler: ILogHandler) =>
|
|
1247
|
-
export const setTheme = (theme: ThemeVariant) =>
|
|
1248
|
-
export const setBannerType = (bannerType: BannerType) =>
|
|
1249
|
-
export const showBanner = (bannerType?: BannerType) =>
|
|
1270
|
+
export const debug = (...args: any[]) => getDefaultLogger().debug(...args);
|
|
1271
|
+
export const info = (...args: any[]) => getDefaultLogger().info(...args);
|
|
1272
|
+
export const warn = (...args: any[]) => getDefaultLogger().warn(...args);
|
|
1273
|
+
export const error = (...args: any[]) => getDefaultLogger().error(...args);
|
|
1274
|
+
export const success = (...args: any[]) => getDefaultLogger().success(...args);
|
|
1275
|
+
export const trace = (...args: any[]) => getDefaultLogger().trace(...args);
|
|
1276
|
+
export const critical = (...args: any[]) => getDefaultLogger().critical(...args);
|
|
1277
|
+
export const table = (data: any, columns?: string[]) => getDefaultLogger().table(data, columns);
|
|
1278
|
+
export const group = (label: string, collapsed?: boolean) => getDefaultLogger().group(label, collapsed);
|
|
1279
|
+
export const groupEnd = () => getDefaultLogger().groupEnd();
|
|
1280
|
+
export const time = (label: string) => getDefaultLogger().time(label);
|
|
1281
|
+
export const timeEnd = (label: string) => getDefaultLogger().timeEnd(label);
|
|
1282
|
+
export const setGlobalPrefix = (prefix: string) => getDefaultLogger().setGlobalPrefix(prefix);
|
|
1283
|
+
export const setVerbosity = (level: Verbosity) => getDefaultLogger().setVerbosity(level);
|
|
1284
|
+
export const addHandler = (handler: ILogHandler) => getDefaultLogger().addHandler(handler);
|
|
1285
|
+
export const setTheme = (theme: ThemeVariant) => getDefaultLogger().setTheme(theme);
|
|
1286
|
+
export const setBannerType = (bannerType: BannerType) => getDefaultLogger().setBannerType(bannerType);
|
|
1287
|
+
export const showBanner = (bannerType?: BannerType) => getDefaultLogger().showBanner(bannerType);
|
|
1250
1288
|
export const logWithSVG = (message: string, svgContent?: string, options?: StyleOptions) =>
|
|
1251
|
-
|
|
1289
|
+
getDefaultLogger().logWithSVG(message, svgContent, options);
|
|
1252
1290
|
export const logAnimated = (message: string, duration?: number) =>
|
|
1253
|
-
|
|
1254
|
-
export const cli = (command: string) =>
|
|
1255
|
-
export const cleanup = () =>
|
|
1291
|
+
getDefaultLogger().logAnimated(message, duration);
|
|
1292
|
+
export const cli = (command: string) => getDefaultLogger().cli(command);
|
|
1293
|
+
export const cleanup = () => getDefaultLogger().cleanup();
|
|
1256
1294
|
|
|
1257
1295
|
// Simplified API exports
|
|
1258
|
-
export const preset = (name: string) =>
|
|
1259
|
-
export const presets = () =>
|
|
1260
|
-
export const hideTimestamp = () =>
|
|
1261
|
-
export const showTimestamp = () =>
|
|
1262
|
-
export const hideLocation = () =>
|
|
1263
|
-
export const showLocation = () =>
|
|
1264
|
-
export const hideBadges = () =>
|
|
1265
|
-
export const showBadges = () =>
|
|
1266
|
-
export const component = (name: string) =>
|
|
1267
|
-
export const api = (name: string) =>
|
|
1268
|
-
export const scope = (name: string) =>
|
|
1269
|
-
export const customize = (overrides: any) =>
|
|
1270
|
-
export const styles = () =>
|
|
1296
|
+
export const preset = (name: string) => getDefaultLogger().preset(name);
|
|
1297
|
+
export const presets = () => getDefaultLogger().presets();
|
|
1298
|
+
export const hideTimestamp = () => getDefaultLogger().hideTimestamp();
|
|
1299
|
+
export const showTimestamp = () => getDefaultLogger().showTimestamp();
|
|
1300
|
+
export const hideLocation = () => getDefaultLogger().hideLocation();
|
|
1301
|
+
export const showLocation = () => getDefaultLogger().showLocation();
|
|
1302
|
+
export const hideBadges = () => getDefaultLogger().hideBadges();
|
|
1303
|
+
export const showBadges = () => getDefaultLogger().showBadges();
|
|
1304
|
+
export const component = (name: string) => getDefaultLogger().component(name);
|
|
1305
|
+
export const api = (name: string) => getDefaultLogger().api(name);
|
|
1306
|
+
export const scope = (name: string) => getDefaultLogger().scope(name);
|
|
1307
|
+
export const customize = (overrides: any) => getDefaultLogger().customize(overrides);
|
|
1308
|
+
export const styles = () => getDefaultLogger().styles();
|
|
1271
1309
|
|
|
1272
1310
|
// Re-export handlers and utilities for backward compatibility
|
|
1273
1311
|
export { FileLogHandler, RemoteLogHandler, AnalyticsLogHandler, ExportLogHandler } from './handlers/index.js';
|
package/src/constants.ts
CHANGED
|
@@ -17,6 +17,7 @@ export const DEFAULT_CONFIG = {
|
|
|
17
17
|
bannerType: 'simple' as const,
|
|
18
18
|
bufferSize: 1000,
|
|
19
19
|
autoDetectTheme: true,
|
|
20
|
+
outputFormat: 'auto' as const,
|
|
20
21
|
} as const;
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -168,4 +169,133 @@ export const ADAPTIVE_COLORS = {
|
|
|
168
169
|
light: '#718096',
|
|
169
170
|
dark: '#a0aec0',
|
|
170
171
|
},
|
|
171
|
-
} as const satisfies Record<string, AdaptiveColors>;
|
|
172
|
+
} as const satisfies Record<string, AdaptiveColors>;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Presets específicos para diferentes entornos de build
|
|
176
|
+
*/
|
|
177
|
+
export const BUILD_PRESETS = {
|
|
178
|
+
/**
|
|
179
|
+
* Configuración optimizada para Next.js builds
|
|
180
|
+
*/
|
|
181
|
+
nextjs: {
|
|
182
|
+
verbosity: 'info' as const,
|
|
183
|
+
enableColors: true,
|
|
184
|
+
enableTimestamps: false,
|
|
185
|
+
enableStackTrace: false,
|
|
186
|
+
autoDetectTheme: false,
|
|
187
|
+
outputFormat: 'build' as const,
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Configuración para Webpack builds
|
|
192
|
+
*/
|
|
193
|
+
webpack: {
|
|
194
|
+
verbosity: 'info' as const,
|
|
195
|
+
enableColors: true,
|
|
196
|
+
enableTimestamps: true,
|
|
197
|
+
enableStackTrace: false,
|
|
198
|
+
autoDetectTheme: false,
|
|
199
|
+
outputFormat: 'build' as const,
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Configuración para CI/CD environments
|
|
204
|
+
*/
|
|
205
|
+
ci: {
|
|
206
|
+
verbosity: 'info' as const,
|
|
207
|
+
enableColors: false,
|
|
208
|
+
enableTimestamps: true,
|
|
209
|
+
enableStackTrace: true,
|
|
210
|
+
autoDetectTheme: false,
|
|
211
|
+
outputFormat: 'ci' as const,
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Configuración para desarrollo terminal
|
|
216
|
+
*/
|
|
217
|
+
terminal: {
|
|
218
|
+
verbosity: 'debug' as const,
|
|
219
|
+
enableColors: true,
|
|
220
|
+
enableTimestamps: true,
|
|
221
|
+
enableStackTrace: true,
|
|
222
|
+
autoDetectTheme: false,
|
|
223
|
+
outputFormat: 'ansi' as const,
|
|
224
|
+
}
|
|
225
|
+
} as const;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Mapeo de variables de entorno a presets
|
|
229
|
+
*/
|
|
230
|
+
export const ENVIRONMENT_DETECTION = {
|
|
231
|
+
// Next.js detection
|
|
232
|
+
isNextJS: typeof process !== 'undefined' && (
|
|
233
|
+
process.env.NEXT_RUNTIME ||
|
|
234
|
+
process.env.NEXT_PUBLIC_VERCEL_ENV ||
|
|
235
|
+
(process.argv && process.argv.some(arg => arg.includes('next')))
|
|
236
|
+
),
|
|
237
|
+
|
|
238
|
+
// Webpack detection
|
|
239
|
+
isWebpack: typeof process !== 'undefined' && (
|
|
240
|
+
process.env.WEBPACK_ENV ||
|
|
241
|
+
process.env.WEBPACK_BUILD ||
|
|
242
|
+
(process.argv && process.argv.some(arg => arg.includes('webpack')))
|
|
243
|
+
),
|
|
244
|
+
|
|
245
|
+
// CI/CD detection
|
|
246
|
+
isCI: typeof process !== 'undefined' && (
|
|
247
|
+
process.env.CI ||
|
|
248
|
+
process.env.GITHUB_ACTIONS ||
|
|
249
|
+
process.env.JENKINS_URL ||
|
|
250
|
+
process.env.GITLAB_CI ||
|
|
251
|
+
process.env.TRAVIS ||
|
|
252
|
+
process.env.CIRCLECI
|
|
253
|
+
),
|
|
254
|
+
|
|
255
|
+
// Build detection
|
|
256
|
+
isBuild: typeof process !== 'undefined' && (
|
|
257
|
+
process.env.NODE_ENV === 'production' ||
|
|
258
|
+
process.env.BUILD_MODE === 'production' ||
|
|
259
|
+
(process.argv && process.argv.some(arg => arg.includes('build')))
|
|
260
|
+
),
|
|
261
|
+
|
|
262
|
+
// Terminal with ANSI support
|
|
263
|
+
isTerminal: typeof process !== 'undefined' && (
|
|
264
|
+
process.stdout?.isTTY === true &&
|
|
265
|
+
process.env.TERM !== 'dumb'
|
|
266
|
+
)
|
|
267
|
+
} as const;
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Auto-detects the best preset based on current environment
|
|
271
|
+
*/
|
|
272
|
+
export function detectEnvironmentPreset(): keyof typeof BUILD_PRESETS {
|
|
273
|
+
if (ENVIRONMENT_DETECTION.isCI) {
|
|
274
|
+
return 'ci';
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (ENVIRONMENT_DETECTION.isNextJS) {
|
|
278
|
+
return 'nextjs';
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
if (ENVIRONMENT_DETECTION.isWebpack) {
|
|
282
|
+
return 'webpack';
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (ENVIRONMENT_DETECTION.isTerminal) {
|
|
286
|
+
return 'terminal';
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return 'terminal'; // Default fallback
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Gets the optimal configuration for current environment
|
|
294
|
+
*/
|
|
295
|
+
export function getOptimalConfig() {
|
|
296
|
+
const preset = detectEnvironmentPreset();
|
|
297
|
+
return {
|
|
298
|
+
...DEFAULT_CONFIG,
|
|
299
|
+
...BUILD_PRESETS[preset]
|
|
300
|
+
};
|
|
301
|
+
}
|