@mks2508/better-logger 0.0.1

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 (41) hide show
  1. package/.claude/settings.local.json +13 -0
  2. package/CLAUDE.md +113 -0
  3. package/dist/assets/index-DxvJByYN.js +183 -0
  4. package/dist/index.html +334 -0
  5. package/dist/vite.svg +1 -0
  6. package/index.html +334 -0
  7. package/package.json +35 -0
  8. package/public/vite.svg +1 -0
  9. package/src/Logger.ts +577 -0
  10. package/src/Logger.ts.backup +1684 -0
  11. package/src/cli/CommandProcessor.ts +77 -0
  12. package/src/cli/commands/ConfigCommand.ts +93 -0
  13. package/src/cli/commands/ExportCommand.ts +271 -0
  14. package/src/cli/commands/StatusCommand.ts +111 -0
  15. package/src/cli/commands/ThemeCommand.ts +88 -0
  16. package/src/cli/help.ts +127 -0
  17. package/src/cli/index.ts +59 -0
  18. package/src/constants.ts +89 -0
  19. package/src/example.ts +88 -0
  20. package/src/handlers/AnalyticsLogHandler.ts +22 -0
  21. package/src/handlers/ExportLogHandler.ts +447 -0
  22. package/src/handlers/FileLogHandler.ts +30 -0
  23. package/src/handlers/RemoteLogHandler.ts +42 -0
  24. package/src/handlers/index.ts +8 -0
  25. package/src/index.ts +122 -0
  26. package/src/main.ts +126 -0
  27. package/src/style.css +96 -0
  28. package/src/styling/StyleBuilder.ts +305 -0
  29. package/src/styling/banners.ts +168 -0
  30. package/src/styling/index.ts +12 -0
  31. package/src/styling/themes.ts +235 -0
  32. package/src/types/core.ts +80 -0
  33. package/src/types/handlers.ts +95 -0
  34. package/src/types/index.ts +29 -0
  35. package/src/typescript.svg +1 -0
  36. package/src/utils/index.ts +18 -0
  37. package/src/utils/output.ts +127 -0
  38. package/src/utils/stackTrace.ts +66 -0
  39. package/src/utils/timestamps.ts +80 -0
  40. package/src/vite-env.d.ts +1 -0
  41. package/tsconfig.json +24 -0
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @fileoverview Timestamp utilities for Advanced Logger
3
+ */
4
+
5
+ import { TIME_UNITS } from '../constants.js';
6
+
7
+ /**
8
+ * Formats the timestamp using modern Date API
9
+ */
10
+ export function formatTimestamp(): string {
11
+ try {
12
+ // Use modern Temporal API if available, fallback to Date
13
+ const now = new Date();
14
+ return now.toISOString();
15
+ } catch {
16
+ return new Date().toISOString();
17
+ }
18
+ }
19
+
20
+ /**
21
+ * Parse relative time strings like "2h", "30m", "1d" into milliseconds
22
+ */
23
+ export function parseRelativeTime(timeStr: string): number {
24
+ const match = timeStr.match(/^(\d+)(ms|s|m|h|d)$/);
25
+ if (!match) {
26
+ throw new Error(`Invalid time format: ${timeStr}. Use format like "2h", "30m", "1d"`);
27
+ }
28
+
29
+ const [, amount, unit] = match;
30
+ const multiplier = TIME_UNITS[unit as keyof typeof TIME_UNITS];
31
+
32
+ return parseInt(amount, 10) * multiplier;
33
+ }
34
+
35
+ /**
36
+ * Parse time input which can be Date, ISO string, or relative time
37
+ */
38
+ export function parseTimeInput(input: Date | string | number): Date {
39
+ if (input instanceof Date) {
40
+ return input;
41
+ }
42
+
43
+ if (typeof input === 'number') {
44
+ // Assume hours ago
45
+ return new Date(Date.now() - input * TIME_UNITS.h);
46
+ }
47
+
48
+ if (typeof input === 'string') {
49
+ // Try parsing as ISO date first
50
+ const isoDate = new Date(input);
51
+ if (!isNaN(isoDate.getTime())) {
52
+ return isoDate;
53
+ }
54
+
55
+ // Try parsing as relative time
56
+ try {
57
+ const ms = parseRelativeTime(input);
58
+ return new Date(Date.now() - ms);
59
+ } catch {
60
+ throw new Error(`Invalid time format: ${input}`);
61
+ }
62
+ }
63
+
64
+ throw new Error(`Unsupported time input type: ${typeof input}`);
65
+ }
66
+
67
+ /**
68
+ * Format timestamp for display in different contexts
69
+ */
70
+ export function formatDisplayTime(date: Date, format: 'short' | 'full' | 'time-only' = 'short'): string {
71
+ switch (format) {
72
+ case 'time-only':
73
+ return date.toTimeString().slice(0, 8); // HH:MM:SS
74
+ case 'full':
75
+ return date.toISOString();
76
+ case 'short':
77
+ default:
78
+ return date.toISOString().slice(11, 23); // HH:MM:SS.mmm
79
+ }
80
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "verbatimModuleSyntax": true,
13
+ "moduleDetection": "force",
14
+ "noEmit": true,
15
+
16
+ /* Linting */
17
+ "strict": true,
18
+ "noUnusedLocals": true,
19
+ "noUnusedParameters": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+ "noUncheckedSideEffectImports": true
22
+ },
23
+ "include": ["src"]
24
+ }