@mks2508/better-logger 1.0.0 → 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.map +1 -0
- package/dist/ScopedLogger.d.ts.map +1 -0
- package/dist/chunks/{Logger-D8pK7XXt.js → Logger-C9zTFYBh.js} +2 -2
- package/dist/chunks/Logger-C9zTFYBh.js.map +1 -0
- package/dist/chunks/{Logger-CTAaDeZi.js → Logger-Th9SfADL.js} +3 -3
- package/dist/chunks/Logger-Th9SfADL.js.map +1 -0
- package/dist/chunks/{ScopedLogger-D-7q8uVP.js → ScopedLogger-HgV_J-ug.js} +2 -2
- package/dist/chunks/{ScopedLogger-D-7q8uVP.js.map → ScopedLogger-HgV_J-ug.js.map} +1 -1
- package/dist/chunks/{ScopedLogger-hS0qSkZD.js → ScopedLogger-uAAeJkfA.js} +2 -2
- package/dist/chunks/{ScopedLogger-hS0qSkZD.js.map → ScopedLogger-uAAeJkfA.js.map} +1 -1
- 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.map +1 -0
- package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
- package/dist/cli/commands/ExportCommand.d.ts.map +1 -0
- package/dist/cli/commands/HistoryCommand.d.ts.map +1 -0
- package/dist/cli/commands/StatusCommand.d.ts.map +1 -0
- package/dist/cli/commands/ThemeCommand.d.ts.map +1 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/{types/constants.d.ts → constants.d.ts} +108 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +127 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +6 -5
- package/dist/core.js.map +1 -1
- package/dist/example.d.ts.map +1 -0
- package/dist/exports-module.d.ts.map +1 -0
- package/dist/exports.cjs +1 -1
- package/dist/exports.js +2 -2
- package/dist/handlers/AnalyticsLogHandler.d.ts.map +1 -0
- package/dist/handlers/ExportLogHandler.d.ts.map +1 -0
- package/dist/handlers/FileLogHandler.d.ts.map +1 -0
- package/dist/handlers/RemoteLogHandler.d.ts.map +1 -0
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +124 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -0
- package/dist/styling/LogStyleBuilder.d.ts.map +1 -0
- package/dist/styling/SemanticStyles.d.ts.map +1 -0
- package/dist/styling/SmartPresets.d.ts.map +1 -0
- package/dist/styling/StyleBuilder.d.ts.map +1 -0
- package/dist/styling/banners.d.ts.map +1 -0
- package/dist/styling/index.d.ts.map +1 -0
- package/dist/styling/themes.d.ts.map +1 -0
- package/dist/styling-module.d.ts.map +1 -0
- package/dist/styling.cjs +1 -1
- package/dist/styling.js +3 -3
- package/dist/types/core.d.ts +229 -122
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/handlers.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -119
- 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/environment.d.ts.map +1 -0
- package/dist/{types/utils → utils}/formatting.d.ts +22 -1
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/{types/utils → utils}/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/opentui-detection.d.ts.map +1 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/stackTrace.d.ts.map +1 -0
- package/dist/utils/timestamps.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/Logger.ts +3 -6
- package/src/constants.ts +131 -1
- package/src/core.ts +11 -7
- package/src/handlers/ExportLogHandler.ts +2 -1
- package/src/index.ts +30 -2
- 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/chunks/Logger-CTAaDeZi.js.map +0 -1
- package/dist/chunks/Logger-D8pK7XXt.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/types/Logger.d.ts.map +0 -1
- package/dist/types/ScopedLogger.d.ts.map +0 -1
- package/dist/types/cli/CommandProcessor.d.ts.map +0 -1
- package/dist/types/cli/commands/ConfigCommand.d.ts.map +0 -1
- package/dist/types/cli/commands/ExportCommand.d.ts.map +0 -1
- package/dist/types/cli/commands/HistoryCommand.d.ts.map +0 -1
- package/dist/types/cli/commands/StatusCommand.d.ts.map +0 -1
- package/dist/types/cli/commands/ThemeCommand.d.ts.map +0 -1
- package/dist/types/cli/help.d.ts.map +0 -1
- package/dist/types/cli/index.d.ts.map +0 -1
- package/dist/types/constants.d.ts.map +0 -1
- package/dist/types/example.d.ts.map +0 -1
- package/dist/types/exports-module.d.ts.map +0 -1
- package/dist/types/handlers/AnalyticsLogHandler.d.ts.map +0 -1
- package/dist/types/handlers/ExportLogHandler.d.ts.map +0 -1
- package/dist/types/handlers/FileLogHandler.d.ts.map +0 -1
- package/dist/types/handlers/RemoteLogHandler.d.ts.map +0 -1
- package/dist/types/handlers/index.d.ts.map +0 -1
- package/dist/types/main.d.ts.map +0 -1
- package/dist/types/styling/LogStyleBuilder.d.ts.map +0 -1
- package/dist/types/styling/SemanticStyles.d.ts.map +0 -1
- package/dist/types/styling/SmartPresets.d.ts.map +0 -1
- package/dist/types/styling/StyleBuilder.d.ts.map +0 -1
- package/dist/types/styling/banners.d.ts.map +0 -1
- package/dist/types/styling/index.d.ts.map +0 -1
- package/dist/types/styling/themes.d.ts.map +0 -1
- 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.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.map +0 -1
- package/dist/types/utils/formatting.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/types/utils/opentui-detection.d.ts.map +0 -1
- package/dist/types/utils/output.d.ts.map +0 -1
- package/dist/types/utils/stackTrace.d.ts.map +0 -1
- package/dist/types/utils/timestamps.d.ts.map +0 -1
- /package/dist/{types/Logger.d.ts → Logger.d.ts} +0 -0
- /package/dist/{types/ScopedLogger.d.ts → ScopedLogger.d.ts} +0 -0
- /package/dist/{types/cli → cli}/CommandProcessor.d.ts +0 -0
- /package/dist/{types/cli → cli}/commands/ConfigCommand.d.ts +0 -0
- /package/dist/{types/cli → cli}/commands/ExportCommand.d.ts +0 -0
- /package/dist/{types/cli → cli}/commands/HistoryCommand.d.ts +0 -0
- /package/dist/{types/cli → cli}/commands/StatusCommand.d.ts +0 -0
- /package/dist/{types/cli → cli}/commands/ThemeCommand.d.ts +0 -0
- /package/dist/{types/cli → cli}/help.d.ts +0 -0
- /package/dist/{types/cli → cli}/index.d.ts +0 -0
- /package/dist/{types/example.d.ts → example.d.ts} +0 -0
- /package/dist/{types/exports-module.d.ts → exports-module.d.ts} +0 -0
- /package/dist/{types/handlers → handlers}/AnalyticsLogHandler.d.ts +0 -0
- /package/dist/{types/handlers → handlers}/ExportLogHandler.d.ts +0 -0
- /package/dist/{types/handlers → handlers}/FileLogHandler.d.ts +0 -0
- /package/dist/{types/handlers → handlers}/RemoteLogHandler.d.ts +0 -0
- /package/dist/{types/handlers → handlers}/index.d.ts +0 -0
- /package/dist/{types/main.d.ts → main.d.ts} +0 -0
- /package/dist/{types/styling → styling}/LogStyleBuilder.d.ts +0 -0
- /package/dist/{types/styling → styling}/SemanticStyles.d.ts +0 -0
- /package/dist/{types/styling → styling}/SmartPresets.d.ts +0 -0
- /package/dist/{types/styling → styling}/StyleBuilder.d.ts +0 -0
- /package/dist/{types/styling → styling}/banners.d.ts +0 -0
- /package/dist/{types/styling → styling}/index.d.ts +0 -0
- /package/dist/{types/styling → styling}/themes.d.ts +0 -0
- /package/dist/{types/styling-module.d.ts → styling-module.d.ts} +0 -0
- /package/dist/types/{types/handlers.d.ts → handlers.d.ts} +0 -0
- /package/dist/{types/utils → utils}/environment.d.ts +0 -0
- /package/dist/{types/utils → utils}/opentui-detection.d.ts +0 -0
- /package/dist/{types/utils → utils}/output.d.ts +0 -0
- /package/dist/{types/utils → utils}/stackTrace.d.ts +0 -0
- /package/dist/{types/utils → utils}/timestamps.d.ts +0 -0
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA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G,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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../src/utils/environment.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,gBAEwB,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,SAAS,SACmC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,WAAW,SACqD,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,MAAM,SACuB,CAAC;AAE3C;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,GAAG,SAAS,CAM7F;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAcxC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAQ5C;AAED;;GAEG;AACH,wBAAgB,kBAAkB;;;;;;;EAWjC"}
|
|
@@ -1,9 +1,30 @@
|
|
|
1
|
-
import { LogLevel, StackInfo } from '../types/index.js';
|
|
1
|
+
import { LogLevel, StackInfo, OutputFormat } from '../types/index.js';
|
|
2
|
+
export type { OutputFormat } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates output based on environment and format preference
|
|
5
|
+
*/
|
|
6
|
+
export declare function createOutput(level: LogLevel, message: string, prefix?: string, stackInfo?: StackInfo | null, format?: OutputFormat): string;
|
|
2
7
|
/**
|
|
3
8
|
* Creates plain text output for any environment
|
|
4
9
|
* No colors, no styling - maximum compatibility
|
|
5
10
|
*/
|
|
6
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;
|
|
7
28
|
/**
|
|
8
29
|
* Gets the appropriate log method for the level
|
|
9
30
|
* Uses different console methods for better semantics
|
|
@@ -0,0 +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,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,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;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,GAAE,MAAU,EAAE,YAAY,GAAE,MAAU,GAAG,GAAG,CAqB3F"}
|
|
@@ -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
|
|
@@ -0,0 +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;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opentui-detection.d.ts","sourceRoot":"","sources":["../../src/utils/opentui-detection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,w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EAAE,aAAa,GAAG,MAAM,CAGtF;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAyBtG;AAGD;;GAEG;AACH,wBAAgB,kBAAkB,CAC9B,KAAK,EAAE,QAAQ,EACf,WAAW,EAAE,MAAM,CAAC,QAAQ,GAAG,SAAS,EAAE,gBAAgB,CAAC,EAC3D,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,SAAS,GAAG,IAAI,EAC3B,eAAe,GAAE,OAAc,GAChC,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAgEvB;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/C;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,SAAI,GAAG,MAAM,CAY7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stackTrace.d.ts","sourceRoot":"","sources":["../../src/utils/stackTrace.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,wBAAgB,eAAe,IAAI,SAAS,GAAG,IAAI,CAqFlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timestamps.d.ts","sourceRoot":"","sources":["../../src/utils/timestamps.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAQxC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAUzD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CA2BlE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,GAAE,OAAO,GAAG,MAAM,GAAG,WAAqB,GAAG,MAAM,CAUtG"}
|
package/package.json
CHANGED
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 {
|
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
|
+
}
|
package/src/core.ts
CHANGED
|
@@ -25,10 +25,13 @@ import {
|
|
|
25
25
|
// Universal formatting and environment detection
|
|
26
26
|
import {
|
|
27
27
|
createPlainOutput,
|
|
28
|
+
createOutput,
|
|
28
29
|
getConsoleMethod,
|
|
29
30
|
createLogEntry,
|
|
30
31
|
formatTablePlain,
|
|
31
|
-
safeSerialize
|
|
32
|
+
safeSerialize,
|
|
33
|
+
detectOptimalFormat,
|
|
34
|
+
type OutputFormat
|
|
32
35
|
} from './utils/formatting.js';
|
|
33
36
|
|
|
34
37
|
import {
|
|
@@ -75,7 +78,8 @@ export class CoreLogger {
|
|
|
75
78
|
enableColors: config.enableColors ?? (isBrowser ? true : false),
|
|
76
79
|
enableTimestamps: config.enableTimestamps ?? true,
|
|
77
80
|
enableStackTrace: config.enableStackTrace ?? false,
|
|
78
|
-
autoDetectTheme: config.autoDetectTheme ?? true
|
|
81
|
+
autoDetectTheme: config.autoDetectTheme ?? true,
|
|
82
|
+
outputFormat: config.outputFormat ?? 'auto'
|
|
79
83
|
};
|
|
80
84
|
}
|
|
81
85
|
|
|
@@ -148,7 +152,7 @@ export class CoreLogger {
|
|
|
148
152
|
const message = String(args[0] || '');
|
|
149
153
|
const stackInfo = this.config.enableStackTrace ? parseStackTrace() : null;
|
|
150
154
|
const consoleMethod = getConsoleMethod(level);
|
|
151
|
-
|
|
155
|
+
|
|
152
156
|
// Choose formatting based on environment and configuration
|
|
153
157
|
if (isBrowser && this.config.enableColors && supportsCSSColors()) {
|
|
154
158
|
// Browser with CSS styling
|
|
@@ -163,14 +167,14 @@ export class CoreLogger {
|
|
|
163
167
|
);
|
|
164
168
|
console[consoleMethod](format, ...styles, ...args.slice(1));
|
|
165
169
|
} catch (error) {
|
|
166
|
-
// Fallback to
|
|
167
|
-
const output =
|
|
170
|
+
// Fallback to universal formatting if CSS fails
|
|
171
|
+
const output = createOutput(level, message, prefix, stackInfo, this.config.outputFormat);
|
|
168
172
|
console[consoleMethod](output, ...args.slice(1));
|
|
169
173
|
}
|
|
170
174
|
} else {
|
|
171
|
-
// Node.js or browser without colors - use
|
|
175
|
+
// Node.js or browser without colors - use universal formatting
|
|
172
176
|
const groupIndent = ' '.repeat(this.groupDepth);
|
|
173
|
-
const output = groupIndent +
|
|
177
|
+
const output = groupIndent + createOutput(level, message, prefix, stackInfo, this.config.outputFormat);
|
|
174
178
|
console[consoleMethod](output, ...args.slice(1));
|
|
175
179
|
}
|
|
176
180
|
|
|
@@ -13,7 +13,8 @@ import type {
|
|
|
13
13
|
BufferStats,
|
|
14
14
|
ExportFormat
|
|
15
15
|
} from '../types/index.js';
|
|
16
|
-
import { parseTimeInput, formatDisplayTime
|
|
16
|
+
import { parseTimeInput, formatDisplayTime } from '../utils/timestamps.js';
|
|
17
|
+
import { safeStringify, escapeHtml, generateLogId } from '../utils/output.js';
|
|
17
18
|
import { BUFFER_LIMITS } from '../constants.js';
|
|
18
19
|
|
|
19
20
|
/**
|
package/src/index.ts
CHANGED
|
@@ -121,7 +121,8 @@ export type {
|
|
|
121
121
|
LoggerConfig,
|
|
122
122
|
LogMetadata,
|
|
123
123
|
StackInfo,
|
|
124
|
-
TimerEntry
|
|
124
|
+
TimerEntry,
|
|
125
|
+
OutputFormat
|
|
125
126
|
} from './types/index.js';
|
|
126
127
|
|
|
127
128
|
// Styling utilities
|
|
@@ -146,9 +147,36 @@ export { DEFAULT_CONFIG } from './constants.js';
|
|
|
146
147
|
// Utility exports
|
|
147
148
|
export {
|
|
148
149
|
parseStackTrace,
|
|
149
|
-
formatTimestamp
|
|
150
|
+
formatTimestamp,
|
|
151
|
+
detectOptimalFormat,
|
|
152
|
+
createOutput,
|
|
153
|
+
createANSIOutput,
|
|
154
|
+
createBuildOutput,
|
|
155
|
+
createCIOutput
|
|
150
156
|
} from './utils/index.js';
|
|
151
157
|
|
|
158
|
+
// ANSI color utilities
|
|
159
|
+
export {
|
|
160
|
+
ansiStyle,
|
|
161
|
+
ansiColor,
|
|
162
|
+
ansiBackground,
|
|
163
|
+
ansiBold,
|
|
164
|
+
ansiDim,
|
|
165
|
+
ansiUnderline,
|
|
166
|
+
formatLogLevelANSI,
|
|
167
|
+
formatSuccessANSI,
|
|
168
|
+
BUILD_FORMATTERS,
|
|
169
|
+
sanitizeEmojis
|
|
170
|
+
} from './utils/ansi-colors.js';
|
|
171
|
+
|
|
172
|
+
// Environment detection and presets
|
|
173
|
+
export {
|
|
174
|
+
BUILD_PRESETS,
|
|
175
|
+
ENVIRONMENT_DETECTION,
|
|
176
|
+
detectEnvironmentPreset,
|
|
177
|
+
getOptimalConfig
|
|
178
|
+
} from './constants.js';
|
|
179
|
+
|
|
152
180
|
/**
|
|
153
181
|
* Utilidades de estilo para crear estilos personalizados de consola
|
|
154
182
|
*
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { StyleBuilder } from './StyleBuilder.js';
|
|
6
6
|
import type { AdaptiveColors } from '../types/index.js';
|
|
7
7
|
import { ADAPTIVE_COLORS } from '../constants.js';
|
|
8
|
-
import { getAdaptiveColor } from '../utils/
|
|
8
|
+
import { getAdaptiveColor } from '../utils/output.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Base semantic styler with common style methods
|
package/src/types/core.ts
CHANGED
|
@@ -77,7 +77,7 @@ export type BannerType = 'simple' | 'ascii' | 'unicode' | 'svg' | 'animated';
|
|
|
77
77
|
/**
|
|
78
78
|
* Formatos de exportación para datos de log
|
|
79
79
|
* @typedef {'json' | 'csv' | 'markdown' | 'plain' | 'html'} ExportFormat
|
|
80
|
-
*
|
|
80
|
+
*
|
|
81
81
|
* @description
|
|
82
82
|
* - json: Formato JSON estructurado
|
|
83
83
|
* - csv: Valores separados por comas para Excel/Sheets
|
|
@@ -87,6 +87,19 @@ export type BannerType = 'simple' | 'ascii' | 'unicode' | 'svg' | 'animated';
|
|
|
87
87
|
*/
|
|
88
88
|
export type ExportFormat = 'json' | 'csv' | 'markdown' | 'plain' | 'html';
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Formatos de salida para diferentes entornos
|
|
92
|
+
* @typedef {'auto' | 'plain' | 'ansi' | 'build' | 'ci'} OutputFormat
|
|
93
|
+
*
|
|
94
|
+
* @description
|
|
95
|
+
* - auto: Detección automática basada en entorno (recomendado)
|
|
96
|
+
* - plain: Texto plano sin colores (máxima compatibilidad)
|
|
97
|
+
* - ansi: Colores ANSI para terminales modernos
|
|
98
|
+
* - build: Formato optimizado para builds (Next.js, webpack, etc.)
|
|
99
|
+
* - ci: Formato optimizado para CI/CD (sin emojis, texto simple)
|
|
100
|
+
*/
|
|
101
|
+
export type OutputFormat = 'auto' | 'plain' | 'ansi' | 'build' | 'ci';
|
|
102
|
+
|
|
90
103
|
/**
|
|
91
104
|
* Interfaz de configuración para instancias del logger
|
|
92
105
|
*
|
|
@@ -116,6 +129,7 @@ export interface LoggerConfig {
|
|
|
116
129
|
bannerType?: BannerType;
|
|
117
130
|
bufferSize?: number;
|
|
118
131
|
autoDetectTheme?: boolean;
|
|
132
|
+
outputFormat?: OutputFormat;
|
|
119
133
|
}
|
|
120
134
|
|
|
121
135
|
/**
|