@loglayer/transport-pretty-terminal 4.0.5 → 4.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/dist/index.cjs +1607 -1758
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +147 -153
- package/dist/index.d.ts +147 -153
- package/dist/index.js +1559 -1751
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.d.cts
CHANGED
|
@@ -1,138 +1,124 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { LogLayerTransportParams, LoggerlessTransport, LoggerlessTransportConfig } from "@loglayer/transport";
|
|
2
|
+
import * as chalk from "chalk";
|
|
3
|
+
import { ChalkInstance } from "chalk";
|
|
4
|
+
|
|
5
|
+
//#region src/types.d.ts
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Represents a single log entry in the storage system.
|
|
8
9
|
* Each entry contains metadata and the actual log content.
|
|
9
10
|
*/
|
|
10
11
|
interface LogEntry {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
/** Unique identifier for the log entry */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Unix timestamp in milliseconds when the log was created */
|
|
15
|
+
timestamp: number;
|
|
16
|
+
/** Log level (trace, debug, info, warn, error, fatal) */
|
|
17
|
+
level: string;
|
|
18
|
+
/** Main log message content */
|
|
19
|
+
message: string;
|
|
20
|
+
/** Optional structured data associated with the log, stored as JSON string */
|
|
21
|
+
data: string | null;
|
|
21
22
|
}
|
|
22
23
|
/**
|
|
23
24
|
* Configuration for log level colors.
|
|
24
25
|
* Each log level can have its own chalk styling.
|
|
25
26
|
*/
|
|
26
27
|
interface ColorConfig {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
/** Style for trace level logs - lowest severity */
|
|
29
|
+
trace?: ChalkInstance;
|
|
30
|
+
/** Style for debug level logs */
|
|
31
|
+
debug?: ChalkInstance;
|
|
32
|
+
/** Style for info level logs - normal operation */
|
|
33
|
+
info?: ChalkInstance;
|
|
34
|
+
/** Style for warning level logs */
|
|
35
|
+
warn?: ChalkInstance;
|
|
36
|
+
/** Style for error level logs */
|
|
37
|
+
error?: ChalkInstance;
|
|
38
|
+
/** Style for fatal level logs - highest severity */
|
|
39
|
+
fatal?: ChalkInstance;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* Base configuration for log view styling.
|
|
42
43
|
* Defines colors and styles for different log elements.
|
|
43
44
|
*/
|
|
44
45
|
interface ViewConfig {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
/** Color configuration for different log levels */
|
|
47
|
+
colors?: ColorConfig;
|
|
48
|
+
/** Style for log entry IDs */
|
|
49
|
+
logIdColor?: ChalkInstance;
|
|
50
|
+
/** Style for data values in structured data */
|
|
51
|
+
dataValueColor?: ChalkInstance;
|
|
52
|
+
/** Style for data keys in structured data */
|
|
53
|
+
dataKeyColor?: ChalkInstance;
|
|
54
|
+
/** Style for selection indicators in interactive mode */
|
|
55
|
+
selectorColor?: ChalkInstance;
|
|
55
56
|
}
|
|
56
57
|
/**
|
|
57
58
|
* Extended view configuration for detailed/interactive mode.
|
|
58
59
|
* Includes additional styling options for the detailed view UI.
|
|
59
60
|
*/
|
|
60
61
|
interface DetailedViewConfig extends ViewConfig {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
62
|
+
/** Style for section headers in detailed view */
|
|
63
|
+
headerColor?: ChalkInstance;
|
|
64
|
+
/** Style for field labels in detailed view */
|
|
65
|
+
labelColor?: ChalkInstance;
|
|
66
|
+
/** Style for visual separators between sections */
|
|
67
|
+
separatorColor?: ChalkInstance;
|
|
68
|
+
/** Configuration for JSON data formatting colors */
|
|
69
|
+
jsonColors?: {
|
|
70
|
+
/** Style for object property names */
|
|
71
|
+
keysColor?: ChalkInstance;
|
|
72
|
+
/** Style for array bullets */
|
|
73
|
+
dashColor?: ChalkInstance;
|
|
74
|
+
/** Default style for numbers */
|
|
75
|
+
numberColor?: ChalkInstance;
|
|
76
|
+
/** Style for single-line strings */
|
|
77
|
+
stringColor?: ChalkInstance;
|
|
78
|
+
/** Style for multi-line strings */
|
|
79
|
+
multilineStringColor?: ChalkInstance;
|
|
80
|
+
/** Style for positive numbers */
|
|
81
|
+
positiveNumberColor?: ChalkInstance;
|
|
82
|
+
/** Style for negative numbers */
|
|
83
|
+
negativeNumberColor?: ChalkInstance;
|
|
84
|
+
/** Style for boolean values */
|
|
85
|
+
booleanColor?: ChalkInstance;
|
|
86
|
+
/** Style for null and undefined values */
|
|
87
|
+
nullUndefinedColor?: ChalkInstance;
|
|
88
|
+
/** Style for date objects */
|
|
89
|
+
dateColor?: ChalkInstance;
|
|
90
|
+
};
|
|
90
91
|
}
|
|
91
92
|
/**
|
|
92
93
|
* Theme configuration for the pretty terminal transport.
|
|
93
94
|
* Defines styling for both simple and detailed view modes.
|
|
94
95
|
*/
|
|
95
96
|
interface PrettyTerminalTheme {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
/** Styling configuration for real-time log output mode */
|
|
98
|
+
simpleView: ViewConfig;
|
|
99
|
+
/** Styling configuration for interactive/detailed view mode */
|
|
100
|
+
detailedView: DetailedViewConfig;
|
|
100
101
|
}
|
|
101
102
|
/**
|
|
102
103
|
* Main configuration interface for PrettyTerminalTransport.
|
|
103
104
|
* Extends the base transport configuration with pretty terminal specific options.
|
|
104
105
|
*/
|
|
105
106
|
interface PrettyTerminalConfig extends LoggerlessTransportConfig {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
107
|
+
/** Maximum depth for inline data display before collapsing */
|
|
108
|
+
maxInlineDepth?: number;
|
|
109
|
+
/** Maximum length for inline data display before truncating */
|
|
110
|
+
maxInlineLength?: number;
|
|
111
|
+
/** Custom theme configuration for log display */
|
|
112
|
+
theme?: PrettyTerminalTheme;
|
|
113
|
+
/** Path to SQLite file for persistent storage. If not provided, uses in-memory database */
|
|
114
|
+
logFile?: string;
|
|
115
|
+
/** Whether the transport is enabled. If false, all operations will no-op. Defaults to true */
|
|
116
|
+
enabled?: boolean;
|
|
117
|
+
/** Whether to disable interactive mode (keyboard input and navigation). Useful when multiple applications need to print to the same terminal. Defaults to false */
|
|
118
|
+
disableInteractiveMode?: boolean;
|
|
118
119
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
* A transport for LogLayer that provides a pretty terminal output with interactive features.
|
|
122
|
-
* This transport implements an interactive terminal UI for viewing and filtering logs.
|
|
123
|
-
*
|
|
124
|
-
* Features:
|
|
125
|
-
* - Real-time log display with color-coded levels
|
|
126
|
-
* - Interactive selection mode for browsing logs
|
|
127
|
-
* - Detailed view for inspecting individual log entries
|
|
128
|
-
* - Search/filter functionality
|
|
129
|
-
* - JSON data pretty printing
|
|
130
|
-
* - Configurable themes and colors
|
|
131
|
-
*
|
|
132
|
-
* The transport uses a singleton pattern to ensure only one instance exists,
|
|
133
|
-
* as it manages terminal input and output which cannot be shared.
|
|
134
|
-
*/
|
|
135
|
-
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/PrettyTerminalTransport.d.ts
|
|
136
122
|
/**
|
|
137
123
|
* Main transport class that handles pretty terminal output and interactive features.
|
|
138
124
|
* This class coordinates between different components:
|
|
@@ -154,59 +140,65 @@ interface PrettyTerminalConfig extends LoggerlessTransportConfig {
|
|
|
154
140
|
* ```
|
|
155
141
|
*/
|
|
156
142
|
declare class PrettyTerminalTransport extends LoggerlessTransport {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
143
|
+
/** Singleton instance of the transport */
|
|
144
|
+
private static instance;
|
|
145
|
+
/** Handles all rendering and formatting of logs */
|
|
146
|
+
private renderer;
|
|
147
|
+
/** Manages log persistence in SQLite database */
|
|
148
|
+
private storage;
|
|
149
|
+
/** Manages user interaction and view state */
|
|
150
|
+
private uiManager;
|
|
151
|
+
/** Configuration options */
|
|
152
|
+
private config;
|
|
153
|
+
/**
|
|
154
|
+
* Creates a new PrettyTerminalTransport instance.
|
|
155
|
+
* This is a singleton class - only one instance can exist at a time.
|
|
156
|
+
* Use getInstance() instead of constructor directly.
|
|
157
|
+
*
|
|
158
|
+
* @param config - Configuration options for the transport
|
|
159
|
+
* @throws Error if attempting to create multiple instances
|
|
160
|
+
*/
|
|
161
|
+
constructor(config?: PrettyTerminalConfig);
|
|
162
|
+
/**
|
|
163
|
+
* Gets or creates the singleton instance of PrettyTerminalTransport.
|
|
164
|
+
* This is the recommended way to obtain a transport instance.
|
|
165
|
+
*
|
|
166
|
+
* @param config - Configuration options for the transport
|
|
167
|
+
* @returns The singleton instance of PrettyTerminalTransport
|
|
168
|
+
*/
|
|
169
|
+
static getInstance(config?: PrettyTerminalConfig): PrettyTerminalTransport;
|
|
170
|
+
/**
|
|
171
|
+
* Generates a random ID for each log entry.
|
|
172
|
+
* Uses base36 encoding for compact, readable IDs.
|
|
173
|
+
*
|
|
174
|
+
* @returns A 6-character string ID
|
|
175
|
+
* @example
|
|
176
|
+
* "a1b2c3" // Example generated ID
|
|
177
|
+
*/
|
|
178
|
+
private generateId;
|
|
179
|
+
/**
|
|
180
|
+
* Main transport method that receives logs from LogLayer.
|
|
181
|
+
* This method is called for each log event and handles:
|
|
182
|
+
* - Generating a unique ID for the log
|
|
183
|
+
* - Converting the log data to a storable format
|
|
184
|
+
* - Storing the log in the database
|
|
185
|
+
* - Rendering the log if not in selection mode
|
|
186
|
+
*
|
|
187
|
+
* @param logLevel - The severity level of the log
|
|
188
|
+
* @param messages - Array of message strings to be joined
|
|
189
|
+
* @param data - Additional structured data to be logged
|
|
190
|
+
* @param hasData - Whether the log includes additional data
|
|
191
|
+
* @returns The original messages array
|
|
192
|
+
*/
|
|
193
|
+
shipToLogger({
|
|
194
|
+
logLevel,
|
|
195
|
+
messages,
|
|
196
|
+
data,
|
|
197
|
+
hasData
|
|
198
|
+
}: LogLayerTransportParams): any[];
|
|
208
199
|
}
|
|
209
|
-
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/themes.d.ts
|
|
210
202
|
/**
|
|
211
203
|
* Moonlight - A dark theme with cool blue tones
|
|
212
204
|
* Inspired by moonlit nights and modern IDEs
|
|
@@ -284,7 +276,9 @@ declare const nature: PrettyTerminalTheme;
|
|
|
284
276
|
* - Applications focusing on reduced visual stress
|
|
285
277
|
*/
|
|
286
278
|
declare const pastel: PrettyTerminalTheme;
|
|
287
|
-
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/index.d.ts
|
|
288
281
|
declare function getPrettyTerminal(config?: PrettyTerminalConfig): PrettyTerminalTransport;
|
|
289
|
-
|
|
290
|
-
export {
|
|
282
|
+
//#endregion
|
|
283
|
+
export { ColorConfig, DetailedViewConfig, LogEntry, PrettyTerminalConfig, PrettyTerminalTheme, PrettyTerminalTransport, ViewConfig, chalk, getPrettyTerminal, moonlight, nature, neon, pastel, sunlight };
|
|
284
|
+
//# sourceMappingURL=index.d.cts.map
|