@mks2508/better-logger 5.0.1 → 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.
Files changed (310) hide show
  1. package/dist/Logger.d.ts +976 -0
  2. package/dist/Logger.d.ts.map +1 -0
  3. package/dist/ScopedLogger.d.ts +74 -0
  4. package/dist/ScopedLogger.d.ts.map +1 -0
  5. package/dist/chunks/Logger-CKqzXDh3.js +2 -0
  6. package/dist/chunks/Logger-CKqzXDh3.js.map +1 -0
  7. package/dist/chunks/Logger-D_vuKP4l.js +4511 -0
  8. package/dist/chunks/Logger-D_vuKP4l.js.map +1 -0
  9. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js +33 -0
  10. package/dist/chunks/RemoteLogHandler-CjWpWZGl.js.map +1 -0
  11. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js +2 -0
  12. package/dist/chunks/RemoteLogHandler-ymkQ97xl.js.map +1 -0
  13. package/dist/chunks/cli-module-B-njrTWb.js +2 -0
  14. package/dist/chunks/cli-module-B-njrTWb.js.map +1 -0
  15. package/dist/chunks/cli-module-Cx7qotPY.js +390 -0
  16. package/dist/chunks/cli-module-Cx7qotPY.js.map +1 -0
  17. package/dist/chunks/color-converter-CCSQRztd.js +2 -0
  18. package/dist/chunks/color-converter-CCSQRztd.js.map +1 -0
  19. package/dist/chunks/color-converter-_Xdmsy7E.js +462 -0
  20. package/dist/chunks/color-converter-_Xdmsy7E.js.map +1 -0
  21. package/dist/chunks/environment-C1xxvc8l.js +1127 -0
  22. package/dist/chunks/environment-C1xxvc8l.js.map +1 -0
  23. package/dist/chunks/environment-Cprkw3g9.js +4 -0
  24. package/dist/chunks/environment-Cprkw3g9.js.map +1 -0
  25. package/dist/chunks/formatting-DMJxYq9o.js +380 -0
  26. package/dist/chunks/formatting-DMJxYq9o.js.map +1 -0
  27. package/dist/chunks/formatting-DpKxCsXq.js +2 -0
  28. package/dist/chunks/formatting-DpKxCsXq.js.map +1 -0
  29. package/dist/cli/CommandProcessor.d.ts +100 -0
  30. package/dist/cli/CommandProcessor.d.ts.map +1 -0
  31. package/dist/cli/commands/ConfigCommand.d.ts +14 -0
  32. package/dist/cli/commands/ConfigCommand.d.ts.map +1 -0
  33. package/dist/cli/commands/ExportCommand.d.ts +48 -0
  34. package/dist/cli/commands/ExportCommand.d.ts.map +1 -0
  35. package/dist/cli/commands/HistoryCommand.d.ts +47 -0
  36. package/dist/cli/commands/HistoryCommand.d.ts.map +1 -0
  37. package/dist/cli/commands/StatusCommand.d.ts +30 -0
  38. package/dist/cli/commands/StatusCommand.d.ts.map +1 -0
  39. package/dist/cli/commands/ThemeCommand.d.ts +30 -0
  40. package/dist/cli/commands/ThemeCommand.d.ts.map +1 -0
  41. package/dist/cli/help.d.ts +12 -0
  42. package/dist/cli/help.d.ts.map +1 -0
  43. package/dist/cli/index.d.ts +15 -0
  44. package/dist/cli/index.d.ts.map +1 -0
  45. package/{src/cli-module.ts → dist/cli-module.d.ts} +2 -8
  46. package/dist/cli-module.d.ts.map +1 -0
  47. package/dist/cli-primitives/box.d.ts +11 -0
  48. package/dist/cli-primitives/box.d.ts.map +1 -0
  49. package/dist/cli-primitives/cli-table.d.ts +11 -0
  50. package/dist/cli-primitives/cli-table.d.ts.map +1 -0
  51. package/dist/cli-primitives/divider.d.ts +11 -0
  52. package/dist/cli-primitives/divider.d.ts.map +1 -0
  53. package/dist/cli-primitives/header.d.ts +12 -0
  54. package/dist/cli-primitives/header.d.ts.map +1 -0
  55. package/{src/cli-primitives/index.ts → dist/cli-primitives/index.d.ts} +1 -1
  56. package/dist/cli-primitives/index.d.ts.map +1 -0
  57. package/dist/cli-primitives/server-fallback.d.ts +25 -0
  58. package/dist/cli-primitives/server-fallback.d.ts.map +1 -0
  59. package/dist/cli-primitives/spinner.d.ts +47 -0
  60. package/dist/cli-primitives/spinner.d.ts.map +1 -0
  61. package/dist/cli-primitives/step.d.ts +11 -0
  62. package/dist/cli-primitives/step.d.ts.map +1 -0
  63. package/dist/cli.cjs +2 -0
  64. package/dist/cli.cjs.map +1 -0
  65. package/dist/cli.js +12 -0
  66. package/dist/cli.js.map +1 -0
  67. package/dist/constants.d.ts +235 -0
  68. package/dist/constants.d.ts.map +1 -0
  69. package/dist/core.cjs +2 -0
  70. package/dist/core.cjs.map +1 -0
  71. package/dist/core.d.ts +127 -0
  72. package/dist/core.d.ts.map +1 -0
  73. package/dist/core.js +291 -0
  74. package/dist/core.js.map +1 -0
  75. package/dist/example.d.ts +18 -0
  76. package/dist/example.d.ts.map +1 -0
  77. package/dist/exports-module.d.ts +196 -0
  78. package/dist/exports-module.d.ts.map +1 -0
  79. package/dist/exports.cjs +2 -0
  80. package/dist/exports.cjs.map +1 -0
  81. package/dist/exports.js +238 -0
  82. package/dist/exports.js.map +1 -0
  83. package/dist/handlers/AnalyticsLogHandler.d.ts +8 -0
  84. package/dist/handlers/AnalyticsLogHandler.d.ts.map +1 -0
  85. package/dist/handlers/ExportLogHandler.d.ts +100 -0
  86. package/dist/handlers/ExportLogHandler.d.ts.map +1 -0
  87. package/dist/handlers/FileLogHandler.d.ts +33 -0
  88. package/dist/handlers/FileLogHandler.d.ts.map +1 -0
  89. package/dist/handlers/RemoteLogHandler.d.ts +11 -0
  90. package/dist/handlers/RemoteLogHandler.d.ts.map +1 -0
  91. package/{src/handlers/index.ts → dist/handlers/index.d.ts} +2 -2
  92. package/dist/handlers/index.d.ts.map +1 -0
  93. package/dist/hooks/HookManager.d.ts +21 -0
  94. package/dist/hooks/HookManager.d.ts.map +1 -0
  95. package/{src/hooks/index.ts → dist/hooks/index.d.ts} +1 -0
  96. package/dist/hooks/index.d.ts.map +1 -0
  97. package/dist/index.cjs +2 -0
  98. package/dist/index.cjs.map +1 -0
  99. package/dist/index.d.ts +161 -0
  100. package/dist/index.d.ts.map +1 -0
  101. package/dist/index.js +627 -0
  102. package/dist/index.js.map +1 -0
  103. package/dist/main.d.ts +2 -0
  104. package/dist/main.d.ts.map +1 -0
  105. package/dist/serializers/SerializerRegistry.d.ts +16 -0
  106. package/dist/serializers/SerializerRegistry.d.ts.map +1 -0
  107. package/{src/serializers/index.ts → dist/serializers/index.d.ts} +1 -0
  108. package/dist/serializers/index.d.ts.map +1 -0
  109. package/dist/styling/LogStyleBuilder.d.ts +146 -0
  110. package/dist/styling/LogStyleBuilder.d.ts.map +1 -0
  111. package/dist/styling/SemanticStyles.d.ts +178 -0
  112. package/dist/styling/SemanticStyles.d.ts.map +1 -0
  113. package/dist/styling/SmartPresets.d.ts +22 -0
  114. package/dist/styling/SmartPresets.d.ts.map +1 -0
  115. package/dist/styling/StyleBuilder.d.ts +140 -0
  116. package/dist/styling/StyleBuilder.d.ts.map +1 -0
  117. package/dist/styling/StyleCache.d.ts +42 -0
  118. package/dist/styling/StyleCache.d.ts.map +1 -0
  119. package/dist/styling/banners.d.ts +42 -0
  120. package/dist/styling/banners.d.ts.map +1 -0
  121. package/dist/styling/index.d.ts +10 -0
  122. package/dist/styling/index.d.ts.map +1 -0
  123. package/dist/styling/themes.d.ts +7 -0
  124. package/dist/styling/themes.d.ts.map +1 -0
  125. package/dist/styling-module.d.ts +178 -0
  126. package/dist/styling-module.d.ts.map +1 -0
  127. package/dist/styling.cjs +2 -0
  128. package/dist/styling.cjs.map +1 -0
  129. package/dist/styling.js +146 -0
  130. package/dist/styling.js.map +1 -0
  131. package/dist/terminal/color-converter.d.ts +73 -0
  132. package/dist/terminal/color-converter.d.ts.map +1 -0
  133. package/dist/terminal/formatter.d.ts +20 -0
  134. package/dist/terminal/formatter.d.ts.map +1 -0
  135. package/dist/terminal/terminal-renderer.d.ts +77 -0
  136. package/dist/terminal/terminal-renderer.d.ts.map +1 -0
  137. package/dist/transports/ConsoleTransport.d.ts +9 -0
  138. package/dist/transports/ConsoleTransport.d.ts.map +1 -0
  139. package/dist/transports/FileTransport.d.ts +15 -0
  140. package/dist/transports/FileTransport.d.ts.map +1 -0
  141. package/dist/transports/HttpTransport.d.ts +16 -0
  142. package/dist/transports/HttpTransport.d.ts.map +1 -0
  143. package/dist/transports/TransportManager.d.ts +14 -0
  144. package/dist/transports/TransportManager.d.ts.map +1 -0
  145. package/{src/transports/index.ts → dist/transports/index.d.ts} +1 -0
  146. package/dist/transports/index.d.ts.map +1 -0
  147. package/{src/types/core.ts → dist/types/core.d.ts} +25 -62
  148. package/dist/types/core.d.ts.map +1 -0
  149. package/{src/types/handlers.ts → dist/types/handlers.d.ts} +5 -15
  150. package/dist/types/handlers.d.ts.map +1 -0
  151. package/{src/types/hooks.ts → dist/types/hooks.d.ts} +3 -12
  152. package/dist/types/hooks.d.ts.map +1 -0
  153. package/dist/types/index.d.ts +11 -0
  154. package/dist/types/index.d.ts.map +1 -0
  155. package/{src/types/serializers.ts → dist/types/serializers.d.ts} +1 -6
  156. package/dist/types/serializers.d.ts.map +1 -0
  157. package/{src/types/transports.ts → dist/types/transports.d.ts} +2 -7
  158. package/dist/types/transports.d.ts.map +1 -0
  159. package/dist/utils/adapter.d.ts +48 -0
  160. package/dist/utils/adapter.d.ts.map +1 -0
  161. package/dist/utils/ansi-colors.d.ts +156 -0
  162. package/dist/utils/ansi-colors.d.ts.map +1 -0
  163. package/dist/utils/environment-detector.d.ts +45 -0
  164. package/dist/utils/environment-detector.d.ts.map +1 -0
  165. package/dist/utils/environment.d.ts +47 -0
  166. package/dist/utils/environment.d.ts.map +1 -0
  167. package/dist/utils/formatting.d.ts +58 -0
  168. package/dist/utils/formatting.d.ts.map +1 -0
  169. package/dist/utils/index.d.ts +8 -0
  170. package/dist/utils/index.d.ts.map +1 -0
  171. package/dist/utils/opentui-detection.d.ts +34 -0
  172. package/dist/utils/opentui-detection.d.ts.map +1 -0
  173. package/dist/utils/output.d.ts +46 -0
  174. package/dist/utils/output.d.ts.map +1 -0
  175. package/dist/utils/stackTrace.d.ts +6 -0
  176. package/dist/utils/stackTrace.d.ts.map +1 -0
  177. package/dist/utils/timestamps.d.ts +20 -0
  178. package/dist/utils/timestamps.d.ts.map +1 -0
  179. package/{src/writers/BufferWriter.ts → dist/writers/BufferWriter.d.ts} +16 -77
  180. package/dist/writers/BufferWriter.d.ts.map +1 -0
  181. package/{src/writers/index.ts → dist/writers/index.d.ts} +1 -1
  182. package/dist/writers/index.d.ts.map +1 -0
  183. package/package.json +5 -1
  184. package/.claude/settings.local.json +0 -48
  185. package/.github/workflows/ci-quality.yml +0 -357
  186. package/.github/workflows/docs-demo.yml +0 -119
  187. package/.github/workflows/releases-core.yml +0 -512
  188. package/.github/workflows/releases-full.yml +0 -582
  189. package/.github/workflows-backup/ci.yml +0 -221
  190. package/.github/workflows-backup/nightly.yml +0 -196
  191. package/.github/workflows-backup/release-optimized.yml +0 -373
  192. package/.github/workflows-backup/release.yml +0 -269
  193. package/.release-notes-0.2.0.md +0 -129
  194. package/.yamllint +0 -28
  195. package/CHANGELOG.json +0 -1120
  196. package/CHANGELOG.md +0 -209
  197. package/CLAUDE.md +0 -217
  198. package/demo.html +0 -847
  199. package/docs/API.md +0 -918
  200. package/docs/CORE.md +0 -264
  201. package/docs/DEVELOPMENT.md +0 -731
  202. package/docs/EXPORTS.md +0 -467
  203. package/docs/PACKAGES.md +0 -244
  204. package/docs/STYLING.md +0 -405
  205. package/docs/_config.yml +0 -36
  206. package/docs/index.md +0 -179
  207. package/examples/README.md +0 -208
  208. package/examples/basic-logging.js +0 -75
  209. package/examples/data-export.js +0 -234
  210. package/examples/package.json +0 -16
  211. package/examples/performance-timing.js +0 -170
  212. package/examples/simplified-api.js +0 -124
  213. package/examples/styling-themes.js +0 -207
  214. package/index.html +0 -358
  215. package/packages/core/package.json +0 -57
  216. package/packages/exports/package.json +0 -41
  217. package/packages/nodejs-opentui/README.md +0 -232
  218. package/packages/nodejs-opentui/package.json +0 -72
  219. package/packages/nodejs-opentui/src/LogRenderer.ts +0 -171
  220. package/packages/nodejs-opentui/src/OpenTUILogHandler.ts +0 -178
  221. package/packages/nodejs-opentui/src/components/LogBadge.tsx +0 -131
  222. package/packages/nodejs-opentui/src/index.ts +0 -133
  223. package/packages/nodejs-opentui/src/types.ts +0 -158
  224. package/packages/nodejs-opentui/tsconfig.json +0 -20
  225. package/packages/styling/package.json +0 -41
  226. package/playground/demo-all.ts +0 -95
  227. package/playground/demo-box.ts +0 -85
  228. package/playground/demo-levels.ts +0 -56
  229. package/playground/demo-real-world.ts +0 -98
  230. package/playground/demo-spinner.ts +0 -77
  231. package/playground/demo-steps.ts +0 -72
  232. package/playground/demo-table.ts +0 -83
  233. package/project-utils/README.md +0 -172
  234. package/project-utils/auto-release-gemini.ts +0 -1193
  235. package/project-utils/auto-release-ui.ts +0 -1329
  236. package/project-utils/commit-generator.ts +0 -1385
  237. package/project-utils/commit-ui.ts +0 -264
  238. package/project-utils/git-utils.ts +0 -199
  239. package/project-utils/github-release-manager.ts +0 -466
  240. package/project-utils/project-config.ts +0 -260
  241. package/project-utils/prompt-templates.js +0 -345
  242. package/project-utils/prompt-templates.ts +0 -422
  243. package/project-utils/version-manager.ts +0 -1078
  244. package/src/Logger.ts +0 -1858
  245. package/src/ScopedLogger.ts +0 -256
  246. package/src/cli/CommandProcessor.ts +0 -248
  247. package/src/cli/commands/ConfigCommand.ts +0 -93
  248. package/src/cli/commands/ExportCommand.ts +0 -276
  249. package/src/cli/commands/HistoryCommand.ts +0 -117
  250. package/src/cli/commands/StatusCommand.ts +0 -112
  251. package/src/cli/commands/ThemeCommand.ts +0 -88
  252. package/src/cli/help.ts +0 -127
  253. package/src/cli/index.ts +0 -71
  254. package/src/cli-primitives/box.ts +0 -86
  255. package/src/cli-primitives/cli-table.ts +0 -62
  256. package/src/cli-primitives/divider.ts +0 -17
  257. package/src/cli-primitives/header.ts +0 -18
  258. package/src/cli-primitives/server-fallback.ts +0 -54
  259. package/src/cli-primitives/spinner.ts +0 -133
  260. package/src/cli-primitives/step.ts +0 -22
  261. package/src/constants.ts +0 -313
  262. package/src/core.ts +0 -397
  263. package/src/example.ts +0 -210
  264. package/src/exports-module.ts +0 -311
  265. package/src/handlers/AnalyticsLogHandler.ts +0 -22
  266. package/src/handlers/ExportLogHandler.ts +0 -610
  267. package/src/handlers/FileLogHandler.ts +0 -169
  268. package/src/handlers/RemoteLogHandler.ts +0 -42
  269. package/src/hooks/HookManager.ts +0 -177
  270. package/src/index.ts +0 -395
  271. package/src/main.ts +0 -196
  272. package/src/serializers/SerializerRegistry.ts +0 -173
  273. package/src/style.css +0 -96
  274. package/src/styling/LogStyleBuilder.ts +0 -355
  275. package/src/styling/SemanticStyles.ts +0 -380
  276. package/src/styling/SmartPresets.ts +0 -288
  277. package/src/styling/StyleBuilder.ts +0 -319
  278. package/src/styling/StyleCache.ts +0 -131
  279. package/src/styling/banners.ts +0 -168
  280. package/src/styling/index.ts +0 -27
  281. package/src/styling/themes.ts +0 -235
  282. package/src/styling-module.ts +0 -244
  283. package/src/terminal/color-converter.ts +0 -315
  284. package/src/terminal/formatter.ts +0 -242
  285. package/src/terminal/terminal-renderer.ts +0 -342
  286. package/src/transports/ConsoleTransport.ts +0 -28
  287. package/src/transports/FileTransport.ts +0 -53
  288. package/src/transports/HttpTransport.ts +0 -56
  289. package/src/transports/TransportManager.ts +0 -130
  290. package/src/types/index.ts +0 -83
  291. package/src/typescript.svg +0 -1
  292. package/src/utils/adapter.ts +0 -291
  293. package/src/utils/ansi-colors.ts +0 -333
  294. package/src/utils/environment-detector.ts +0 -170
  295. package/src/utils/environment.ts +0 -94
  296. package/src/utils/formatting.ts +0 -332
  297. package/src/utils/index.ts +0 -33
  298. package/src/utils/opentui-detection.ts +0 -138
  299. package/src/utils/output.ts +0 -227
  300. package/src/utils/stackTrace.ts +0 -144
  301. package/src/utils/timestamps.ts +0 -80
  302. package/src/vite-env.d.ts +0 -1
  303. package/test-core-browser.html +0 -237
  304. package/test-core-node.js +0 -63
  305. package/tests/test-conflict-resolution.ts +0 -391
  306. package/tests/validate-workflows.sh +0 -131
  307. package/tests/yaml-autofix.sh +0 -146
  308. package/tsconfig.json +0 -50
  309. package/vite.config.ts +0 -256
  310. /package/{public → dist}/vite.svg +0 -0
@@ -1,170 +0,0 @@
1
- /**
2
- * Environment Detector - Robust environment detection for logger
3
- * Detects browser, terminal, server, and other runtime environments
4
- */
5
-
6
- export type Environment = 'browser' | 'terminal' | 'server' | 'webworker' | 'deno' | 'unknown';
7
-
8
- /**
9
- * Main environment detection function
10
- */
11
- export function getEnvironment(): Environment {
12
- // Check for Deno first
13
- if (typeof globalThis !== 'undefined' && (globalThis as any).Deno) {
14
- return 'deno';
15
- }
16
-
17
- // Check for WebWorker
18
- if (typeof window === 'undefined' && typeof self !== 'undefined' && typeof (self as any).importScripts === 'function') {
19
- return 'webworker';
20
- }
21
-
22
- // Check for Node.js (server environment)
23
- if (typeof process !== 'undefined' && process.versions && process.versions.node) {
24
- // Determine if it's running in a terminal or as a server
25
- if (isRunningInTerminal()) {
26
- return 'terminal';
27
- }
28
- return 'server';
29
- }
30
-
31
- // Check for browser
32
- if (typeof window !== 'undefined' && typeof document !== 'undefined') {
33
- return 'browser';
34
- }
35
-
36
- return 'unknown';
37
- }
38
-
39
- /**
40
- * Check if running in an interactive terminal
41
- */
42
- export function isRunningInTerminal(): boolean {
43
- // Check for common terminal indicators
44
- if (typeof process === 'undefined') return false;
45
-
46
- const isTTY = process.stdout && process.stdout.isTTY;
47
- const hasTerminalEnv = process.env && (
48
- process.env.TERM ||
49
- process.env.TERM_PROGRAM ||
50
- process.env.SSH_TTY ||
51
- process.env.TERM_SESSION_ID
52
- );
53
-
54
- // Check if we're running in common terminal programs
55
- const terminalPrograms = [
56
- 'vscode',
57
- 'hyper',
58
- 'iterm',
59
- 'terminal',
60
- 'alacritty',
61
- 'kitty',
62
- 'gnome-terminal',
63
- 'konsole',
64
- 'xterm',
65
- 'tmux',
66
- 'screen'
67
- ];
68
-
69
- const isTerminalProgram = hasTerminalEnv && terminalPrograms.some(program =>
70
- process.env.TERM_PROGRAM?.toLowerCase().includes(program) ||
71
- process.env.TERM?.toLowerCase().includes(program)
72
- );
73
-
74
- return Boolean(isTTY || hasTerminalEnv || isTerminalProgram);
75
- }
76
-
77
- /**
78
- * Check if environment supports ANSI colors
79
- */
80
- export function supportsANSI(): boolean {
81
- const env = getEnvironment();
82
-
83
- if (env === 'browser') return false;
84
- if (env === 'terminal') return true;
85
- if (env === 'server') return checkServerANSISupport();
86
-
87
- return false;
88
- }
89
-
90
- /**
91
- * Check if server environment supports ANSI colors
92
- */
93
- function checkServerANSISupport(): boolean {
94
- if (typeof process === 'undefined') return false;
95
-
96
- // Check common environment variables that indicate ANSI support
97
- const supportsANSI = process.env && (
98
- process.env.COLORTERM ||
99
- process.env.FORCE_COLOR ||
100
- (process.env.TERM && process.env.TERM !== 'dumb') ||
101
- process.env.TERM_PROGRAM
102
- );
103
-
104
- return Boolean(supportsANSI);
105
- }
106
-
107
- /**
108
- * Get environment-specific color capability
109
- */
110
- export function getColorCapability(): 'full' | 'basic' | 'none' {
111
- const env = getEnvironment();
112
-
113
- if (env === 'browser') {
114
- return 'full'; // CSS colors
115
- }
116
-
117
- if (!supportsANSI()) {
118
- return 'none';
119
- }
120
-
121
- // Check for 256-color or truecolor support
122
- if (typeof process !== 'undefined' && process.env) {
123
- const hasTrueColor = process.env.COLORTERM === 'truecolor' || process.env.COLORTERM === '24bit';
124
- const has256Colors = process.env.TERM && process.env.TERM.includes('256');
125
-
126
- if (hasTrueColor || has256Colors) {
127
- return 'full';
128
- }
129
- }
130
-
131
- return 'basic'; // Basic 16 colors
132
- }
133
-
134
- /**
135
- * Get terminal width in columns
136
- */
137
- export function getTerminalWidth(): number {
138
- if (typeof process !== 'undefined' && process.stdout?.columns) {
139
- return process.stdout.columns;
140
- }
141
- return 80;
142
- }
143
-
144
- /**
145
- * Get terminal height in rows
146
- */
147
- export function getTerminalHeight(): number {
148
- if (typeof process !== 'undefined' && process.stdout?.rows) {
149
- return process.stdout.rows;
150
- }
151
- return 24;
152
- }
153
-
154
- /**
155
- * Environment information for debugging
156
- */
157
- export function getEnvironmentInfo() {
158
- return {
159
- environment: getEnvironment(),
160
- supportsANSI: supportsANSI(),
161
- colorCapability: getColorCapability(),
162
- isTTY: typeof process !== 'undefined' ? Boolean(process.stdout?.isTTY) : false,
163
- platform: typeof process !== 'undefined' ? process.platform : 'unknown',
164
- nodeVersion: typeof process !== 'undefined' ? process.versions?.node : null,
165
- term: typeof process !== 'undefined' ? process.env?.TERM : null,
166
- colorTerm: typeof process !== 'undefined' ? process.env?.COLORTERM : null,
167
- terminalWidth: getTerminalWidth(),
168
- terminalHeight: getTerminalHeight()
169
- };
170
- }
@@ -1,94 +0,0 @@
1
- /**
2
- * @fileoverview Environment detection utilities for Universal Logger
3
- */
4
-
5
- /**
6
- * Checks if running in Node.js environment
7
- */
8
- export const isNode = typeof process !== 'undefined' &&
9
- process.versions &&
10
- process.versions.node;
11
-
12
- /**
13
- * Checks if running in browser environment
14
- */
15
- export const isBrowser = typeof window !== 'undefined' &&
16
- typeof document !== 'undefined';
17
-
18
- /**
19
- * Checks if running in web worker environment
20
- */
21
- export const isWebWorker = typeof self !== 'undefined' &&
22
- typeof (self as any).importScripts === 'function';
23
-
24
- /**
25
- * Checks if running in Deno environment
26
- */
27
- export const isDeno = typeof globalThis !== 'undefined' &&
28
- 'Deno' in globalThis;
29
-
30
- /**
31
- * Gets the current runtime environment
32
- */
33
- export function getRuntimeEnvironment(): 'node' | 'browser' | 'webworker' | 'deno' | 'unknown' {
34
- if (isNode) return 'node';
35
- if (isBrowser) return 'browser';
36
- if (isWebWorker) return 'webworker';
37
- if (isDeno) return 'deno';
38
- return 'unknown';
39
- }
40
-
41
- /**
42
- * Checks if colors/styling should be supported in current environment
43
- */
44
- export function supportsColors(): boolean {
45
- if (isBrowser) {
46
- // Browser always supports CSS colors
47
- return true;
48
- }
49
-
50
- if (isNode) {
51
- // Check if Node.js supports colors
52
- return process.stdout?.isTTY === true ||
53
- process.env.FORCE_COLOR === '1' ||
54
- process.env.FORCE_COLOR === 'true';
55
- }
56
-
57
- return false;
58
- }
59
-
60
- /**
61
- * Checks if CSS styling is supported (browser-only feature)
62
- */
63
- export function supportsCSSColors(): boolean {
64
- return isBrowser;
65
- }
66
-
67
- /**
68
- * Checks if ANSI colors are supported (terminal environments)
69
- */
70
- export function supportsANSIColors(): boolean {
71
- if (isNode) {
72
- return process.stdout?.isTTY === true ||
73
- process.env.FORCE_COLOR === '1' ||
74
- process.env.FORCE_COLOR === 'true';
75
- }
76
-
77
- return false;
78
- }
79
-
80
- /**
81
- * Gets environment-specific information
82
- */
83
- export function getEnvironmentInfo() {
84
- const env = getRuntimeEnvironment();
85
-
86
- return {
87
- runtime: env,
88
- supportsColors: supportsColors(),
89
- supportsCSSColors: supportsCSSColors(),
90
- supportsANSIColors: supportsANSIColors(),
91
- isProduction: isNode ? process.env.NODE_ENV === 'production' : false,
92
- version: isNode ? process.versions.node : (isBrowser ? navigator.userAgent : 'unknown')
93
- };
94
- }
@@ -1,332 +0,0 @@
1
- /**
2
- * @fileoverview Formatting utilities for Universal Logger
3
- */
4
-
5
- import type { LogLevel, StackInfo, OutputFormat } from '../types/index.js';
6
- import { formatTimestamp } from './timestamps.js';
7
- import { isNode, supportsANSIColors } from './environment.js';
8
- import {
9
- formatLogLevelANSI,
10
- formatTimestampANSI,
11
- formatPrefixANSI,
12
- formatLocationANSI,
13
- sanitizeEmojis,
14
- BUILD_FORMATTERS
15
- } from './ansi-colors.js';
16
-
17
- // Re-export the type for convenience
18
- export type { OutputFormat } from '../types/index.js';
19
-
20
- /**
21
- * Creates output based on environment and format preference
22
- */
23
- export function createOutput(
24
- level: LogLevel,
25
- message: string,
26
- prefix?: string,
27
- stackInfo?: StackInfo | null,
28
- format: OutputFormat = 'auto'
29
- ): string {
30
- const detectedFormat = format === 'auto' ? detectOptimalFormat() : format;
31
-
32
- switch (detectedFormat) {
33
- case 'ansi':
34
- return createANSIOutput(level, message, prefix, stackInfo);
35
- case 'build':
36
- return createBuildOutput(level, message, prefix, stackInfo);
37
- case 'ci':
38
- return createCIOutput(level, message, prefix, stackInfo);
39
- case 'plain':
40
- default:
41
- return createPlainOutput(level, message, prefix, stackInfo);
42
- }
43
- }
44
-
45
- /**
46
- * Creates plain text output for any environment
47
- * No colors, no styling - maximum compatibility
48
- */
49
- export function createPlainOutput(
50
- level: LogLevel,
51
- message: string,
52
- prefix?: string,
53
- stackInfo?: StackInfo | null
54
- ): string {
55
- const timestamp = formatTimestamp();
56
- const timeStr = timestamp.slice(11, 23); // HH:MM:SS.mmm
57
-
58
- let output = `[${timeStr}] [${level.toUpperCase()}]`;
59
-
60
- if (prefix) {
61
- output += ` [${prefix}]`;
62
- }
63
-
64
- output += ` ${message}`;
65
-
66
- if (stackInfo) {
67
- output += ` (${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`;
68
- }
69
-
70
- return output;
71
- }
72
-
73
- /**
74
- * Creates ANSI-colored output for terminals
75
- */
76
- export function createANSIOutput(
77
- level: LogLevel,
78
- message: string,
79
- prefix?: string,
80
- stackInfo?: StackInfo | null
81
- ): string {
82
- const timestamp = formatTimestamp();
83
- const timeStr = timestamp.slice(11, 23);
84
-
85
- let output = '';
86
-
87
- // Timestamp
88
- output += formatTimestampANSI(`[${timeStr}]`) + ' ';
89
-
90
- // Log level with colors
91
- output += formatLogLevelANSI(level) + ' ';
92
-
93
- // Prefix if provided
94
- if (prefix) {
95
- output += formatPrefixANSI(prefix) + ' ';
96
- }
97
-
98
- // Message
99
- output += message;
100
-
101
- // Stack info if provided
102
- if (stackInfo) {
103
- output += ' ' + formatLocationANSI(`(${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`);
104
- }
105
-
106
- return sanitizeEmojis(output);
107
- }
108
-
109
- /**
110
- * Creates build-friendly output (optimized for Next.js builds, webpack, etc.)
111
- */
112
- export function createBuildOutput(
113
- level: LogLevel,
114
- message: string,
115
- prefix?: string,
116
- stackInfo?: StackInfo | null
117
- ): string {
118
- const timestamp = formatTimestamp();
119
- const timeStr = timestamp.slice(11, 23);
120
-
121
- let output = '';
122
-
123
- // Use ANSI colors if supported
124
- if (supportsANSIColors()) {
125
- output += formatTimestampANSI(`[${timeStr}]`) + ' ';
126
-
127
- // Use build-specific formatters
128
- switch (level) {
129
- case 'info':
130
- output += BUILD_FORMATTERS.info(message);
131
- break;
132
- case 'warn':
133
- output += BUILD_FORMATTERS.warning(message);
134
- break;
135
- case 'error':
136
- case 'critical':
137
- output += BUILD_FORMATTERS.error(message);
138
- break;
139
- default:
140
- output += `${formatLogLevelANSI(level)} ${message}`;
141
- }
142
- } else {
143
- // Fallback to plain text
144
- output = `[${timeStr}] [${level.toUpperCase()}]`;
145
-
146
- if (prefix) {
147
- output += ` [${prefix}]`;
148
- }
149
-
150
- output += ` ${message}`;
151
- }
152
-
153
- if (stackInfo) {
154
- output += ` (${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`;
155
- }
156
-
157
- return sanitizeEmojis(output);
158
- }
159
-
160
- /**
161
- * Creates CI-friendly output (no emojis, simple formatting)
162
- */
163
- export function createCIOutput(
164
- level: LogLevel,
165
- message: string,
166
- prefix?: string,
167
- stackInfo?: StackInfo | null
168
- ): string {
169
- const timestamp = formatTimestamp();
170
- const timeStr = timestamp.slice(11, 23);
171
-
172
- let output = `[${timeStr}] [${level.toUpperCase()}]`;
173
-
174
- if (prefix) {
175
- output += ` [${prefix}]`;
176
- }
177
-
178
- output += ` ${message}`;
179
-
180
- if (stackInfo) {
181
- output += ` (${stackInfo.file}:${stackInfo.line}:${stackInfo.column})`;
182
- }
183
-
184
- // Always remove emojis for CI
185
- return sanitizeEmojis(output);
186
- }
187
-
188
- /**
189
- * Detects the optimal output format based on environment
190
- */
191
- export function detectOptimalFormat(): OutputFormat {
192
- // Check for specific environment variables
193
- const isCI = process.env.CI ||
194
- process.env.GITHUB_ACTIONS ||
195
- process.env.JENKINS_URL ||
196
- process.env.GITLAB_CI ||
197
- process.env.TRAVIS ||
198
- process.env.CIRCLECI;
199
-
200
- const isBuild = process.env.NODE_ENV === 'production' ||
201
- process.env.BUILD_MODE === 'production' ||
202
- process.argv.some(arg => arg.includes('build') || arg.includes('webpack'));
203
-
204
- const isNextJS = process.env.NEXT_RUNTIME ||
205
- process.argv.some(arg => arg.includes('next'));
206
-
207
- // CI environment - always use plain text
208
- if (isCI) {
209
- return 'ci';
210
- }
211
-
212
- // Next.js build environment
213
- if (isNextJS || isBuild) {
214
- return 'build';
215
- }
216
-
217
- // Node.js with ANSI support
218
- if (isNode && supportsANSIColors()) {
219
- return 'ansi';
220
- }
221
-
222
- // Default to plain text
223
- return 'plain';
224
- }
225
-
226
- /**
227
- * Gets the appropriate log method for the level
228
- * Uses different console methods for better semantics
229
- */
230
- export function getConsoleMethod(level: LogLevel): 'log' | 'info' | 'warn' | 'error' {
231
- switch (level) {
232
- case 'debug':
233
- return 'log';
234
- case 'info':
235
- return 'info';
236
- case 'warn':
237
- return 'warn';
238
- case 'error':
239
- case 'critical':
240
- return 'error';
241
- default:
242
- return 'log';
243
- }
244
- }
245
-
246
- /**
247
- * Create a simple log entry object for handlers
248
- */
249
- export function createLogEntry(
250
- level: LogLevel,
251
- message: string,
252
- args: any[],
253
- prefix?: string,
254
- stackInfo?: StackInfo | null
255
- ) {
256
- return {
257
- timestamp: formatTimestamp(),
258
- level: level.toUpperCase(),
259
- prefix,
260
- message,
261
- args: args.slice(1), // Exclude the first message argument
262
- location: stackInfo ? {
263
- file: stackInfo.file,
264
- line: stackInfo.line,
265
- column: stackInfo.column,
266
- function: stackInfo.function
267
- } : undefined,
268
- raw: args
269
- };
270
- }
271
-
272
- /**
273
- * Format data for table display in plain text
274
- */
275
- export function formatTablePlain(data: any, columns?: string[]): string {
276
- try {
277
- if (Array.isArray(data)) {
278
- if (data.length === 0) return '[Empty Array]';
279
-
280
- // Simple array formatting
281
- if (typeof data[0] !== 'object') {
282
- return data.map((item, i) => `${i}: ${item}`).join('\n');
283
- }
284
-
285
- // Object array formatting
286
- const keys = columns || Object.keys(data[0] || {});
287
- const header = keys.join('\t');
288
- const rows = data.map(item =>
289
- keys.map(key => String(item[key] || '')).join('\t')
290
- );
291
-
292
- return [header, ...rows].join('\n');
293
- }
294
-
295
- if (typeof data === 'object' && data !== null) {
296
- // Simple object formatting
297
- return Object.entries(data)
298
- .map(([key, value]) => `${key}: ${value}`)
299
- .join('\n');
300
- }
301
-
302
- return String(data);
303
- } catch (error) {
304
- return `[Error formatting table: ${error}]`;
305
- }
306
- }
307
-
308
- /**
309
- * Safe object serialization for logging
310
- */
311
- export function safeSerialize(obj: any, maxDepth: number = 3, currentDepth: number = 0): any {
312
- if (currentDepth >= maxDepth) {
313
- return '[Max Depth Reached]';
314
- }
315
-
316
- if (obj === null) return null;
317
- if (obj === undefined) return '[undefined]';
318
- if (typeof obj === 'function') return '[Function]';
319
- if (obj instanceof Error) return `[Error: ${obj.message}]`;
320
- if (obj instanceof Date) return obj.toISOString();
321
- if (typeof obj !== 'object') return obj;
322
-
323
- if (Array.isArray(obj)) {
324
- return obj.map(item => safeSerialize(item, maxDepth, currentDepth + 1));
325
- }
326
-
327
- const result: any = {};
328
- for (const [key, value] of Object.entries(obj)) {
329
- result[key] = safeSerialize(value, maxDepth, currentDepth + 1);
330
- }
331
- return result;
332
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * @fileoverview Utility functions exports for Advanced Logger
3
- */
4
-
5
- export { parseStackTrace } from './stackTrace.js';
6
- export {
7
- formatTimestamp,
8
- parseRelativeTime,
9
- parseTimeInput,
10
- formatDisplayTime
11
- } from './timestamps.js';
12
- export {
13
- createStyledOutput,
14
- generateLogId,
15
- escapeHtml,
16
- safeStringify,
17
- detectDevToolsTheme,
18
- getAdaptiveColor,
19
- setupThemeChangeListener,
20
- type LevelStyleConfig
21
- } from './output.js';
22
- export {
23
- createPlainOutput,
24
- createOutput,
25
- createANSIOutput,
26
- createBuildOutput,
27
- createCIOutput,
28
- detectOptimalFormat,
29
- getConsoleMethod,
30
- createLogEntry,
31
- formatTablePlain,
32
- safeSerialize
33
- } from './formatting.js';