@socketsecurity/lib 1.0.5 → 1.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/CHANGELOG.md +19 -0
- package/dist/arrays.d.ts +143 -0
- package/dist/arrays.js.map +2 -2
- package/dist/fs.d.ts +595 -23
- package/dist/fs.js.map +2 -2
- package/dist/git.d.ts +488 -41
- package/dist/git.js.map +2 -2
- package/dist/github.d.ts +361 -12
- package/dist/github.js.map +2 -2
- package/dist/http-request.d.ts +463 -4
- package/dist/http-request.js.map +2 -2
- package/dist/json.d.ts +177 -4
- package/dist/json.js.map +2 -2
- package/dist/logger.d.ts +822 -67
- package/dist/logger.js +653 -46
- package/dist/logger.js.map +2 -2
- package/dist/objects.d.ts +386 -10
- package/dist/objects.js.map +2 -2
- package/dist/path.d.ts +270 -6
- package/dist/path.js.map +2 -2
- package/dist/promises.d.ts +432 -27
- package/dist/promises.js.map +2 -2
- package/dist/spawn.d.ts +239 -12
- package/dist/spawn.js.map +2 -2
- package/dist/spinner.d.ts +260 -20
- package/dist/spinner.js +201 -63
- package/dist/spinner.js.map +2 -2
- package/dist/stdio/clear.d.ts +130 -9
- package/dist/stdio/clear.js.map +2 -2
- package/dist/stdio/divider.d.ts +106 -10
- package/dist/stdio/divider.js +10 -0
- package/dist/stdio/divider.js.map +2 -2
- package/dist/stdio/footer.d.ts +70 -3
- package/dist/stdio/footer.js.map +2 -2
- package/dist/stdio/header.d.ts +93 -12
- package/dist/stdio/header.js.map +2 -2
- package/dist/stdio/mask.d.ts +82 -14
- package/dist/stdio/mask.js +25 -4
- package/dist/stdio/mask.js.map +2 -2
- package/dist/stdio/progress.d.ts +112 -15
- package/dist/stdio/progress.js +43 -3
- package/dist/stdio/progress.js.map +2 -2
- package/dist/stdio/prompts.d.ts +95 -5
- package/dist/stdio/prompts.js.map +2 -2
- package/dist/stdio/stderr.d.ts +114 -11
- package/dist/stdio/stderr.js.map +2 -2
- package/dist/stdio/stdout.d.ts +107 -11
- package/dist/stdio/stdout.js.map +2 -2
- package/dist/strings.d.ts +357 -28
- package/dist/strings.js.map +2 -2
- package/dist/validation/json-parser.d.ts +226 -7
- package/dist/validation/json-parser.js.map +2 -2
- package/dist/validation/types.d.ts +114 -8
- package/dist/validation/types.js.map +1 -1
- package/package.json +1 -1
package/dist/logger.d.ts
CHANGED
|
@@ -1,181 +1,936 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Log symbols for terminal output with colored indicators.
|
|
3
|
+
*
|
|
4
|
+
* Each symbol provides visual feedback for different message types, with
|
|
5
|
+
* Unicode and ASCII fallback support.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { LOG_SYMBOLS } from '@socketsecurity/lib'
|
|
10
|
+
*
|
|
11
|
+
* console.log(`${LOG_SYMBOLS.success} Operation completed`)
|
|
12
|
+
* console.log(`${LOG_SYMBOLS.fail} Operation failed`)
|
|
13
|
+
* console.log(`${LOG_SYMBOLS.warn} Warning message`)
|
|
14
|
+
* console.log(`${LOG_SYMBOLS.info} Information message`)
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
2
17
|
type LogSymbols = {
|
|
18
|
+
/** Red colored failure symbol (✖ or × in ASCII) */
|
|
3
19
|
fail: string;
|
|
20
|
+
/** Blue colored information symbol (ℹ or i in ASCII) */
|
|
4
21
|
info: string;
|
|
22
|
+
/** Green colored success symbol (✔ or √ in ASCII) */
|
|
5
23
|
success: string;
|
|
24
|
+
/** Yellow colored warning symbol (⚠ or ‼ in ASCII) */
|
|
6
25
|
warn: string;
|
|
7
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Type definition for logger methods that mirror console methods.
|
|
29
|
+
*
|
|
30
|
+
* All methods return the logger instance for method chaining.
|
|
31
|
+
*/
|
|
8
32
|
type LoggerMethods = {
|
|
9
33
|
[K in keyof typeof console]: (typeof console)[K] extends (...args: infer A) => any ? (...args: A) => Logger : (typeof console)[K];
|
|
10
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* A task that can be executed with automatic start/complete logging.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const task = logger.createTask('Database migration')
|
|
41
|
+
* task.run(() => {
|
|
42
|
+
* // Migration logic here
|
|
43
|
+
* })
|
|
44
|
+
* // Logs: "Starting task: Database migration"
|
|
45
|
+
* // Logs: "Completed task: Database migration"
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
11
48
|
interface Task {
|
|
49
|
+
/**
|
|
50
|
+
* Executes the task function with automatic logging.
|
|
51
|
+
*
|
|
52
|
+
* @template T - The return type of the task function
|
|
53
|
+
* @param f - The function to execute
|
|
54
|
+
* @returns The result of the task function
|
|
55
|
+
*/
|
|
12
56
|
run<T>(f: () => T): T;
|
|
13
57
|
}
|
|
14
58
|
export type { LogSymbols, LoggerMethods, Task };
|
|
59
|
+
/**
|
|
60
|
+
* Log symbols for terminal output with colored indicators.
|
|
61
|
+
*
|
|
62
|
+
* Provides colored Unicode symbols (✔, ✖, ⚠, ℹ) with ASCII fallbacks (√, ×, ‼, i)
|
|
63
|
+
* for terminals that don't support Unicode. Symbols are color-coded: green for
|
|
64
|
+
* success, red for failure, yellow for warnings, blue for info.
|
|
65
|
+
*
|
|
66
|
+
* The symbols are lazily initialized on first access and then frozen for immutability.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* import { LOG_SYMBOLS } from '@socketsecurity/lib'
|
|
71
|
+
*
|
|
72
|
+
* console.log(`${LOG_SYMBOLS.success} Build completed`) // Green ✔
|
|
73
|
+
* console.log(`${LOG_SYMBOLS.fail} Build failed`) // Red ✖
|
|
74
|
+
* console.log(`${LOG_SYMBOLS.warn} Deprecated API used`) // Yellow ⚠
|
|
75
|
+
* console.log(`${LOG_SYMBOLS.info} Starting process`) // Blue ℹ
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
15
78
|
export declare const LOG_SYMBOLS: Record<string, string>;
|
|
79
|
+
/**
|
|
80
|
+
* Symbol for incrementing the internal log call counter.
|
|
81
|
+
*
|
|
82
|
+
* This is an internal symbol used to track the number of times logging
|
|
83
|
+
* methods have been called on a logger instance.
|
|
84
|
+
*/
|
|
16
85
|
export declare const incLogCallCountSymbol: unique symbol;
|
|
86
|
+
/**
|
|
87
|
+
* Symbol for tracking whether the last logged line was blank.
|
|
88
|
+
*
|
|
89
|
+
* This is used internally to prevent multiple consecutive blank lines
|
|
90
|
+
* and to determine whether to add spacing before certain messages.
|
|
91
|
+
*/
|
|
17
92
|
export declare const lastWasBlankSymbol: unique symbol;
|
|
18
93
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
94
|
+
* Enhanced console logger with indentation, colored symbols, and stream management.
|
|
95
|
+
*
|
|
96
|
+
* Provides a fluent API for logging with automatic indentation tracking, colored
|
|
97
|
+
* status symbols, separate stderr/stdout management, and method chaining. All
|
|
98
|
+
* methods return `this` for easy chaining.
|
|
99
|
+
*
|
|
100
|
+
* Features:
|
|
101
|
+
* - Automatic line prefixing with indentation
|
|
102
|
+
* - Colored status symbols (success, fail, warn, info)
|
|
103
|
+
* - Separate indentation tracking for stderr and stdout
|
|
104
|
+
* - Stream-bound logger instances via `.stderr` and `.stdout`
|
|
105
|
+
* - Group/indentation management
|
|
106
|
+
* - Progress indicators with clearable lines
|
|
107
|
+
* - Task execution with automatic logging
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* import { logger } from '@socketsecurity/lib'
|
|
112
|
+
*
|
|
113
|
+
* // Basic logging with symbols
|
|
114
|
+
* logger.success('Build completed')
|
|
115
|
+
* logger.fail('Build failed')
|
|
116
|
+
* logger.warn('Deprecated API')
|
|
117
|
+
* logger.info('Starting process')
|
|
118
|
+
*
|
|
119
|
+
* // Indentation and grouping
|
|
120
|
+
* logger.log('Processing files:')
|
|
121
|
+
* logger.indent()
|
|
122
|
+
* logger.log('file1.js')
|
|
123
|
+
* logger.log('file2.js')
|
|
124
|
+
* logger.dedent()
|
|
125
|
+
*
|
|
126
|
+
* // Method chaining
|
|
127
|
+
* logger
|
|
128
|
+
* .log('Step 1')
|
|
129
|
+
* .indent()
|
|
130
|
+
* .log('Substep 1.1')
|
|
131
|
+
* .log('Substep 1.2')
|
|
132
|
+
* .dedent()
|
|
133
|
+
* .log('Step 2')
|
|
134
|
+
*
|
|
135
|
+
* // Stream-specific logging
|
|
136
|
+
* logger.stdout.log('Normal output')
|
|
137
|
+
* logger.stderr.error('Error message')
|
|
138
|
+
*
|
|
139
|
+
* // Progress indicators
|
|
140
|
+
* logger.progress('Processing...')
|
|
141
|
+
* // ... do work ...
|
|
142
|
+
* logger.clearLine()
|
|
143
|
+
* logger.success('Done')
|
|
144
|
+
*
|
|
145
|
+
* // Task execution
|
|
146
|
+
* const task = logger.createTask('Migration')
|
|
147
|
+
* task.run(() => {
|
|
148
|
+
* // Migration logic
|
|
149
|
+
* })
|
|
150
|
+
* ```
|
|
21
151
|
*/
|
|
22
152
|
/*@__PURE__*/
|
|
23
153
|
export declare class Logger {
|
|
24
154
|
#private;
|
|
155
|
+
/**
|
|
156
|
+
* Static reference to log symbols for convenience.
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* console.log(`${Logger.LOG_SYMBOLS.success} Done`)
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
25
163
|
static LOG_SYMBOLS: Record<string, string>;
|
|
164
|
+
/**
|
|
165
|
+
* Creates a new Logger instance.
|
|
166
|
+
*
|
|
167
|
+
* When called without arguments, creates a logger using the default
|
|
168
|
+
* `process.stdout` and `process.stderr` streams. Can accept custom
|
|
169
|
+
* console constructor arguments for advanced use cases.
|
|
170
|
+
*
|
|
171
|
+
* @param args - Optional console constructor arguments
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* // Default logger
|
|
176
|
+
* const logger = new Logger()
|
|
177
|
+
*
|
|
178
|
+
* // Custom streams (advanced)
|
|
179
|
+
* const customLogger = new Logger({
|
|
180
|
+
* stdout: customWritableStream,
|
|
181
|
+
* stderr: customErrorStream
|
|
182
|
+
* })
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
26
185
|
constructor(...args: unknown[]);
|
|
27
186
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
187
|
+
* Gets a logger instance bound exclusively to stderr.
|
|
188
|
+
*
|
|
189
|
+
* All logging operations on this instance will write to stderr only.
|
|
190
|
+
* Indentation is tracked separately from stdout. The instance is
|
|
191
|
+
* cached and reused on subsequent accesses.
|
|
192
|
+
*
|
|
193
|
+
* @returns A logger instance bound to stderr
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* // Write errors to stderr
|
|
198
|
+
* logger.stderr.error('Configuration invalid')
|
|
199
|
+
* logger.stderr.warn('Using fallback settings')
|
|
200
|
+
*
|
|
201
|
+
* // Indent only affects stderr
|
|
202
|
+
* logger.stderr.indent()
|
|
203
|
+
* logger.stderr.error('Nested error details')
|
|
204
|
+
* logger.stderr.dedent()
|
|
205
|
+
* ```
|
|
30
206
|
*/
|
|
31
207
|
get stderr(): Logger;
|
|
32
208
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
209
|
+
* Gets a logger instance bound exclusively to stdout.
|
|
210
|
+
*
|
|
211
|
+
* All logging operations on this instance will write to stdout only.
|
|
212
|
+
* Indentation is tracked separately from stderr. The instance is
|
|
213
|
+
* cached and reused on subsequent accesses.
|
|
214
|
+
*
|
|
215
|
+
* @returns A logger instance bound to stdout
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* // Write normal output to stdout
|
|
220
|
+
* logger.stdout.log('Processing started')
|
|
221
|
+
* logger.stdout.log('Items processed: 42')
|
|
222
|
+
*
|
|
223
|
+
* // Indent only affects stdout
|
|
224
|
+
* logger.stdout.indent()
|
|
225
|
+
* logger.stdout.log('Detailed output')
|
|
226
|
+
* logger.stdout.dedent()
|
|
227
|
+
* ```
|
|
35
228
|
*/
|
|
36
229
|
get stdout(): Logger;
|
|
37
230
|
/**
|
|
38
|
-
*
|
|
231
|
+
* Gets the total number of log calls made on this logger instance.
|
|
232
|
+
*
|
|
233
|
+
* Tracks all logging method calls including `log()`, `error()`, `warn()`,
|
|
234
|
+
* `success()`, `fail()`, etc. Useful for testing and monitoring logging activity.
|
|
235
|
+
*
|
|
236
|
+
* @returns The number of times logging methods have been called
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* logger.log('Message 1')
|
|
241
|
+
* logger.error('Message 2')
|
|
242
|
+
* console.log(logger.logCallCount) // 2
|
|
243
|
+
* ```
|
|
39
244
|
*/
|
|
40
245
|
get logCallCount(): number;
|
|
41
246
|
/**
|
|
42
|
-
*
|
|
247
|
+
* Increments the internal log call counter.
|
|
248
|
+
*
|
|
249
|
+
* This is called automatically by logging methods and should not
|
|
250
|
+
* be called directly in normal usage.
|
|
251
|
+
*
|
|
252
|
+
* @returns The logger instance for chaining
|
|
43
253
|
*/
|
|
44
254
|
[incLogCallCountSymbol](): this;
|
|
45
255
|
/**
|
|
46
|
-
*
|
|
256
|
+
* Sets whether the last logged line was blank.
|
|
257
|
+
*
|
|
258
|
+
* Used internally to track blank lines and prevent duplicate spacing.
|
|
259
|
+
* This is called automatically by logging methods.
|
|
260
|
+
*
|
|
261
|
+
* @param value - Whether the last line was blank
|
|
262
|
+
* @returns The logger instance for chaining
|
|
47
263
|
*/
|
|
48
264
|
[lastWasBlankSymbol](value: unknown): this;
|
|
49
265
|
/**
|
|
50
|
-
*
|
|
266
|
+
* Logs an assertion failure message if the value is falsy.
|
|
267
|
+
*
|
|
268
|
+
* Works like `console.assert()` but returns the logger for chaining.
|
|
269
|
+
* If the value is truthy, nothing is logged. If falsy, logs an error
|
|
270
|
+
* message with an assertion failure.
|
|
271
|
+
*
|
|
272
|
+
* @param value - The value to test
|
|
273
|
+
* @param message - Optional message and additional arguments to log
|
|
274
|
+
* @returns The logger instance for chaining
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* logger.assert(true, 'This will not log')
|
|
279
|
+
* logger.assert(false, 'Assertion failed: value is false')
|
|
280
|
+
* logger.assert(items.length > 0, 'No items found')
|
|
281
|
+
* ```
|
|
51
282
|
*/
|
|
52
283
|
assert(value: unknown, ...message: unknown[]): this;
|
|
53
284
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
285
|
+
* Clears the visible terminal screen.
|
|
286
|
+
*
|
|
287
|
+
* Only available on the main logger instance, not on stream-bound instances
|
|
288
|
+
* (`.stderr` or `.stdout`). Resets the log call count and blank line tracking
|
|
289
|
+
* if the output is a TTY.
|
|
290
|
+
*
|
|
291
|
+
* @returns The logger instance for chaining
|
|
292
|
+
* @throws {Error} If called on a stream-bound logger instance
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```typescript
|
|
296
|
+
* logger.log('Some output')
|
|
297
|
+
* logger.clearVisible() // Screen is now clear
|
|
298
|
+
*
|
|
299
|
+
* // Error: Can't call on stream-bound instance
|
|
300
|
+
* logger.stderr.clearVisible() // throws
|
|
301
|
+
* ```
|
|
56
302
|
*/
|
|
57
303
|
clearVisible(): this;
|
|
58
304
|
/**
|
|
59
|
-
*
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*
|
|
305
|
+
* Increments and logs a counter for the given label.
|
|
306
|
+
*
|
|
307
|
+
* Each unique label maintains its own counter. Works like `console.count()`.
|
|
308
|
+
*
|
|
309
|
+
* @param label - Optional label for the counter
|
|
310
|
+
* @default 'default'
|
|
311
|
+
* @returns The logger instance for chaining
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```typescript
|
|
315
|
+
* logger.count('requests') // requests: 1
|
|
316
|
+
* logger.count('requests') // requests: 2
|
|
317
|
+
* logger.count('errors') // errors: 1
|
|
318
|
+
* logger.count() // default: 1
|
|
319
|
+
* ```
|
|
320
|
+
*/
|
|
321
|
+
count(label?: string | undefined): this;
|
|
322
|
+
/**
|
|
323
|
+
* Creates a task that logs start and completion messages automatically.
|
|
324
|
+
*
|
|
325
|
+
* Returns a task object with a `run()` method that executes the provided
|
|
326
|
+
* function and logs "Starting task: {name}" before execution and
|
|
327
|
+
* "Completed task: {name}" after completion.
|
|
328
|
+
*
|
|
329
|
+
* @param name - The name of the task
|
|
330
|
+
* @returns A task object with a `run()` method
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```typescript
|
|
334
|
+
* const task = logger.createTask('Database Migration')
|
|
335
|
+
* const result = task.run(() => {
|
|
336
|
+
* // Logs: "Starting task: Database Migration"
|
|
337
|
+
* migrateDatabase()
|
|
338
|
+
* return 'success'
|
|
339
|
+
* // Logs: "Completed task: Database Migration"
|
|
340
|
+
* })
|
|
341
|
+
* console.log(result) // 'success'
|
|
342
|
+
* ```
|
|
64
343
|
*/
|
|
65
344
|
createTask(name: string): Task;
|
|
66
345
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
346
|
+
* Decreases the indentation level by removing spaces from the prefix.
|
|
347
|
+
*
|
|
348
|
+
* When called on the main logger, affects both stderr and stdout indentation.
|
|
349
|
+
* When called on a stream-bound logger (`.stderr` or `.stdout`), affects
|
|
350
|
+
* only that stream's indentation.
|
|
351
|
+
*
|
|
352
|
+
* @param spaces - Number of spaces to remove from indentation
|
|
353
|
+
* @default 2
|
|
354
|
+
* @returns The logger instance for chaining
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* ```typescript
|
|
358
|
+
* logger.indent()
|
|
359
|
+
* logger.log('Indented')
|
|
360
|
+
* logger.dedent()
|
|
361
|
+
* logger.log('Back to normal')
|
|
362
|
+
*
|
|
363
|
+
* // Remove custom amount
|
|
364
|
+
* logger.indent(4)
|
|
365
|
+
* logger.log('Four spaces')
|
|
366
|
+
* logger.dedent(4)
|
|
367
|
+
*
|
|
368
|
+
* // Stream-specific dedent
|
|
369
|
+
* logger.stdout.indent()
|
|
370
|
+
* logger.stdout.log('Indented stdout')
|
|
371
|
+
* logger.stdout.dedent()
|
|
372
|
+
* ```
|
|
70
373
|
*/
|
|
71
374
|
dedent(spaces?: number): this;
|
|
72
375
|
/**
|
|
73
|
-
*
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
376
|
+
* Displays an object's properties in a formatted way.
|
|
377
|
+
*
|
|
378
|
+
* Works like `console.dir()` with customizable options for depth,
|
|
379
|
+
* colors, etc. Useful for inspecting complex objects.
|
|
380
|
+
*
|
|
381
|
+
* @param obj - The object to display
|
|
382
|
+
* @param options - Optional formatting options (Node.js inspect options)
|
|
383
|
+
* @returns The logger instance for chaining
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* ```typescript
|
|
387
|
+
* const obj = { a: 1, b: { c: 2, d: { e: 3 } } }
|
|
388
|
+
* logger.dir(obj)
|
|
389
|
+
* logger.dir(obj, { depth: 1 }) // Limit nesting depth
|
|
390
|
+
* logger.dir(obj, { colors: true }) // Enable colors
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
dir(obj: unknown, options?: unknown | undefined): this;
|
|
394
|
+
/**
|
|
395
|
+
* Displays data as XML/HTML in a formatted way.
|
|
396
|
+
*
|
|
397
|
+
* Works like `console.dirxml()`. In Node.js, behaves the same as `dir()`.
|
|
398
|
+
*
|
|
399
|
+
* @param data - The data to display
|
|
400
|
+
* @returns The logger instance for chaining
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```typescript
|
|
404
|
+
* logger.dirxml(document.body) // In browser environments
|
|
405
|
+
* logger.dirxml(xmlObject) // In Node.js
|
|
406
|
+
* ```
|
|
78
407
|
*/
|
|
79
408
|
dirxml(...data: unknown[]): this;
|
|
80
409
|
/**
|
|
81
|
-
*
|
|
410
|
+
* Logs an error message to stderr.
|
|
411
|
+
*
|
|
412
|
+
* Automatically applies current indentation. All arguments are formatted
|
|
413
|
+
* and logged like `console.error()`.
|
|
414
|
+
*
|
|
415
|
+
* @param args - Message and additional arguments to log
|
|
416
|
+
* @returns The logger instance for chaining
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```typescript
|
|
420
|
+
* logger.error('Build failed')
|
|
421
|
+
* logger.error('Error code:', 500)
|
|
422
|
+
* logger.error('Details:', { message: 'Not found' })
|
|
423
|
+
* ```
|
|
82
424
|
*/
|
|
83
425
|
error(...args: unknown[]): this;
|
|
84
426
|
/**
|
|
85
|
-
*
|
|
427
|
+
* Logs a newline to stderr only if the last line wasn't already blank.
|
|
428
|
+
*
|
|
429
|
+
* Prevents multiple consecutive blank lines. Useful for adding spacing
|
|
430
|
+
* between sections without creating excessive whitespace.
|
|
431
|
+
*
|
|
432
|
+
* @returns The logger instance for chaining
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```typescript
|
|
436
|
+
* logger.error('Error message')
|
|
437
|
+
* logger.errorNewline() // Adds blank line
|
|
438
|
+
* logger.errorNewline() // Does nothing (already blank)
|
|
439
|
+
* logger.error('Next section')
|
|
440
|
+
* ```
|
|
86
441
|
*/
|
|
87
442
|
errorNewline(): this;
|
|
88
443
|
/**
|
|
89
|
-
*
|
|
444
|
+
* Logs a failure message with a red colored fail symbol.
|
|
445
|
+
*
|
|
446
|
+
* Automatically prefixes the message with `LOG_SYMBOLS.fail` (red ✖).
|
|
447
|
+
* Always outputs to stderr. If the message starts with an existing
|
|
448
|
+
* symbol, it will be stripped and replaced.
|
|
449
|
+
*
|
|
450
|
+
* @param args - Message and additional arguments to log
|
|
451
|
+
* @returns The logger instance for chaining
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```typescript
|
|
455
|
+
* logger.fail('Build failed')
|
|
456
|
+
* logger.fail('Test suite failed:', { passed: 5, failed: 3 })
|
|
457
|
+
* ```
|
|
90
458
|
*/
|
|
91
459
|
fail(...args: unknown[]): this;
|
|
92
460
|
/**
|
|
93
|
-
*
|
|
461
|
+
* Starts a new indented log group.
|
|
462
|
+
*
|
|
463
|
+
* If a label is provided, it's logged before increasing indentation.
|
|
464
|
+
* Groups can be nested. Each group increases indentation by the
|
|
465
|
+
* `kGroupIndentWidth` (default 2 spaces). Call `groupEnd()` to close.
|
|
466
|
+
*
|
|
467
|
+
* @param label - Optional label to display before the group
|
|
468
|
+
* @returns The logger instance for chaining
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* ```typescript
|
|
472
|
+
* logger.group('Processing files:')
|
|
473
|
+
* logger.log('file1.js')
|
|
474
|
+
* logger.log('file2.js')
|
|
475
|
+
* logger.groupEnd()
|
|
476
|
+
*
|
|
477
|
+
* // Nested groups
|
|
478
|
+
* logger.group('Outer')
|
|
479
|
+
* logger.log('Outer content')
|
|
480
|
+
* logger.group('Inner')
|
|
481
|
+
* logger.log('Inner content')
|
|
482
|
+
* logger.groupEnd()
|
|
483
|
+
* logger.groupEnd()
|
|
484
|
+
* ```
|
|
94
485
|
*/
|
|
95
486
|
group(...label: unknown[]): this;
|
|
96
487
|
/**
|
|
97
|
-
*
|
|
488
|
+
* Starts a new collapsed log group (alias for `group()`).
|
|
489
|
+
*
|
|
490
|
+
* In browser consoles, this creates a collapsed group. In Node.js,
|
|
491
|
+
* it behaves identically to `group()`.
|
|
492
|
+
*
|
|
493
|
+
* @param label - Optional label to display before the group
|
|
494
|
+
* @returns The logger instance for chaining
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```typescript
|
|
498
|
+
* logger.groupCollapsed('Details')
|
|
499
|
+
* logger.log('Hidden by default in browsers')
|
|
500
|
+
* logger.groupEnd()
|
|
501
|
+
* ```
|
|
98
502
|
*/
|
|
99
503
|
// groupCollapsed is an alias of group.
|
|
100
504
|
// https://nodejs.org/api/console.html#consolegroupcollapsed
|
|
101
505
|
groupCollapsed(...label: unknown[]): this;
|
|
102
506
|
/**
|
|
103
|
-
*
|
|
507
|
+
* Ends the current log group and decreases indentation.
|
|
508
|
+
*
|
|
509
|
+
* Must be called once for each `group()` or `groupCollapsed()` call
|
|
510
|
+
* to properly close the group and restore indentation.
|
|
511
|
+
*
|
|
512
|
+
* @returns The logger instance for chaining
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```typescript
|
|
516
|
+
* logger.group('Group 1')
|
|
517
|
+
* logger.log('Content')
|
|
518
|
+
* logger.groupEnd() // Closes 'Group 1'
|
|
519
|
+
* ```
|
|
104
520
|
*/
|
|
105
521
|
groupEnd(): this;
|
|
106
522
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
523
|
+
* Increases the indentation level by adding spaces to the prefix.
|
|
524
|
+
*
|
|
525
|
+
* When called on the main logger, affects both stderr and stdout indentation.
|
|
526
|
+
* When called on a stream-bound logger (`.stderr` or `.stdout`), affects
|
|
527
|
+
* only that stream's indentation. Maximum indentation is 1000 spaces.
|
|
528
|
+
*
|
|
529
|
+
* @param spaces - Number of spaces to add to indentation
|
|
530
|
+
* @default 2
|
|
531
|
+
* @returns The logger instance for chaining
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```typescript
|
|
535
|
+
* logger.log('Level 0')
|
|
536
|
+
* logger.indent()
|
|
537
|
+
* logger.log('Level 1')
|
|
538
|
+
* logger.indent()
|
|
539
|
+
* logger.log('Level 2')
|
|
540
|
+
* logger.dedent()
|
|
541
|
+
* logger.dedent()
|
|
542
|
+
*
|
|
543
|
+
* // Custom indent amount
|
|
544
|
+
* logger.indent(4)
|
|
545
|
+
* logger.log('Indented 4 spaces')
|
|
546
|
+
* logger.dedent(4)
|
|
547
|
+
*
|
|
548
|
+
* // Stream-specific indent
|
|
549
|
+
* logger.stdout.indent()
|
|
550
|
+
* logger.stdout.log('Only stdout is indented')
|
|
551
|
+
* ```
|
|
110
552
|
*/
|
|
111
553
|
indent(spaces?: number): this;
|
|
112
554
|
/**
|
|
113
|
-
*
|
|
555
|
+
* Logs an informational message with a blue colored info symbol.
|
|
556
|
+
*
|
|
557
|
+
* Automatically prefixes the message with `LOG_SYMBOLS.info` (blue ℹ).
|
|
558
|
+
* Always outputs to stderr. If the message starts with an existing
|
|
559
|
+
* symbol, it will be stripped and replaced.
|
|
560
|
+
*
|
|
561
|
+
* @param args - Message and additional arguments to log
|
|
562
|
+
* @returns The logger instance for chaining
|
|
563
|
+
*
|
|
564
|
+
* @example
|
|
565
|
+
* ```typescript
|
|
566
|
+
* logger.info('Starting build process')
|
|
567
|
+
* logger.info('Configuration loaded:', config)
|
|
568
|
+
* logger.info('Using cache directory:', cacheDir)
|
|
569
|
+
* ```
|
|
114
570
|
*/
|
|
115
571
|
info(...args: unknown[]): this;
|
|
116
572
|
/**
|
|
117
|
-
*
|
|
573
|
+
* Logs a message to stdout.
|
|
574
|
+
*
|
|
575
|
+
* Automatically applies current indentation. All arguments are formatted
|
|
576
|
+
* and logged like `console.log()`. This is the primary method for
|
|
577
|
+
* standard output.
|
|
578
|
+
*
|
|
579
|
+
* @param args - Message and additional arguments to log
|
|
580
|
+
* @returns The logger instance for chaining
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* ```typescript
|
|
584
|
+
* logger.log('Processing complete')
|
|
585
|
+
* logger.log('Items processed:', 42)
|
|
586
|
+
* logger.log('Results:', { success: true, count: 10 })
|
|
587
|
+
*
|
|
588
|
+
* // Method chaining
|
|
589
|
+
* logger.log('Step 1').log('Step 2').log('Step 3')
|
|
590
|
+
* ```
|
|
118
591
|
*/
|
|
119
592
|
log(...args: unknown[]): this;
|
|
120
593
|
/**
|
|
121
|
-
*
|
|
594
|
+
* Logs a newline to stdout only if the last line wasn't already blank.
|
|
595
|
+
*
|
|
596
|
+
* Prevents multiple consecutive blank lines. Useful for adding spacing
|
|
597
|
+
* between sections without creating excessive whitespace.
|
|
598
|
+
*
|
|
599
|
+
* @returns The logger instance for chaining
|
|
600
|
+
*
|
|
601
|
+
* @example
|
|
602
|
+
* ```typescript
|
|
603
|
+
* logger.log('Section 1')
|
|
604
|
+
* logger.logNewline() // Adds blank line
|
|
605
|
+
* logger.logNewline() // Does nothing (already blank)
|
|
606
|
+
* logger.log('Section 2')
|
|
607
|
+
* ```
|
|
122
608
|
*/
|
|
123
609
|
logNewline(): this;
|
|
124
610
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
611
|
+
* Resets all indentation to zero.
|
|
612
|
+
*
|
|
613
|
+
* When called on the main logger, resets both stderr and stdout indentation.
|
|
614
|
+
* When called on a stream-bound logger (`.stderr` or `.stdout`), resets
|
|
615
|
+
* only that stream's indentation.
|
|
616
|
+
*
|
|
617
|
+
* @returns The logger instance for chaining
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* ```typescript
|
|
621
|
+
* logger.indent().indent().indent()
|
|
622
|
+
* logger.log('Very indented')
|
|
623
|
+
* logger.resetIndent()
|
|
624
|
+
* logger.log('Back to zero indentation')
|
|
625
|
+
*
|
|
626
|
+
* // Reset only stdout
|
|
627
|
+
* logger.stdout.resetIndent()
|
|
628
|
+
* ```
|
|
128
629
|
*/
|
|
129
630
|
resetIndent(): this;
|
|
130
631
|
/**
|
|
131
|
-
*
|
|
632
|
+
* Logs a main step message with a blank line before it (stateless).
|
|
633
|
+
*
|
|
634
|
+
* Automatically adds a blank line before the message unless the last
|
|
635
|
+
* line was already blank. Useful for marking major steps in a process
|
|
636
|
+
* with clear visual separation.
|
|
637
|
+
*
|
|
638
|
+
* @param msg - The step message to log
|
|
639
|
+
* @param extras - Additional arguments to log
|
|
640
|
+
* @returns The logger instance for chaining
|
|
641
|
+
*
|
|
642
|
+
* @example
|
|
643
|
+
* ```typescript
|
|
644
|
+
* logger.step('Building project')
|
|
645
|
+
* logger.log('Compiling TypeScript...')
|
|
646
|
+
* logger.step('Running tests')
|
|
647
|
+
* logger.log('Running test suite...')
|
|
648
|
+
* // Output:
|
|
649
|
+
* // [blank line]
|
|
650
|
+
* // Building project
|
|
651
|
+
* // Compiling TypeScript...
|
|
652
|
+
* // [blank line]
|
|
653
|
+
* // Running tests
|
|
654
|
+
* // Running test suite...
|
|
655
|
+
* ```
|
|
132
656
|
*/
|
|
133
657
|
step(msg: string, ...extras: unknown[]): this;
|
|
134
658
|
/**
|
|
135
|
-
*
|
|
659
|
+
* Logs an indented substep message (stateless).
|
|
660
|
+
*
|
|
661
|
+
* Adds a 2-space indent to the message without affecting the logger's
|
|
662
|
+
* indentation state. Useful for showing sub-items under a main step.
|
|
663
|
+
*
|
|
664
|
+
* @param msg - The substep message to log
|
|
665
|
+
* @param extras - Additional arguments to log
|
|
666
|
+
* @returns The logger instance for chaining
|
|
667
|
+
*
|
|
668
|
+
* @example
|
|
669
|
+
* ```typescript
|
|
670
|
+
* logger.log('Installing dependencies:')
|
|
671
|
+
* logger.substep('Installing react')
|
|
672
|
+
* logger.substep('Installing typescript')
|
|
673
|
+
* logger.substep('Installing eslint')
|
|
674
|
+
* // Output:
|
|
675
|
+
* // Installing dependencies:
|
|
676
|
+
* // Installing react
|
|
677
|
+
* // Installing typescript
|
|
678
|
+
* // Installing eslint
|
|
679
|
+
* ```
|
|
136
680
|
*/
|
|
137
681
|
substep(msg: string, ...extras: unknown[]): this;
|
|
138
682
|
/**
|
|
139
|
-
*
|
|
683
|
+
* Logs a success message with a green colored success symbol.
|
|
684
|
+
*
|
|
685
|
+
* Automatically prefixes the message with `LOG_SYMBOLS.success` (green ✔).
|
|
686
|
+
* Always outputs to stderr. If the message starts with an existing
|
|
687
|
+
* symbol, it will be stripped and replaced.
|
|
688
|
+
*
|
|
689
|
+
* @param args - Message and additional arguments to log
|
|
690
|
+
* @returns The logger instance for chaining
|
|
691
|
+
*
|
|
692
|
+
* @example
|
|
693
|
+
* ```typescript
|
|
694
|
+
* logger.success('Build completed')
|
|
695
|
+
* logger.success('Tests passed:', { total: 42, passed: 42 })
|
|
696
|
+
* logger.success('Deployment successful')
|
|
697
|
+
* ```
|
|
140
698
|
*/
|
|
141
699
|
success(...args: unknown[]): this;
|
|
142
700
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
701
|
+
* Logs a completion message with a success symbol (alias for `success()`).
|
|
702
|
+
*
|
|
703
|
+
* Provides semantic clarity when marking something as "done". Does NOT
|
|
704
|
+
* automatically clear the current line - call `clearLine()` first if
|
|
705
|
+
* needed after using `progress()`.
|
|
706
|
+
*
|
|
707
|
+
* @param args - Message and additional arguments to log
|
|
708
|
+
* @returns The logger instance for chaining
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
* ```typescript
|
|
712
|
+
* logger.done('Task completed')
|
|
713
|
+
*
|
|
714
|
+
* // After progress indicator
|
|
715
|
+
* logger.progress('Processing...')
|
|
716
|
+
* // ... do work ...
|
|
717
|
+
* logger.clearLine()
|
|
718
|
+
* logger.done('Processing complete')
|
|
719
|
+
* ```
|
|
145
720
|
*/
|
|
146
721
|
done(...args: unknown[]): this;
|
|
147
722
|
/**
|
|
148
|
-
*
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
*
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
*
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
*
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
*
|
|
723
|
+
* Displays data in a table format.
|
|
724
|
+
*
|
|
725
|
+
* Works like `console.table()`. Accepts arrays of objects or
|
|
726
|
+
* objects with nested objects. Optionally specify which properties
|
|
727
|
+
* to include in the table.
|
|
728
|
+
*
|
|
729
|
+
* @param tabularData - The data to display as a table
|
|
730
|
+
* @param properties - Optional array of property names to include
|
|
731
|
+
* @returns The logger instance for chaining
|
|
732
|
+
*
|
|
733
|
+
* @example
|
|
734
|
+
* ```typescript
|
|
735
|
+
* // Array of objects
|
|
736
|
+
* logger.table([
|
|
737
|
+
* { name: 'Alice', age: 30 },
|
|
738
|
+
* { name: 'Bob', age: 25 }
|
|
739
|
+
* ])
|
|
740
|
+
*
|
|
741
|
+
* // Specify properties to show
|
|
742
|
+
* logger.table(users, ['name', 'email'])
|
|
743
|
+
*
|
|
744
|
+
* // Object with nested objects
|
|
745
|
+
* logger.table({
|
|
746
|
+
* user1: { name: 'Alice', age: 30 },
|
|
747
|
+
* user2: { name: 'Bob', age: 25 }
|
|
748
|
+
* })
|
|
749
|
+
* ```
|
|
750
|
+
*/
|
|
751
|
+
table(tabularData: unknown, properties?: readonly string[] | undefined): this;
|
|
752
|
+
/**
|
|
753
|
+
* Ends a timer and logs the elapsed time.
|
|
754
|
+
*
|
|
755
|
+
* Logs the duration since `console.time()` was called with the same
|
|
756
|
+
* label. The timer is stopped and removed.
|
|
757
|
+
*
|
|
758
|
+
* @param label - Optional label for the timer
|
|
759
|
+
* @default 'default'
|
|
760
|
+
* @returns The logger instance for chaining
|
|
761
|
+
*
|
|
762
|
+
* @example
|
|
763
|
+
* ```typescript
|
|
764
|
+
* console.time('operation')
|
|
765
|
+
* // ... do work ...
|
|
766
|
+
* logger.timeEnd('operation')
|
|
767
|
+
* // Logs: "operation: 123.456ms"
|
|
768
|
+
*
|
|
769
|
+
* console.time()
|
|
770
|
+
* // ... do work ...
|
|
771
|
+
* logger.timeEnd()
|
|
772
|
+
* // Logs: "default: 123.456ms"
|
|
773
|
+
* ```
|
|
774
|
+
*/
|
|
775
|
+
timeEnd(label?: string | undefined): this;
|
|
776
|
+
/**
|
|
777
|
+
* Logs the current value of a timer without stopping it.
|
|
778
|
+
*
|
|
779
|
+
* Logs the duration since `console.time()` was called with the same
|
|
780
|
+
* label, but keeps the timer running. Can include additional data
|
|
781
|
+
* to log alongside the time.
|
|
782
|
+
*
|
|
783
|
+
* @param label - Optional label for the timer
|
|
784
|
+
* @param data - Additional data to log with the time
|
|
785
|
+
* @default 'default'
|
|
786
|
+
* @returns The logger instance for chaining
|
|
787
|
+
*
|
|
788
|
+
* @example
|
|
789
|
+
* ```typescript
|
|
790
|
+
* console.time('process')
|
|
791
|
+
* // ... partial work ...
|
|
792
|
+
* logger.timeLog('process', 'Checkpoint 1')
|
|
793
|
+
* // Logs: "process: 123.456ms Checkpoint 1"
|
|
794
|
+
* // ... more work ...
|
|
795
|
+
* logger.timeLog('process', 'Checkpoint 2')
|
|
796
|
+
* // Logs: "process: 234.567ms Checkpoint 2"
|
|
797
|
+
* console.timeEnd('process')
|
|
798
|
+
* ```
|
|
799
|
+
*/
|
|
800
|
+
timeLog(label?: string | undefined, ...data: unknown[]): this;
|
|
801
|
+
/**
|
|
802
|
+
* Logs a stack trace to the console.
|
|
803
|
+
*
|
|
804
|
+
* Works like `console.trace()`. Shows the call stack leading to
|
|
805
|
+
* where this method was called. Useful for debugging.
|
|
806
|
+
*
|
|
807
|
+
* @param message - Optional message to display with the trace
|
|
808
|
+
* @param args - Additional arguments to log
|
|
809
|
+
* @returns The logger instance for chaining
|
|
810
|
+
*
|
|
811
|
+
* @example
|
|
812
|
+
* ```typescript
|
|
813
|
+
* function debugFunction() {
|
|
814
|
+
* logger.trace('Debug point reached')
|
|
815
|
+
* }
|
|
816
|
+
*
|
|
817
|
+
* logger.trace('Trace from here')
|
|
818
|
+
* logger.trace('Error context:', { userId: 123 })
|
|
819
|
+
* ```
|
|
820
|
+
*/
|
|
821
|
+
trace(message?: unknown | undefined, ...args: unknown[]): this;
|
|
822
|
+
/**
|
|
823
|
+
* Logs a warning message with a yellow colored warning symbol.
|
|
824
|
+
*
|
|
825
|
+
* Automatically prefixes the message with `LOG_SYMBOLS.warn` (yellow ⚠).
|
|
826
|
+
* Always outputs to stderr. If the message starts with an existing
|
|
827
|
+
* symbol, it will be stripped and replaced.
|
|
828
|
+
*
|
|
829
|
+
* @param args - Message and additional arguments to log
|
|
830
|
+
* @returns The logger instance for chaining
|
|
831
|
+
*
|
|
832
|
+
* @example
|
|
833
|
+
* ```typescript
|
|
834
|
+
* logger.warn('Deprecated API used')
|
|
835
|
+
* logger.warn('Low memory:', { available: '100MB' })
|
|
836
|
+
* logger.warn('Missing optional configuration')
|
|
837
|
+
* ```
|
|
165
838
|
*/
|
|
166
839
|
warn(...args: unknown[]): this;
|
|
167
840
|
/**
|
|
168
|
-
*
|
|
841
|
+
* Writes text directly to stdout without a newline or indentation.
|
|
842
|
+
*
|
|
843
|
+
* Useful for progress indicators or custom formatting where you need
|
|
844
|
+
* low-level control. Does not apply any indentation or formatting.
|
|
845
|
+
*
|
|
846
|
+
* @param text - The text to write
|
|
847
|
+
* @returns The logger instance for chaining
|
|
848
|
+
*
|
|
849
|
+
* @example
|
|
850
|
+
* ```typescript
|
|
851
|
+
* logger.write('Processing... ')
|
|
852
|
+
* // ... do work ...
|
|
853
|
+
* logger.write('done\n')
|
|
854
|
+
*
|
|
855
|
+
* // Build a line incrementally
|
|
856
|
+
* logger.write('Step 1')
|
|
857
|
+
* logger.write('... Step 2')
|
|
858
|
+
* logger.write('... Step 3\n')
|
|
859
|
+
* ```
|
|
169
860
|
*/
|
|
170
861
|
write(text: string): this;
|
|
171
862
|
/**
|
|
172
|
-
*
|
|
173
|
-
*
|
|
863
|
+
* Shows a progress indicator that can be cleared with `clearLine()`.
|
|
864
|
+
*
|
|
865
|
+
* Displays a simple status message with a '∴' prefix. Does not include
|
|
866
|
+
* animation or spinner. Intended to be cleared once the operation completes.
|
|
867
|
+
* The output stream (stderr or stdout) depends on whether the logger is
|
|
868
|
+
* stream-bound.
|
|
869
|
+
*
|
|
870
|
+
* @param text - The progress message to display
|
|
871
|
+
* @returns The logger instance for chaining
|
|
872
|
+
*
|
|
873
|
+
* @example
|
|
874
|
+
* ```typescript
|
|
875
|
+
* logger.progress('Processing files...')
|
|
876
|
+
* // ... do work ...
|
|
877
|
+
* logger.clearLine()
|
|
878
|
+
* logger.success('Files processed')
|
|
879
|
+
*
|
|
880
|
+
* // Stream-specific progress
|
|
881
|
+
* logger.stdout.progress('Loading...')
|
|
882
|
+
* // ... do work ...
|
|
883
|
+
* logger.stdout.clearLine()
|
|
884
|
+
* logger.stdout.log('Done')
|
|
885
|
+
* ```
|
|
174
886
|
*/
|
|
175
887
|
progress(text: string): this;
|
|
176
888
|
/**
|
|
177
|
-
*
|
|
889
|
+
* Clears the current line in the terminal.
|
|
890
|
+
*
|
|
891
|
+
* Moves the cursor to the beginning of the line and clears all content.
|
|
892
|
+
* Works in both TTY and non-TTY environments. Useful for clearing
|
|
893
|
+
* progress indicators created with `progress()`.
|
|
894
|
+
*
|
|
895
|
+
* The stream to clear (stderr or stdout) depends on whether the logger
|
|
896
|
+
* is stream-bound.
|
|
897
|
+
*
|
|
898
|
+
* @returns The logger instance for chaining
|
|
899
|
+
*
|
|
900
|
+
* @example
|
|
901
|
+
* ```typescript
|
|
902
|
+
* logger.progress('Loading...')
|
|
903
|
+
* // ... do work ...
|
|
904
|
+
* logger.clearLine()
|
|
905
|
+
* logger.success('Loaded')
|
|
906
|
+
*
|
|
907
|
+
* // Clear multiple progress updates
|
|
908
|
+
* for (const file of files) {
|
|
909
|
+
* logger.progress(`Processing ${file}`)
|
|
910
|
+
* processFile(file)
|
|
911
|
+
* logger.clearLine()
|
|
912
|
+
* }
|
|
913
|
+
* logger.success('All files processed')
|
|
914
|
+
* ```
|
|
178
915
|
*/
|
|
179
916
|
clearLine(): this;
|
|
180
917
|
}
|
|
918
|
+
/**
|
|
919
|
+
* Default logger instance for the application.
|
|
920
|
+
*
|
|
921
|
+
* A pre-configured `Logger` instance that uses the standard `process.stdout`
|
|
922
|
+
* and `process.stderr` streams. This is the recommended logger to import
|
|
923
|
+
* and use throughout your application.
|
|
924
|
+
*
|
|
925
|
+
* @example
|
|
926
|
+
* ```typescript
|
|
927
|
+
* import { logger } from '@socketsecurity/lib'
|
|
928
|
+
*
|
|
929
|
+
* logger.log('Application started')
|
|
930
|
+
* logger.success('Configuration loaded')
|
|
931
|
+
* logger.indent()
|
|
932
|
+
* logger.log('Using port 3000')
|
|
933
|
+
* logger.dedent()
|
|
934
|
+
* ```
|
|
935
|
+
*/
|
|
181
936
|
export declare const logger: Logger;
|