@heojeongbo/log-palette 0.2.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/src/types.ts ADDED
@@ -0,0 +1,80 @@
1
+ export type LogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug'
2
+
3
+ export interface LoggerOptions {
4
+ /**
5
+ * CSS color string for this domain's prefix badge.
6
+ * If omitted, a color is auto-derived from the domain name via djb2 hash.
7
+ * Accepts any valid CSS color value: '#f06', 'hsl(200,80%,55%)', 'coral', etc.
8
+ */
9
+ color?: string
10
+
11
+ /**
12
+ * Minimum log level to output. Levels below this are silently dropped.
13
+ * Order (lowest→highest): debug < log < info < warn < error
14
+ * Defaults to 'debug' (all levels pass through).
15
+ */
16
+ level?: LogLevel
17
+
18
+ /**
19
+ * When false, suppress all output regardless of level.
20
+ * Defaults to true.
21
+ */
22
+ enabled?: boolean
23
+ }
24
+
25
+ export interface Logger {
26
+ /** Log at 'log' level. */
27
+ log(...args: unknown[]): void
28
+ /** Log at 'info' level. */
29
+ info(...args: unknown[]): void
30
+ /** Log at 'warn' level. */
31
+ warn(...args: unknown[]): void
32
+ /** Log at 'error' level. */
33
+ error(...args: unknown[]): void
34
+ /** Log at 'debug' level. */
35
+ debug(...args: unknown[]): void
36
+
37
+ /**
38
+ * Open a collapsible DevTools group with the domain prefix.
39
+ * Must be closed with `groupEnd()`.
40
+ */
41
+ group(label: string): void
42
+
43
+ /**
44
+ * Open a collapsed DevTools group with the domain prefix.
45
+ * Must be closed with `groupEnd()`.
46
+ */
47
+ groupCollapsed(label: string): void
48
+
49
+ /** Close the most recently opened group. */
50
+ groupEnd(): void
51
+
52
+ /**
53
+ * Start a named timer prefixed with the domain.
54
+ * Use `timeEnd(label)` to stop and print elapsed time.
55
+ */
56
+ time(label: string): void
57
+
58
+ /**
59
+ * Stop a named timer and log the elapsed time to the console.
60
+ * @param label Must match the label passed to `time()`.
61
+ */
62
+ timeEnd(label: string): void
63
+
64
+ /**
65
+ * Dynamically change the minimum log level for this logger.
66
+ * Useful for adjusting verbosity at runtime.
67
+ */
68
+ setLevel(level: LogLevel): void
69
+
70
+ /**
71
+ * Enable or disable this logger at runtime.
72
+ * When disabled, all log calls are silently dropped.
73
+ */
74
+ setEnabled(enabled: boolean): void
75
+
76
+ /** The domain name this logger was created with. */
77
+ readonly domain: string
78
+ /** The resolved CSS color string for this logger's prefix. */
79
+ readonly color: string
80
+ }