node-logy 0.2.2 → 0.2.4

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.d.ts CHANGED
@@ -1,267 +1,3 @@
1
- import { LogLevelType } from "./protocol.js";
2
- /**
3
- * Timestamp format options
4
- */
5
- export type TimestampType = "iso" | "locale" | "utc" | "unix" | "unix_ms" | "date" | "time" | "datetime" | "short" | "custom";
6
- /**
7
- * Options to change the logger
8
- */
9
- export type LoggerOptions = {
10
- /**
11
- * Where to store the log files output
12
- */
13
- basePath: string;
14
- /**
15
- * If this logger should save logs to log files
16
- */
17
- saveToLogFiles: boolean;
18
- /**
19
- * If this logger's logs should be printed to the stdout of the process
20
- */
21
- outputToConsole: boolean;
22
- /**
23
- * If the output to console should be colored
24
- */
25
- useColoredOutput: boolean;
26
- /**
27
- * Map of specific log level and what color to use
28
- */
29
- colorMap: Record<LogLevelType, string>;
30
- /**
31
- * If it should add timestamps to logs
32
- */
33
- showTimestamps: boolean;
34
- /**
35
- * Which timestamp format to use (only applies when showTimestamps is true)
36
- */
37
- timestampType: TimestampType;
38
- /**
39
- * Custom timestamp format string (only used when timestampType is "custom")
40
- * Use tokens: YYYY=year, MM=month, DD=day, HH=hour, mm=minute, ss=second, ms=millisecond
41
- */
42
- customTimestampFormat?: string;
43
- /**
44
- * If it should show log level
45
- */
46
- showLogLevel: boolean;
47
- /**
48
- * Map a specific log level with a string value used for it
49
- */
50
- logLevelMap: Record<LogLevelType, string>;
51
- /**
52
- * Minimum log level to process (filters out lower levels)
53
- */
54
- minLevel?: LogLevelType;
55
- /**
56
- * Maximum log level to process (filters out higher levels)
57
- */
58
- maxLevel?: LogLevelType;
59
- /**
60
- * Specific levels to include (whitelist)
61
- */
62
- includeLevels?: LogLevelType[];
63
- /**
64
- * Specific levels to exclude (blacklist)
65
- */
66
- excludeLevels?: LogLevelType[];
67
- /**
68
- * Filter function to determine if a log should be processed
69
- */
70
- filter?: (level: LogLevelType, message: any) => boolean;
71
- /**
72
- * Show where it was called at (file:line:column)
73
- */
74
- showCallSite?: boolean;
75
- /**
76
- * Addtional options to change call site log information
77
- */
78
- callSiteOptions?: {
79
- /**
80
- * If it should show a full file path or the default short name
81
- */
82
- fullFilePath?: boolean;
83
- };
84
- /**
85
- * Contains a list of addtional prefixes to add to each log for example `["foo"]`
86
- */
87
- additionalPrefixes?: string[];
88
- };
89
- /**
90
- * Custom error for logger initialization failures
91
- */
92
- export declare class LoggerInitializationError extends Error {
93
- constructor(message: string);
94
- }
95
- /**
96
- * Used to log to console and also the log files
97
- */
98
- export declare class Logger {
99
- /**
100
- * Local reference to options passed
101
- */
102
- private _options;
103
- /**
104
- * Holds the worker thread
105
- */
106
- private _worker;
107
- /**
108
- * A request's id
109
- */
110
- private _id;
111
- /**
112
- * Gets the next ID; if it exceeds 1 million then rolls back to zero
113
- */
114
- private _getNextId;
115
- /**
116
- * Holds batch of LOG requests only (fire-and-forget)
117
- */
118
- private _logBatch;
119
- /**
120
- * How long it will wait until it flushes / sends the logs to the worker
121
- */
122
- private _logRequestFlushMs;
123
- /**
124
- * Holds the timeout for log batch flushing
125
- */
126
- private _logBatchTimeout;
127
- /**
128
- * How large we want the batch array to get before we send it
129
- */
130
- private _logBatchMaxSize;
131
- /**
132
- * Holds pending requests that expect a response (FLUSH, RELOAD, SHUTDOWN)
133
- */
134
- private _pending;
135
- constructor(options?: Partial<LoggerOptions>);
136
- /**
137
- * Get the path to the worker
138
- * @returns Path to the worker
139
- */
140
- private _getWorkerPath;
141
- /**
142
- * Inits the worker thread
143
- */
144
- private _initWorker;
145
- /**
146
- * Flush the current log batch to worker immediately
147
- */
148
- private _flushLogBatch;
149
- /**
150
- * Starts the timer to flush log batch after delay
151
- */
152
- private _startLogBatchTimer;
153
- /**
154
- * Stops the log batch flush timer
155
- */
156
- private _stopLogBatchTimer;
157
- /**
158
- * Adds a LOG request to the batch (fire-and-forget)
159
- */
160
- private _addToLogBatch;
161
- /**
162
- * Clears pending requests on process exit/error
163
- */
164
- private _clearPending;
165
- /**
166
- * Handle a decoded response from worker
167
- */
168
- private _handleResponse;
169
- /**
170
- * Resolve any pending requests that expected a response
171
- */
172
- private _resolvePending;
173
- /**
174
- * Send a request that expects a response (FLUSH, RELOAD, SHUTDOWN)
175
- * These are sent immediately, not batched
176
- */
177
- private _sendControlRequest;
178
- /**
179
- * Validates the basePath option
180
- */
181
- private _validateBasePath;
182
- /**
183
- * Creates the log directory if file logging is enabled
184
- */
185
- private _initializeDirectory;
186
- /**
187
- * Extract call site information (file:line:column) from stack trace
188
- */
189
- private _getCallSite;
190
- /**
191
- * Check if a log level should be processed based on filtering rules
192
- */
193
- private _shouldLog;
194
- /**
195
- * Verifies the log directory is writable
196
- */
197
- private _verifyWritable;
198
- /**
199
- * Get the string representation of a log level
200
- */
201
- private _getLevelString;
202
- /**
203
- * Format timestamp based on the configured timestampType
204
- */
205
- private _formatTimestamp;
206
- /**
207
- * Apply custom format string to date
208
- * Tokens: YYYY=year, MM=month, DD=day, HH=hour, mm=minute, ss=second, ms=millisecond
209
- */
210
- private _applyCustomFormat;
211
- /**
212
- * Convert any value to string representation
213
- */
214
- private _stringify;
215
- /**
216
- * Format a log message with optional fields
217
- */
218
- private _formatMessage;
219
- /**
220
- * Apply color to the entire message if colored output is enabled
221
- */
222
- private _colorize;
223
- /**
224
- * Log a specific level and content
225
- * @param level The specific level to log
226
- * @param message The content of the message
227
- * @param messages Any additional messages
228
- */
229
- log(level: LogLevelType, message: any, ...messages: any[]): void;
230
- /**
231
- * Convenience method for INFO level
232
- */
233
- info(message: any, ...messages: any[]): void;
234
- /**
235
- * Convenience method for WARN level
236
- */
237
- warn(message: any, ...messages: any[]): void;
238
- /**
239
- * Convenience method for ERROR level
240
- */
241
- error(message: any, ...messages: any[]): void;
242
- /**
243
- * Convenience method for DEBUG level
244
- */
245
- debug(message: any, ...messages: any[]): void;
246
- /**
247
- * Convenience method for FATAL level
248
- */
249
- fatal(message: any, ...messages: any[]): void;
250
- /**
251
- * Flush remaining buffer to log files
252
- */
253
- flush(): Promise<void>;
254
- /**
255
- * Used to reload / refresh the process
256
- */
257
- reload(): Promise<void>;
258
- /**
259
- * Used to shut down the child process and clean up
260
- */
261
- shutdown(): Promise<void>;
262
- /**
263
- * Get current logger options (read-only copy)
264
- */
265
- get options(): Readonly<LoggerOptions>;
266
- }
1
+ export * from "./logger.js";
2
+ export * from "./protocol.js";
267
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAIb,MAAM,eAAe,CAAC;AAOvB;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,KAAK,GACL,QAAQ,GACR,KAAK,GACL,MAAM,GACN,SAAS,GACT,MAAM,GACN,MAAM,GACN,UAAU,GACV,OAAO,GACP,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAE1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAEvC;;OAEG;IACH,cAAc,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;IAE7B;;;OAGG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,EAAE,YAAY,CAAC;IAExB;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