@loglayer/transport-simple-pretty-terminal 2.2.7 → 2.2.9
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/dist/index.cjs +678 -633
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +104 -118
- package/dist/index.d.ts +104 -118
- package/dist/index.js +642 -634
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ChalkInstance } from
|
|
3
|
-
export * from
|
|
1
|
+
import { LogLayerTransportParams, LoggerlessTransport, LoggerlessTransportConfig } from "@loglayer/transport";
|
|
2
|
+
import { ChalkInstance } from "chalk";
|
|
3
|
+
export * from "chalk";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Configuration for log level colors.
|
|
7
9
|
* Each log level can have its own chalk styling.
|
|
8
10
|
*/
|
|
9
11
|
interface ColorConfig {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
/** Style for trace level logs - lowest severity */
|
|
13
|
+
trace?: ChalkInstance;
|
|
14
|
+
/** Style for debug level logs */
|
|
15
|
+
debug?: ChalkInstance;
|
|
16
|
+
/** Style for info level logs - normal operation */
|
|
17
|
+
info?: ChalkInstance;
|
|
18
|
+
/** Style for warning level logs */
|
|
19
|
+
warn?: ChalkInstance;
|
|
20
|
+
/** Style for error level logs */
|
|
21
|
+
error?: ChalkInstance;
|
|
22
|
+
/** Style for fatal level logs - highest severity */
|
|
23
|
+
fatal?: ChalkInstance;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* Configuration for log view styling.
|
|
25
27
|
* Defines colors and styles for different log elements.
|
|
26
28
|
*/
|
|
27
29
|
interface ViewConfig {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
/** Color configuration for different log levels */
|
|
31
|
+
colors?: ColorConfig;
|
|
32
|
+
/** Style for log entry IDs */
|
|
33
|
+
logIdColor?: ChalkInstance;
|
|
34
|
+
/** Style for data values in structured data */
|
|
35
|
+
dataValueColor?: ChalkInstance;
|
|
36
|
+
/** Style for data keys in structured data */
|
|
37
|
+
dataKeyColor?: ChalkInstance;
|
|
36
38
|
}
|
|
37
39
|
/**
|
|
38
40
|
* Runtime environment for the transport.
|
|
@@ -43,8 +45,7 @@ type Runtime = "node" | "browser";
|
|
|
43
45
|
* Theme configuration for the simple pretty terminal transport.
|
|
44
46
|
* Defines styling for log output.
|
|
45
47
|
*/
|
|
46
|
-
interface SimplePrettyTerminalTheme extends ViewConfig {
|
|
47
|
-
}
|
|
48
|
+
interface SimplePrettyTerminalTheme extends ViewConfig {}
|
|
48
49
|
/**
|
|
49
50
|
* View modes for log display.
|
|
50
51
|
* - inline: Shows all information with complete data structures inline (no truncation)
|
|
@@ -57,52 +58,29 @@ type PrettyTerminalViewMode = "inline" | "message-only" | "expanded";
|
|
|
57
58
|
* Extends the base transport configuration with simple pretty terminal specific options.
|
|
58
59
|
*/
|
|
59
60
|
interface SimplePrettyTerminalConfig extends LoggerlessTransportConfig {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
61
|
+
/** Maximum depth for inline data display before collapsing. Default is 4. */
|
|
62
|
+
maxInlineDepth?: number;
|
|
63
|
+
/** Custom theme configuration for log display */
|
|
64
|
+
theme?: SimplePrettyTerminalTheme;
|
|
65
|
+
/** Whether the transport is enabled. If false, all operations will no-op. Defaults to true */
|
|
66
|
+
enabled?: boolean;
|
|
67
|
+
/** View mode for log display. Defaults to "inline" */
|
|
68
|
+
viewMode?: PrettyTerminalViewMode;
|
|
69
|
+
/** Whether to show log IDs in the output. Defaults to false */
|
|
70
|
+
showLogId?: boolean;
|
|
71
|
+
/** Custom timestamp format. Can be a date-fns format string or a custom function. Defaults to "HH:mm:ss.SSS" */
|
|
72
|
+
timestampFormat?: string | ((timestamp: number) => string);
|
|
73
|
+
/** Whether to collapse arrays in expanded mode. Defaults to true */
|
|
74
|
+
collapseArrays?: boolean;
|
|
75
|
+
/** Whether to flatten nested objects with dot notation in inline mode. Defaults to true */
|
|
76
|
+
flattenNestedObjects?: boolean;
|
|
77
|
+
/** Runtime environment for output */
|
|
78
|
+
runtime: Runtime;
|
|
79
|
+
/** Whether to include data object as second parameter in browser console calls for better debugging. Defaults to false */
|
|
80
|
+
includeDataInBrowserConsole?: boolean;
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
* A transport for LogLayer that provides simple pretty terminal output.
|
|
84
|
-
* This transport displays logs with theming and formatting but without interactive features.
|
|
85
|
-
*
|
|
86
|
-
* Features:
|
|
87
|
-
* - Real-time log display with color-coded levels
|
|
88
|
-
* - Configurable themes and colors
|
|
89
|
-
* - Three view modes: inline, message-only, expanded
|
|
90
|
-
* - JSON data pretty printing
|
|
91
|
-
* - No interactive features (no keyboard navigation, no input)
|
|
92
|
-
* - Browser and Node.js runtime support
|
|
93
|
-
*
|
|
94
|
-
* Usage:
|
|
95
|
-
* ```typescript
|
|
96
|
-
* const transport = new SimplePrettyTerminalTransport({
|
|
97
|
-
* maxInlineDepth: 4,
|
|
98
|
-
* maxInlineLength: 120,
|
|
99
|
-
* theme: customTheme,
|
|
100
|
-
* viewMode: "inline",
|
|
101
|
-
* runtime: "node" // or "browser"
|
|
102
|
-
* });
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/SimplePrettyTerminalTransport.d.ts
|
|
106
84
|
/**
|
|
107
85
|
* Main transport class that handles simple pretty terminal output.
|
|
108
86
|
* This class provides the display functionality of PrettyTerminal without interactive features.
|
|
@@ -113,53 +91,59 @@ interface SimplePrettyTerminalConfig extends LoggerlessTransportConfig {
|
|
|
113
91
|
* 3. Expanded: Shows timestamp, level, and message on first line, with data on indented separate lines
|
|
114
92
|
*/
|
|
115
93
|
declare class SimplePrettyTerminalTransport extends LoggerlessTransport {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
94
|
+
/** Handles rendering and formatting of logs */
|
|
95
|
+
private renderer;
|
|
96
|
+
/** Configuration options */
|
|
97
|
+
private config;
|
|
98
|
+
/**
|
|
99
|
+
* Creates a new SimplePrettyTerminalTransport instance.
|
|
100
|
+
*
|
|
101
|
+
* @param config - Configuration options for the transport
|
|
102
|
+
*/
|
|
103
|
+
constructor(config: SimplePrettyTerminalConfig);
|
|
104
|
+
/**
|
|
105
|
+
* Generates a random ID for each log entry.
|
|
106
|
+
* Uses base36 encoding for compact, readable IDs.
|
|
107
|
+
*
|
|
108
|
+
* @returns A 6-character string ID
|
|
109
|
+
* @example
|
|
110
|
+
* "a1b2c3" // Example generated ID
|
|
111
|
+
*/
|
|
112
|
+
private generateId;
|
|
113
|
+
/**
|
|
114
|
+
* Main transport method that receives logs from LogLayer.
|
|
115
|
+
* This method is called for each log event and handles:
|
|
116
|
+
* - Generating a unique ID for the log
|
|
117
|
+
* - Converting the log data to a storable format
|
|
118
|
+
* - Rendering the log using the SimpleView renderer
|
|
119
|
+
*
|
|
120
|
+
* @param logLevel - The severity level of the log
|
|
121
|
+
* @param messages - Array of message strings to be joined
|
|
122
|
+
* @param data - Additional structured data to be logged
|
|
123
|
+
* @param hasData - Whether the log includes additional data
|
|
124
|
+
* @returns The original messages array
|
|
125
|
+
*/
|
|
126
|
+
shipToLogger({
|
|
127
|
+
logLevel,
|
|
128
|
+
messages,
|
|
129
|
+
data,
|
|
130
|
+
hasData
|
|
131
|
+
}: LogLayerTransportParams): any[];
|
|
132
|
+
/**
|
|
133
|
+
* Changes the view mode for log display.
|
|
134
|
+
*
|
|
135
|
+
* @param viewMode - The new view mode to use
|
|
136
|
+
*/
|
|
137
|
+
setViewMode(viewMode: PrettyTerminalViewMode): void;
|
|
138
|
+
/**
|
|
139
|
+
* Gets the current view mode.
|
|
140
|
+
*
|
|
141
|
+
* @returns The current view mode
|
|
142
|
+
*/
|
|
143
|
+
getViewMode(): PrettyTerminalViewMode;
|
|
161
144
|
}
|
|
162
|
-
|
|
145
|
+
//#endregion
|
|
146
|
+
//#region src/themes.d.ts
|
|
163
147
|
/**
|
|
164
148
|
* Moonlight - A dark theme with cool blue tones
|
|
165
149
|
* Inspired by moonlit nights and modern IDEs
|
|
@@ -236,7 +220,9 @@ declare const nature: SimplePrettyTerminalTheme;
|
|
|
236
220
|
* - Reduced visual stress
|
|
237
221
|
*/
|
|
238
222
|
declare const pastel: SimplePrettyTerminalTheme;
|
|
239
|
-
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/index.d.ts
|
|
240
225
|
declare function getSimplePrettyTerminal(config: SimplePrettyTerminalConfig): SimplePrettyTerminalTransport;
|
|
241
|
-
|
|
226
|
+
//#endregion
|
|
242
227
|
export { type PrettyTerminalViewMode, type Runtime, type SimplePrettyTerminalConfig, type SimplePrettyTerminalTheme, SimplePrettyTerminalTransport, getSimplePrettyTerminal, moonlight, nature, neon, pastel, sunlight };
|
|
228
|
+
//# sourceMappingURL=index.d.ts.map
|