@gesslar/toolkit 3.19.0 → 3.20.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/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "gesslar",
6
6
  "url": "https://gesslar.dev"
7
7
  },
8
- "version": "3.19.0",
8
+ "version": "3.20.0",
9
9
  "license": "Unlicense",
10
10
  "homepage": "https://github.com/gesslar/toolkit#readme",
11
11
  "repository": {
@@ -1,4 +1,5 @@
1
1
  import Tantrum from "./Tantrum.js"
2
+ import Valid from "./Valid.js"
2
3
 
3
4
  /**
4
5
  * Utility class providing helper functions for working with Promises,
@@ -13,9 +14,24 @@ export default class Promised {
13
14
  * @returns {Promise<Array<unknown>>} Results of all promises
14
15
  */
15
16
  static async await(promises) {
17
+ Valid.type(promises, "Promise[]")
18
+
16
19
  return await Promise.all(promises)
17
20
  }
18
21
 
22
+ /**
23
+ * Returns the first promise to resolve or reject from an array of promises.
24
+ * Wrapper around Promise.race for consistency with other utility methods.
25
+ *
26
+ * @param {Array<Promise<unknown>>} promises - Array of promises to race
27
+ * @returns {Promise<unknown>} Result of the first settled promise
28
+ */
29
+ static async race(promises) {
30
+ Valid.type(promises, "Promise[]")
31
+
32
+ return await Promise.race(promises)
33
+ }
34
+
19
35
  /**
20
36
  * Settles all promises (both fulfilled and rejected) in parallel.
21
37
  * Wrapper around Promise.allSettled for consistency with other utility methods.
@@ -24,6 +40,8 @@ export default class Promised {
24
40
  * @returns {Promise<Array<{status: 'fulfilled'|'rejected', value?: unknown, reason?: unknown}>>} Results of all settled promises with status and value/reason
25
41
  */
26
42
  static async settle(promises) {
43
+ Valid.type(promises, "Promise[]")
44
+
27
45
  return await Promise.allSettled(promises)
28
46
  }
29
47
 
@@ -101,20 +119,12 @@ export default class Promised {
101
119
  * @throws {Tantrum} Throws a Tantrum error with rejection reasons
102
120
  */
103
121
  static throw(message="GIGO", settled) {
122
+ Valid.type(message, "String", {allowEmpty: false})
123
+ Valid.type(settled, "Array")
124
+
104
125
  const rejected = this.rejected(settled)
105
126
  const reasons = this.reasons(rejected)
106
127
 
107
128
  throw Tantrum.new(message, reasons)
108
129
  }
109
-
110
- /**
111
- * Returns the first promise to resolve or reject from an array of promises.
112
- * Wrapper around Promise.race for consistency with other utility methods.
113
- *
114
- * @param {Array<Promise<unknown>>} promises - Array of promises to race
115
- * @returns {Promise<unknown>} Result of the first settled promise
116
- */
117
- static async race(promises) {
118
- return await Promise.race(promises)
119
- }
120
130
  }
@@ -458,9 +458,8 @@ export default class FileObject extends FS {
458
458
  any: [JSON5,YAML]
459
459
  }[normalizedType]
460
460
 
461
- if(!toTry) {
461
+ if(!toTry)
462
462
  throw Sass.new(`Unsupported data type '${type}'. Supported types: json, json5, yaml.`)
463
- }
464
463
 
465
464
  for(const format of toTry) {
466
465
  try {
@@ -7,7 +7,7 @@
7
7
  * 1. Simple function call: Glog(data)
8
8
  * 2. With levels: Glog(2, "debug message")
9
9
  * 3. Configured instance: new Glog(options)
10
- * 4. Fluent setup: Glog.create().withName("App").withColors()
10
+ * 4. Fluent setup: Glog.create().withName("App").withColours()
11
11
  * 5. Traditional logger: logger.debug("message", level)
12
12
  */
13
13
 
@@ -16,9 +16,18 @@ import c from "@gesslar/colours"
16
16
  import Data from "../../browser/lib/Data.js"
17
17
  import Term from "./Term.js"
18
18
  import Util from "../../browser/lib/Util.js"
19
- // ErrorStackParser will be dynamically imported when needed
20
19
 
21
- // Enhanced color system using @gesslar/colours
20
+ /**
21
+ * Default colour configuration for logger output using @gesslar/colours format
22
+ *
23
+ * @type {object}
24
+ * @property {string[]} debug - Array of 5 colour codes for debug levels 0-4
25
+ * @property {string} info - Colour code for info messages
26
+ * @property {string} warn - Colour code for warning messages
27
+ * @property {string} error - Colour code for error messages
28
+ * @property {string} success - Colour code for success messages
29
+ * @property {string} reset - Colour reset code
30
+ */
22
31
  export const loggerColours = {
23
32
  debug: [
24
33
  "{F019}", // Debug level 0: Dark blue
@@ -34,7 +43,16 @@ export const loggerColours = {
34
43
  reset: "{/}", // Reset
35
44
  }
36
45
 
37
- // Symbol alternatives for tags
46
+ /**
47
+ * Symbol characters used for log level tags when colours are disabled or tagsAsStrings is false
48
+ *
49
+ * @type {object}
50
+ * @property {string} debug - Symbol for debug messages
51
+ * @property {string} info - Symbol for info messages
52
+ * @property {string} warn - Symbol for warning messages
53
+ * @property {string} error - Symbol for error messages
54
+ * @property {string} success - Symbol for success messages
55
+ */
38
56
  export const logSymbols = {
39
57
  debug: "?",
40
58
  info: "i",
@@ -43,7 +61,7 @@ export const logSymbols = {
43
61
  success: "✓"
44
62
  }
45
63
 
46
- // Set up convenient aliases for common log colors
64
+ // Set up convenient aliases for common log colours
47
65
  c.alias.set("debug", "{F033}")
48
66
  c.alias.set("info", "{F036}")
49
67
  c.alias.set("warn", "{F214}")
@@ -57,7 +75,7 @@ class Glog {
57
75
  // Static properties (for global usage)
58
76
  static logLevel = 0
59
77
  static logPrefix = ""
60
- static colors = null
78
+ static colours = null
61
79
  static stackTrace = false
62
80
  static name = ""
63
81
  static tagsAsStrings = false
@@ -65,7 +83,7 @@ class Glog {
65
83
  // Instance properties (for configured loggers)
66
84
  #logLevel = 0
67
85
  #logPrefix = ""
68
- #colors = null
86
+ #colours = null
69
87
  #stackTrace = false
70
88
  #name = ""
71
89
  #tagsAsStrings = false
@@ -74,6 +92,20 @@ class Glog {
74
92
  #vscodeWarn = null
75
93
  #vscodeInfo = null
76
94
 
95
+ /**
96
+ * Create a new Glog logger instance with optional configuration
97
+ *
98
+ * @param {object} [options={}] - Configuration options
99
+ * @param {string} [options.name] - Logger name to display in output
100
+ * @param {number} [options.debugLevel] - Debug verbosity level (0-5, default: 0)
101
+ * @param {number} [options.logLevel] - Alias for debugLevel
102
+ * @param {string} [options.prefix] - Prefix to prepend to all log messages
103
+ * @param {object} [options.colours] - Colour configuration object
104
+ * @param {boolean} [options.stackTrace=false] - Enable stack trace extraction
105
+ * @param {boolean} [options.tagsAsStrings=false] - Use string tags instead of symbols
106
+ * @param {boolean} [options.displayName=true] - Display logger name in output
107
+ * @param {string} [options.env] - Environment mode ("extension" for VSCode integration)
108
+ */
77
109
  constructor(options = {}) {
78
110
  this.setOptions(options)
79
111
  this.constructor.name = "Glog"
@@ -94,11 +126,25 @@ class Glog {
94
126
 
95
127
  // === CONFIGURATION METHODS ===
96
128
 
129
+ /**
130
+ * Set configuration options for this logger instance
131
+ *
132
+ * @param {object} options - Configuration options
133
+ * @param {string} [options.name] - Logger name to display in output
134
+ * @param {number} [options.debugLevel] - Debug verbosity level (0-5)
135
+ * @param {number} [options.logLevel] - Alias for debugLevel
136
+ * @param {string} [options.prefix] - Prefix to prepend to all log messages
137
+ * @param {object} [options.colours] - Colour configuration object
138
+ * @param {boolean} [options.stackTrace] - Enable stack trace extraction
139
+ * @param {boolean} [options.tagsAsStrings] - Use string tags instead of symbols
140
+ * @param {boolean} [options.displayName] - Display logger name in output
141
+ * @returns {Glog} This Glog instance for chaining
142
+ */
97
143
  setOptions(options) {
98
144
  this.#name = options.name ?? this.#name
99
145
  this.#logLevel = options.debugLevel ?? options.logLevel ?? this.#logLevel
100
146
  this.#logPrefix = options.prefix ?? this.#logPrefix
101
- this.#colors = options.colors ?? this.#colors
147
+ this.#colours = options.colours ?? this.#colours
102
148
  this.#stackTrace = options.stackTrace ?? this.#stackTrace
103
149
  this.#tagsAsStrings = options.tagsAsStrings ?? this.#tagsAsStrings
104
150
  this.#displayName = options.displayName ?? this.#displayName
@@ -145,18 +191,18 @@ class Glog {
145
191
  }
146
192
 
147
193
  /**
148
- * Enable colors for global usage
149
- * Merges with existing color configuration (can pass partial config)
194
+ * Enable colours for global usage
195
+ * Merges with existing colour configuration (can pass partial config)
150
196
  * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
151
- * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
152
- * - info, warn, error, reset: Single color code strings
197
+ * - debug: Array of 5 colour codes [level0, level1, level2, level3, level4]
198
+ * - info, warn, error, reset: Single colour code strings
153
199
  * Uses @gesslar/colours format like "{F196}"
154
200
  *
155
- * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
201
+ * @param {object} [colours=loggerColours] - Colour configuration object (partial or complete)
156
202
  * @returns {typeof Glog} The Glog class for chaining
157
203
  */
158
- static withColors(colors = loggerColours) {
159
- this.colors = Object.assign({}, this.colors ?? loggerColours, colors)
204
+ static withColours(colours = loggerColours) {
205
+ this.colours = Object.assign({}, this.colours ?? loggerColours, colours)
160
206
 
161
207
  return this
162
208
  }
@@ -185,6 +231,54 @@ class Glog {
185
231
  return this
186
232
  }
187
233
 
234
+ /**
235
+ * Create a temporary scoped logger with a custom prefix for a single chain (static version)
236
+ * The prefix replaces all formatting (name, tags) with just the prefix + message
237
+ *
238
+ * @param {string} prefix - Temporary prefix to use (e.g., "=>", " ", "-->")
239
+ * @returns {object} Temporary logger with all standard methods
240
+ * @example
241
+ * Glog.use("=>").info("Indented message") // => Indented message
242
+ * Glog.info("Back to normal") // [Log] i Back to normal
243
+ */
244
+ static use(prefix) {
245
+ return {
246
+ debug: (message, level = 1, ...args) => {
247
+ if(this.logLevel > 0 && level <= this.logLevel) {
248
+ Term.debug(`${prefix}${message}`, ...args)
249
+ }
250
+ },
251
+ info: (message, ...args) => Term.info(`${prefix}${message}`, ...args),
252
+ warn: (message, ...args) => Term.warn(`${prefix}${message}`, ...args),
253
+ error: (message, ...args) => Term.error(`${prefix}${message}`, ...args),
254
+ success: (message, ...args) => Term.log(`${prefix}${message}`, ...args),
255
+ log: (...args) => Term.log(prefix, ...args),
256
+ group: (...args) => {
257
+ const label = args.length > 0 ? ` ${args.join(" ")}` : ""
258
+
259
+ Term.group(`${prefix}${label}`)
260
+ },
261
+ groupEnd: () => Term.groupEnd(),
262
+ table: (data, labelOrOptions, options) => {
263
+ let label
264
+ let tableOptions = {}
265
+
266
+ if(typeof labelOrOptions === "string") {
267
+ label = labelOrOptions
268
+ tableOptions = options || {}
269
+ } else if(typeof labelOrOptions === "object" && labelOrOptions !== null) {
270
+ tableOptions = labelOrOptions
271
+ }
272
+
273
+ if(label) {
274
+ Term.log(`${prefix}${label}`)
275
+ }
276
+
277
+ Term.table(data, tableOptions)
278
+ }
279
+ }
280
+ }
281
+
188
282
  // === FLUENT INSTANCE CREATION ===
189
283
 
190
284
  /**
@@ -197,18 +291,36 @@ class Glog {
197
291
  return new this(options)
198
292
  }
199
293
 
294
+ /**
295
+ * Set the logger name for this instance
296
+ *
297
+ * @param {string} name - Logger name to display in output
298
+ * @returns {Glog} This Glog instance for chaining
299
+ */
200
300
  withName(name) {
201
301
  this.#name = name
202
302
 
203
303
  return this
204
304
  }
205
305
 
306
+ /**
307
+ * Set the log level for this instance (0-5)
308
+ *
309
+ * @param {number} level - Log level (0 = off, 1-5 = increasing verbosity)
310
+ * @returns {Glog} This Glog instance for chaining
311
+ */
206
312
  withLogLevel(level) {
207
313
  this.#logLevel = level
208
314
 
209
315
  return this
210
316
  }
211
317
 
318
+ /**
319
+ * Set the log prefix for this instance
320
+ *
321
+ * @param {string} prefix - Prefix to prepend to all log messages
322
+ * @returns {Glog} This Glog instance for chaining
323
+ */
212
324
  withPrefix(prefix) {
213
325
  this.#logPrefix = prefix
214
326
 
@@ -216,93 +328,191 @@ class Glog {
216
328
  }
217
329
 
218
330
  /**
219
- * Enable colors for this logger instance
220
- * Merges with existing color configuration (can pass partial config)
331
+ * Enable colours for this logger instance
332
+ * Merges with existing colour configuration (can pass partial config)
221
333
  * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
222
- * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
223
- * - info, warn, error, reset: Single color code strings
334
+ * - debug: Array of 5 colour codes [level0, level1, level2, level3, level4]
335
+ * - info, warn, error, reset: Single colour code strings
224
336
  * Uses @gesslar/colours format like "{F196}"
225
337
  *
226
- * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
338
+ * @param {object} [colours=loggerColours] - Colour configuration object (partial or complete)
227
339
  * @returns {Glog} This Glog instance for chaining
228
340
  */
229
- withColors(colors = loggerColours) {
230
- this.#colors = Object.assign({}, this.#colors ?? loggerColours, colors)
341
+ withColours(colours = loggerColours) {
342
+ this.#colours = Object.assign({}, this.#colours ?? loggerColours, colours)
231
343
 
232
344
  return this
233
345
  }
234
346
 
347
+ /**
348
+ * Enable or disable stack trace extraction for this instance
349
+ *
350
+ * @param {boolean} [enabled=true] - Whether to enable stack traces
351
+ * @returns {Glog} This Glog instance for chaining
352
+ */
235
353
  withStackTrace(enabled = true) {
236
354
  this.#stackTrace = enabled
237
355
 
238
356
  return this
239
357
  }
240
358
 
359
+ /**
360
+ * Use tag names as strings instead of symbols for this instance
361
+ *
362
+ * @param {boolean} [enabled=false] - Whether to use string tags
363
+ * @returns {Glog} This Glog instance for chaining
364
+ */
241
365
  withTagsAsStrings(enabled = false) {
242
366
  this.#tagsAsStrings = enabled
243
367
 
244
368
  return this
245
369
  }
246
370
 
371
+ /**
372
+ * Disable displaying the logger name in output for this instance
373
+ *
374
+ * @returns {Glog} This Glog instance for chaining
375
+ */
247
376
  noDisplayName() {
248
377
  this.#displayName = false
249
378
 
250
379
  return this
251
380
  }
252
381
 
382
+ /**
383
+ * Create a temporary scoped logger with a custom prefix for a single chain
384
+ * The prefix replaces all formatting (name, tags) with just the prefix + message
385
+ *
386
+ * @param {string} prefix - Temporary prefix to use (e.g., "=>", " ", "-->")
387
+ * @returns {object} Temporary logger with all standard methods
388
+ * @example
389
+ * logger.use("=>").info("Indented message") // => Indented message
390
+ * logger.info("Back to normal") // [MyApp] i Back to normal
391
+ */
392
+ use(prefix) {
393
+ return {
394
+ debug: (message, level = 1, ...args) => {
395
+ const currentLevel = this.#logLevel || Glog.logLevel
396
+
397
+ if(currentLevel > 0 && level <= currentLevel) {
398
+ Term.debug(`${prefix}${message}`, ...args)
399
+ }
400
+ },
401
+ info: (message, ...args) => Term.info(`${prefix}${message}`, ...args),
402
+ warn: (message, ...args) => Term.warn(`${prefix}${message}`, ...args),
403
+ error: (message, ...args) => Term.error(`${prefix}${message}`, ...args),
404
+ success: (message, ...args) => Term.log(`${prefix}${message}`, ...args),
405
+ log: (...args) => Term.log(prefix, ...args),
406
+ group: (...args) => {
407
+ const label = args.length > 0 ? ` ${args.join(" ")}` : ""
408
+
409
+ Term.group(`${prefix}${label}`)
410
+ },
411
+ groupEnd: () => Term.groupEnd(),
412
+ table: (data, labelOrOptions, options) => {
413
+ let label
414
+ let tableOptions = {}
415
+
416
+ if(typeof labelOrOptions === "string") {
417
+ label = labelOrOptions
418
+ tableOptions = options || {}
419
+ } else if(typeof labelOrOptions === "object" && labelOrOptions !== null) {
420
+ tableOptions = labelOrOptions
421
+ }
422
+
423
+ if(label) {
424
+ Term.log(`${prefix}${label}`)
425
+ }
426
+
427
+ Term.table(data, tableOptions)
428
+ }
429
+ }
430
+ }
431
+
253
432
  // === UTILITY METHODS ===
254
433
 
434
+ /**
435
+ * Get the current logger name
436
+ *
437
+ * @returns {string} The logger name
438
+ */
255
439
  get name() {
256
440
  return this.#name
257
441
  }
258
442
 
443
+ /**
444
+ * Get the current debug level
445
+ *
446
+ * @returns {number} The debug level (0-5)
447
+ */
259
448
  get debugLevel() {
260
449
  return this.#logLevel
261
450
  }
262
451
 
452
+ /**
453
+ * Get the current logger options configuration
454
+ *
455
+ * @returns {object} The logger options
456
+ * @returns {string} return.name - Logger name
457
+ * @returns {number} return.debugLevel - Debug level
458
+ * @returns {string} return.prefix - Log prefix
459
+ * @returns {object} return.colours - Colour configuration
460
+ * @returns {boolean} return.stackTrace - Stack trace enabled
461
+ */
263
462
  get options() {
264
463
  return {
265
464
  name: this.#name,
266
465
  debugLevel: this.#logLevel,
267
466
  prefix: this.#logPrefix,
268
- colors: this.#colors,
467
+ colours: this.#colours,
269
468
  stackTrace: this.#stackTrace
270
469
  }
271
470
  }
272
471
 
273
472
  #compose(level, message, debugLevel = 0) {
274
- const colors = this.#colors || Glog.colors || loggerColours
473
+ const colours = this.#colours || Glog.colours || loggerColours
275
474
  const name = this.#name || Glog.name || "Log"
276
475
  const useStrings = this.#tagsAsStrings || Glog.tagsAsStrings
277
476
  const showName = this.#displayName
278
477
  const tag = useStrings ? Util.capitalize(level) : logSymbols[level]
279
478
  const namePrefix = showName ? `[${name}] ` : ""
280
479
 
281
- if(!colors) {
480
+ if(!colours) {
282
481
  return useStrings
283
482
  ? `${namePrefix}${tag}: ${message}`
284
483
  : `${namePrefix}${tag} ${message}`
285
484
  }
286
485
 
287
486
  if(level === "debug") {
288
- const colorCode = colors[level][debugLevel] || colors[level][0]
487
+ const colourCode = colours[level][debugLevel] || colours[level][0]
289
488
 
290
489
  return useStrings
291
- ? c`${namePrefix}${colorCode}${tag}{/}: ${message}`
292
- : c`${namePrefix}${colorCode}${tag}{/} ${message}`
490
+ ? c`${namePrefix}${colourCode}${tag}{/}: ${message}`
491
+ : c`${namePrefix}${colourCode}${tag}{/} ${message}`
293
492
  }
294
493
 
295
494
  return useStrings
296
- ? c`${namePrefix}${colors[level]}${tag}{/}: ${message}`
297
- : c`${namePrefix}${colors[level]}${tag}{/} ${message}`
495
+ ? c`${namePrefix}${colours[level]}${tag}{/}: ${message}`
496
+ : c`${namePrefix}${colours[level]}${tag}{/} ${message}`
298
497
  }
299
498
 
300
- // Stack trace functionality - simplified for now
499
+ /**
500
+ * Extract file and function information from stack trace
501
+ *
502
+ * @private
503
+ * @returns {string} Caller tag
504
+ */
301
505
  extractFileFunction() {
302
506
  // Simple fallback - just return a basic tag
303
507
  return "caller"
304
508
  }
305
509
 
510
+ /**
511
+ * Create a new debug function with a specific tag
512
+ *
513
+ * @param {string} tag - Tag to prepend to debug messages
514
+ * @returns {Function} Debug function with the tag
515
+ */
306
516
  newDebug(tag) {
307
517
  return function(message, level, ...arg) {
308
518
  if(this.#stackTrace || Glog.stackTrace) {
@@ -363,16 +573,34 @@ class Glog {
363
573
  }
364
574
  }
365
575
 
576
+ /**
577
+ * Log an informational message
578
+ *
579
+ * @param {string} message - Info message to log
580
+ * @param {...unknown} arg - Additional arguments to log
581
+ */
366
582
  info(message, ...arg) {
367
583
  Term.info(this.#compose("info", message), ...arg)
368
584
  this.#vscodeInfo?.(JSON.stringify(message))
369
585
  }
370
586
 
587
+ /**
588
+ * Log a warning message
589
+ *
590
+ * @param {string} message - Warning message to log
591
+ * @param {...unknown} arg - Additional arguments to log
592
+ */
371
593
  warn(message, ...arg) {
372
594
  Term.warn(this.#compose("warn", message), ...arg)
373
595
  this.#vscodeWarn?.(JSON.stringify(message))
374
596
  }
375
597
 
598
+ /**
599
+ * Log an error message
600
+ *
601
+ * @param {string} message - Error message to log
602
+ * @param {...unknown} arg - Additional arguments to log
603
+ */
376
604
  error(message, ...arg) {
377
605
  Term.error(this.#compose("error", message), ...arg)
378
606
  this.#vscodeError?.(JSON.stringify(message))
@@ -406,7 +634,12 @@ class Glog {
406
634
  }
407
635
  }
408
636
 
409
- // Instance execute for configured loggers
637
+ /**
638
+ * Instance execute method for configured loggers
639
+ * Can be called as: logger(data) or logger(level, data)
640
+ *
641
+ * @param {...unknown} args - Arguments (optional level number, then data)
642
+ */
410
643
  execute(...args) {
411
644
  this.#log(...args)
412
645
  }
@@ -414,13 +647,13 @@ class Glog {
414
647
  // === ENHANCED METHODS WITH @gesslar/colours ===
415
648
 
416
649
  /**
417
- * Log a colorized message using template literals
650
+ * Log a colourized message using template literals
418
651
  *
419
652
  * @param {Array<string>} strings - Template strings
420
653
  * @param {...unknown} values - Template values
421
- * @example logger.colorize`{success}Operation completed{/} in {bold}${time}ms{/}`
654
+ * @example logger.colourize`{success}Operation completed{/} in {bold}${time}ms{/}`
422
655
  */
423
- colorize(strings, ...values) {
656
+ colourize(strings, ...values) {
424
657
  const message = c(strings, ...values)
425
658
  const name = this.#name || Glog.name || "Log"
426
659
 
@@ -428,12 +661,12 @@ class Glog {
428
661
  }
429
662
 
430
663
  /**
431
- * Static version of colorize for global usage
664
+ * Static version of colourize for global usage
432
665
  *
433
666
  * @param {Array<string>} strings - Template strings
434
667
  * @param {...unknown} values - Template values
435
668
  */
436
- static colorize(strings, ...values) {
669
+ static colourize(strings, ...values) {
437
670
  const message = c(strings, ...values)
438
671
  const name = this.name || "Log"
439
672
 
@@ -441,7 +674,7 @@ class Glog {
441
674
  }
442
675
 
443
676
  /**
444
- * Log a success message with green color
677
+ * Log a success message with green colour
445
678
  *
446
679
  * @param {string} message - Success message
447
680
  * @param {...unknown} args - Additional arguments
@@ -457,14 +690,14 @@ class Glog {
457
690
  * @param {...unknown} args - Additional arguments to log
458
691
  */
459
692
  static success(message, ...args) {
460
- const colors = this.colors || loggerColours
693
+ const colours = this.colours || loggerColours
461
694
  const name = this.name || "Log"
462
695
  const useStrings = this.tagsAsStrings
463
696
  const tag = useStrings ? "Success" : logSymbols.success
464
- const colorCode = colors.success || "{F046}"
697
+ const colourCode = colours.success || "{F046}"
465
698
  const formatted = useStrings
466
- ? c`[${name}] ${colorCode}${tag}{/}: ${message}`
467
- : c`[${name}] ${colorCode}${tag}{/} ${message}`
699
+ ? c`[${name}] ${colourCode}${tag}{/}: ${message}`
700
+ : c`[${name}] ${colourCode}${tag}{/} ${message}`
468
701
 
469
702
  Term.log(formatted, ...args)
470
703
  }
@@ -495,14 +728,14 @@ class Glog {
495
728
  * @param {number} [level=1] - Debug level
496
729
  */
497
730
  static groupDebug(message, level = 1) {
498
- const colors = this.colors || loggerColours
731
+ const colours = this.colours || loggerColours
499
732
  const name = this.name || "Log"
500
733
  const useStrings = this.tagsAsStrings
501
734
  const tag = useStrings ? "Debug" : logSymbols.debug
502
- const colorCode = colors.debug[level] || colors.debug[0]
735
+ const colourCode = colours.debug[level] || colours.debug[0]
503
736
  const label = useStrings
504
- ? c`[${name}] ${colorCode}${tag}{/}: ${message}`
505
- : c`[${name}] ${colorCode}${tag}{/} ${message}`
737
+ ? c`[${name}] ${colourCode}${tag}{/}: ${message}`
738
+ : c`[${name}] ${colourCode}${tag}{/} ${message}`
506
739
 
507
740
  Term.group(label)
508
741
  }
@@ -513,13 +746,13 @@ class Glog {
513
746
  * @param {string} message - Group label
514
747
  */
515
748
  static groupInfo(message) {
516
- const colors = this.colors || loggerColours
749
+ const colours = this.colours || loggerColours
517
750
  const name = this.name || "Log"
518
751
  const useStrings = this.tagsAsStrings
519
752
  const tag = useStrings ? "Info" : logSymbols.info
520
753
  const label = useStrings
521
- ? c`[${name}] ${colors.info}${tag}{/}: ${message}`
522
- : c`[${name}] ${colors.info}${tag}{/} ${message}`
754
+ ? c`[${name}] ${colours.info}${tag}{/}: ${message}`
755
+ : c`[${name}] ${colours.info}${tag}{/} ${message}`
523
756
 
524
757
  Term.group(label)
525
758
  }
@@ -657,14 +890,14 @@ class Glog {
657
890
  }
658
891
 
659
892
  /**
660
- * Set a color alias for convenient usage
893
+ * Set a colour alias for convenient usage
661
894
  *
662
895
  * @param {string} alias - Alias name
663
- * @param {string} colorCode - Color code (e.g., "{F196}" or "{<B}")
896
+ * @param {string} colourCode - Colour code (e.g., "{F196}" or "{<B}")
664
897
  * @returns {Glog} The Glog class for chaining.
665
898
  */
666
- static setAlias(alias, colorCode) {
667
- c.alias.set(alias, colorCode)
899
+ static setAlias(alias, colourCode) {
900
+ c.alias.set(alias, colourCode)
668
901
 
669
902
  return this
670
903
  }
@@ -682,6 +915,15 @@ class Glog {
682
915
  * Get a raw logger that outputs without name/tag formatting
683
916
  *
684
917
  * @returns {object} Raw logger interface
918
+ * @returns {Function} return.debug - Raw debug output function
919
+ * @returns {Function} return.info - Raw info output function
920
+ * @returns {Function} return.warn - Raw warning output function
921
+ * @returns {Function} return.error - Raw error output function
922
+ * @returns {Function} return.log - Raw log output function
923
+ * @returns {Function} return.success - Raw success output function
924
+ * @returns {Function} return.table - Raw table output function
925
+ * @returns {Function} return.group - Raw group start function
926
+ * @returns {Function} return.groupEnd - Raw group end function
685
927
  */
686
928
  get raw() {
687
929
  return {
@@ -701,6 +943,15 @@ class Glog {
701
943
  * Static raw logger that outputs without name/tag formatting
702
944
  *
703
945
  * @returns {object} Raw logger interface
946
+ * @returns {Function} return.debug - Raw debug output function
947
+ * @returns {Function} return.info - Raw info output function
948
+ * @returns {Function} return.warn - Raw warning output function
949
+ * @returns {Function} return.error - Raw error output function
950
+ * @returns {Function} return.log - Raw log output function
951
+ * @returns {Function} return.success - Raw success output function
952
+ * @returns {Function} return.table - Raw table output function
953
+ * @returns {Function} return.group - Raw group start function
954
+ * @returns {Function} return.groupEnd - Raw group end function
704
955
  */
705
956
  static get raw() {
706
957
  return {
@@ -11,6 +11,14 @@ export default class Promised {
11
11
  * @returns {Promise<Array<unknown>>} Results of all promises
12
12
  */
13
13
  static await(promises: Array<Promise<unknown>>): Promise<Array<unknown>>;
14
+ /**
15
+ * Returns the first promise to resolve or reject from an array of promises.
16
+ * Wrapper around Promise.race for consistency with other utility methods.
17
+ *
18
+ * @param {Array<Promise<unknown>>} promises - Array of promises to race
19
+ * @returns {Promise<unknown>} Result of the first settled promise
20
+ */
21
+ static race(promises: Array<Promise<unknown>>): Promise<unknown>;
14
22
  /**
15
23
  * Settles all promises (both fulfilled and rejected) in parallel.
16
24
  * Wrapper around Promise.allSettled for consistency with other utility methods.
@@ -107,13 +115,5 @@ export default class Promised {
107
115
  value?: unknown;
108
116
  reason?: unknown;
109
117
  }>): void;
110
- /**
111
- * Returns the first promise to resolve or reject from an array of promises.
112
- * Wrapper around Promise.race for consistency with other utility methods.
113
- *
114
- * @param {Array<Promise<unknown>>} promises - Array of promises to race
115
- * @returns {Promise<unknown>} Result of the first settled promise
116
- */
117
- static race(promises: Array<Promise<unknown>>): Promise<unknown>;
118
118
  }
119
119
  //# sourceMappingURL=Promised.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Promised.d.ts","sourceRoot":"","sources":["../../../src/browser/lib/Promised.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH;IACE;;;;;;OAMG;IACH,uBAHW,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GACrB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC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xE,KAAK,CAAC,OAAO,CAAC,CAO1B;IAED;;;;;;OAMG;IACH,sBAJW,MAAM,WACN,KAAK,CAAC;QAAC,MAAM,EAAE,WAAW,GAAC,UAAU,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAC,CAAC,QAWpF;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;GAaG;AAEH;IACE;;;;;OAKG;IACH,yBAFU;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,GAAG,OAAO,IAAI,CAAC,CAAA;KAAC,CAO1D;IA0BF;;;;;;;;OAQG;IACH,gDAOC;IAED;;;;;OAKG;IACH,uBAHW,MAAM,WACN,eAAe,GAAC,MAAM,GAAC,IAAI,EA6DrC;IAaD;;;;OAIG;IACH,cAFa,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,GAAG,CAIf;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAFa,MAAM,CAIlB;IACD;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;;;;;;;;;;;OAcG;IACH,cAFa,eAAe,CAI3B;IAED;;;;OAIG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,OAAO,CAAC,OAAO,CAAC,CAU5B;IAED;;;;OAIG;IACH,YAFa,OAAO,CAAC,OAAO,CAAC,CAU5B;IAiBD;;;;OAIG;IACH,QAFa,OAAO,CAAC,MAAM,OAAC,CAAC,CAU5B;IAED;;;;;OAKG;IACH,YAFa,OAAO,CAAC,IAAI,OAAC,CAAC,CAU1B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;;;;;;;OAWG;IACH,cARa,OAAO,CAAC,MAAM,CAAC,CAe3B;IAED;;;;;;;;;;;OAWG;IACH,eARW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAiBzB;IAED;;;;;;;;;;;;;;;OAeG;IACH,kBAXW,WAAW,GAAC,IAAI,GAAC,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAwBzB;IAED;;;;;;;;;;;;;;OAcG;IACH,gBAXW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAkC5B;IAED;;;;OAIG;IACH,UAFa,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;;;;;OASG;IACH,UAPa,OAAO,CAAC,IAAI,CAAC,CAczB;;CACF;eA/ec,iBAAiB;4BADJ,sBAAsB"}
1
+ {"version":3,"file":"FileObject.d.ts","sourceRoot":"","sources":["../../../src/node/lib/FileObject.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;GAaG;AAEH;IACE;;;;;OAKG;IACH,yBAFU;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,OAAO,KAAK,GAAG,OAAO,IAAI,CAAC,CAAA;KAAC,CAO1D;IA0BF;;;;;;;;OAQG;IACH,gDAOC;IAED;;;;;OAKG;IACH,uBAHW,MAAM,WACN,eAAe,GAAC,MAAM,GAAC,IAAI,EA6DrC;IAaD;;;;OAIG;IACH,cAFa,OAAO,CAAC,OAAO,CAAC,CAI5B;IAED;;;;OAIG;IACH,gBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,GAAG,CAIf;IAED;;;;OAIG;IACH,YAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,cAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,iBAFa,MAAM,CAIlB;IACD;;;;OAIG;IACH,cAFa,OAAO,CAInB;IAED;;;;;;;;;;;;;;OAcG;IACH,cAFa,eAAe,CAI3B;IAED;;;;OAIG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,WAFa,OAAO,CAAC,OAAO,CAAC,CAU5B;IAED;;;;OAIG;IACH,YAFa,OAAO,CAAC,OAAO,CAAC,CAU5B;IAiBD;;;;OAIG;IACH,QAFa,OAAO,CAAC,MAAM,OAAC,CAAC,CAU5B;IAED;;;;;OAKG;IACH,YAFa,OAAO,CAAC,IAAI,OAAC,CAAC,CAU1B;IAED;;;;;OAKG;IACH,gBAHW,MAAM,GACJ,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;;;;;;;OAWG;IACH,cARa,OAAO,CAAC,MAAM,CAAC,CAe3B;IAED;;;;;;;;;;;OAWG;IACH,eARW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CAiBzB;IAED;;;;;;;;;;;;;;;OAeG;IACH,kBAXW,WAAW,GAAC,IAAI,GAAC,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAwBzB;IAED;;;;;;;;;;;;;;OAcG;IACH,gBAXW,MAAM,aACN,MAAM,GACJ,OAAO,CAAC,OAAO,CAAC,CAiC5B;IAED;;;;OAIG;IACH,UAFa,OAAO,CAAC,MAAM,CAAC,CAS3B;IAED;;;;;;;;;OASG;IACH,UAPa,OAAO,CAAC,IAAI,CAAC,CAczB;;CACF;eA9ec,iBAAiB;4BADJ,sBAAsB"}
@@ -1,29 +1,32 @@
1
- export namespace loggerColours {
2
- let debug: string[];
3
- let info: string;
4
- let warn: string;
5
- let error: string;
6
- let success: string;
7
- let reset: string;
8
- }
9
- export namespace logSymbols {
10
- let debug_1: string;
11
- export { debug_1 as debug };
12
- let info_1: string;
13
- export { info_1 as info };
14
- let warn_1: string;
15
- export { warn_1 as warn };
16
- let error_1: string;
17
- export { error_1 as error };
18
- let success_1: string;
19
- export { success_1 as success };
20
- }
1
+ /**
2
+ * Default colour configuration for logger output using @gesslar/colours format
3
+ *
4
+ * @type {object}
5
+ * @property {string[]} debug - Array of 5 colour codes for debug levels 0-4
6
+ * @property {string} info - Colour code for info messages
7
+ * @property {string} warn - Colour code for warning messages
8
+ * @property {string} error - Colour code for error messages
9
+ * @property {string} success - Colour code for success messages
10
+ * @property {string} reset - Colour reset code
11
+ */
12
+ export const loggerColours: object;
13
+ /**
14
+ * Symbol characters used for log level tags when colours are disabled or tagsAsStrings is false
15
+ *
16
+ * @type {object}
17
+ * @property {string} debug - Symbol for debug messages
18
+ * @property {string} info - Symbol for info messages
19
+ * @property {string} warn - Symbol for warning messages
20
+ * @property {string} error - Symbol for error messages
21
+ * @property {string} success - Symbol for success messages
22
+ */
23
+ export const logSymbols: object;
21
24
  declare const _default: typeof Glog;
22
25
  export default _default;
23
26
  declare class Glog {
24
27
  static logLevel: number;
25
28
  static logPrefix: string;
26
- static colors: any;
29
+ static colours: any;
27
30
  static stackTrace: boolean;
28
31
  static name: string;
29
32
  static tagsAsStrings: boolean;
@@ -49,17 +52,17 @@ declare class Glog {
49
52
  */
50
53
  static withName(name: string): typeof Glog;
51
54
  /**
52
- * Enable colors for global usage
53
- * Merges with existing color configuration (can pass partial config)
55
+ * Enable colours for global usage
56
+ * Merges with existing colour configuration (can pass partial config)
54
57
  * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
55
- * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
56
- * - info, warn, error, reset: Single color code strings
58
+ * - debug: Array of 5 colour codes [level0, level1, level2, level3, level4]
59
+ * - info, warn, error, reset: Single colour code strings
57
60
  * Uses @gesslar/colours format like "{F196}"
58
61
  *
59
- * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
62
+ * @param {object} [colours=loggerColours] - Colour configuration object (partial or complete)
60
63
  * @returns {typeof Glog} The Glog class for chaining
61
64
  */
62
- static withColors(colors?: object): typeof Glog;
65
+ static withColours(colours?: object): typeof Glog;
63
66
  /**
64
67
  * Enable stack trace extraction for global usage
65
68
  *
@@ -74,6 +77,17 @@ declare class Glog {
74
77
  * @returns {typeof Glog} The Glog class for chaining
75
78
  */
76
79
  static withTagsAsStrings(enabled?: boolean): typeof Glog;
80
+ /**
81
+ * Create a temporary scoped logger with a custom prefix for a single chain (static version)
82
+ * The prefix replaces all formatting (name, tags) with just the prefix + message
83
+ *
84
+ * @param {string} prefix - Temporary prefix to use (e.g., "=>", " ", "-->")
85
+ * @returns {object} Temporary logger with all standard methods
86
+ * @example
87
+ * Glog.use("=>").info("Indented message") // => Indented message
88
+ * Glog.info("Back to normal") // [Log] i Back to normal
89
+ */
90
+ static use(prefix: string): object;
77
91
  /**
78
92
  * Create a new Glog instance with fluent configuration
79
93
  *
@@ -89,12 +103,12 @@ declare class Glog {
89
103
  */
90
104
  static execute(...args: unknown[]): void;
91
105
  /**
92
- * Static version of colorize for global usage
106
+ * Static version of colourize for global usage
93
107
  *
94
108
  * @param {Array<string>} strings - Template strings
95
109
  * @param {...unknown} values - Template values
96
110
  */
97
- static colorize(strings: Array<string>, ...values: unknown[]): void;
111
+ static colourize(strings: Array<string>, ...values: unknown[]): void;
98
112
  /**
99
113
  * Static success method
100
114
  *
@@ -147,50 +161,178 @@ declare class Glog {
147
161
  quotedStrings?: boolean;
148
162
  }): void;
149
163
  /**
150
- * Set a color alias for convenient usage
164
+ * Set a colour alias for convenient usage
151
165
  *
152
166
  * @param {string} alias - Alias name
153
- * @param {string} colorCode - Color code (e.g., "{F196}" or "{<B}")
167
+ * @param {string} colourCode - Colour code (e.g., "{F196}" or "{<B}")
154
168
  * @returns {Glog} The Glog class for chaining.
155
169
  */
156
- static setAlias(alias: string, colorCode: string): Glog;
170
+ static setAlias(alias: string, colourCode: string): Glog;
157
171
  /**
158
172
  * Static raw logger that outputs without name/tag formatting
159
173
  *
160
174
  * @returns {object} Raw logger interface
175
+ * @returns {Function} return.debug - Raw debug output function
176
+ * @returns {Function} return.info - Raw info output function
177
+ * @returns {Function} return.warn - Raw warning output function
178
+ * @returns {Function} return.error - Raw error output function
179
+ * @returns {Function} return.log - Raw log output function
180
+ * @returns {Function} return.success - Raw success output function
181
+ * @returns {Function} return.table - Raw table output function
182
+ * @returns {Function} return.group - Raw group start function
183
+ * @returns {Function} return.groupEnd - Raw group end function
161
184
  */
162
185
  static get raw(): object;
163
- constructor(options?: {});
164
- setOptions(options: any): this;
165
- withName(name: any): this;
166
- withLogLevel(level: any): this;
167
- withPrefix(prefix: any): this;
168
- /**
169
- * Enable colors for this logger instance
170
- * Merges with existing color configuration (can pass partial config)
186
+ /**
187
+ * Create a new Glog logger instance with optional configuration
188
+ *
189
+ * @param {object} [options={}] - Configuration options
190
+ * @param {string} [options.name] - Logger name to display in output
191
+ * @param {number} [options.debugLevel] - Debug verbosity level (0-5, default: 0)
192
+ * @param {number} [options.logLevel] - Alias for debugLevel
193
+ * @param {string} [options.prefix] - Prefix to prepend to all log messages
194
+ * @param {object} [options.colours] - Colour configuration object
195
+ * @param {boolean} [options.stackTrace=false] - Enable stack trace extraction
196
+ * @param {boolean} [options.tagsAsStrings=false] - Use string tags instead of symbols
197
+ * @param {boolean} [options.displayName=true] - Display logger name in output
198
+ * @param {string} [options.env] - Environment mode ("extension" for VSCode integration)
199
+ */
200
+ constructor(options?: {
201
+ name?: string;
202
+ debugLevel?: number;
203
+ logLevel?: number;
204
+ prefix?: string;
205
+ colours?: object;
206
+ stackTrace?: boolean;
207
+ tagsAsStrings?: boolean;
208
+ displayName?: boolean;
209
+ env?: string;
210
+ });
211
+ /**
212
+ * Set configuration options for this logger instance
213
+ *
214
+ * @param {object} options - Configuration options
215
+ * @param {string} [options.name] - Logger name to display in output
216
+ * @param {number} [options.debugLevel] - Debug verbosity level (0-5)
217
+ * @param {number} [options.logLevel] - Alias for debugLevel
218
+ * @param {string} [options.prefix] - Prefix to prepend to all log messages
219
+ * @param {object} [options.colours] - Colour configuration object
220
+ * @param {boolean} [options.stackTrace] - Enable stack trace extraction
221
+ * @param {boolean} [options.tagsAsStrings] - Use string tags instead of symbols
222
+ * @param {boolean} [options.displayName] - Display logger name in output
223
+ * @returns {Glog} This Glog instance for chaining
224
+ */
225
+ setOptions(options: {
226
+ name?: string;
227
+ debugLevel?: number;
228
+ logLevel?: number;
229
+ prefix?: string;
230
+ colours?: object;
231
+ stackTrace?: boolean;
232
+ tagsAsStrings?: boolean;
233
+ displayName?: boolean;
234
+ }): Glog;
235
+ /**
236
+ * Set the logger name for this instance
237
+ *
238
+ * @param {string} name - Logger name to display in output
239
+ * @returns {Glog} This Glog instance for chaining
240
+ */
241
+ withName(name: string): Glog;
242
+ /**
243
+ * Set the log level for this instance (0-5)
244
+ *
245
+ * @param {number} level - Log level (0 = off, 1-5 = increasing verbosity)
246
+ * @returns {Glog} This Glog instance for chaining
247
+ */
248
+ withLogLevel(level: number): Glog;
249
+ /**
250
+ * Set the log prefix for this instance
251
+ *
252
+ * @param {string} prefix - Prefix to prepend to all log messages
253
+ * @returns {Glog} This Glog instance for chaining
254
+ */
255
+ withPrefix(prefix: string): Glog;
256
+ /**
257
+ * Enable colours for this logger instance
258
+ * Merges with existing colour configuration (can pass partial config)
171
259
  * Shape: {debug?: string[], info?: string, warn?: string, error?: string, reset?: string}
172
- * - debug: Array of 5 color codes [level0, level1, level2, level3, level4]
173
- * - info, warn, error, reset: Single color code strings
260
+ * - debug: Array of 5 colour codes [level0, level1, level2, level3, level4]
261
+ * - info, warn, error, reset: Single colour code strings
174
262
  * Uses @gesslar/colours format like "{F196}"
175
263
  *
176
- * @param {object} [colors=loggerColours] - Color configuration object (partial or complete)
264
+ * @param {object} [colours=loggerColours] - Colour configuration object (partial or complete)
265
+ * @returns {Glog} This Glog instance for chaining
266
+ */
267
+ withColours(colours?: object): Glog;
268
+ /**
269
+ * Enable or disable stack trace extraction for this instance
270
+ *
271
+ * @param {boolean} [enabled=true] - Whether to enable stack traces
272
+ * @returns {Glog} This Glog instance for chaining
273
+ */
274
+ withStackTrace(enabled?: boolean): Glog;
275
+ /**
276
+ * Use tag names as strings instead of symbols for this instance
277
+ *
278
+ * @param {boolean} [enabled=false] - Whether to use string tags
279
+ * @returns {Glog} This Glog instance for chaining
280
+ */
281
+ withTagsAsStrings(enabled?: boolean): Glog;
282
+ /**
283
+ * Disable displaying the logger name in output for this instance
284
+ *
177
285
  * @returns {Glog} This Glog instance for chaining
178
286
  */
179
- withColors(colors?: object): Glog;
180
- withStackTrace(enabled?: boolean): this;
181
- withTagsAsStrings(enabled?: boolean): this;
182
- noDisplayName(): this;
287
+ noDisplayName(): Glog;
288
+ /**
289
+ * Create a temporary scoped logger with a custom prefix for a single chain
290
+ * The prefix replaces all formatting (name, tags) with just the prefix + message
291
+ *
292
+ * @param {string} prefix - Temporary prefix to use (e.g., "=>", " ", "-->")
293
+ * @returns {object} Temporary logger with all standard methods
294
+ * @example
295
+ * logger.use("=>").info("Indented message") // => Indented message
296
+ * logger.info("Back to normal") // [MyApp] i Back to normal
297
+ */
298
+ use(prefix: string): object;
299
+ /**
300
+ * Get the current logger name
301
+ *
302
+ * @returns {string} The logger name
303
+ */
183
304
  get name(): string;
305
+ /**
306
+ * Get the current debug level
307
+ *
308
+ * @returns {number} The debug level (0-5)
309
+ */
184
310
  get debugLevel(): number;
185
- get options(): {
186
- name: string;
187
- debugLevel: number;
188
- prefix: string;
189
- colors: any;
190
- stackTrace: boolean;
191
- };
192
- extractFileFunction(): string;
193
- newDebug(tag: any): any;
311
+ /**
312
+ * Get the current logger options configuration
313
+ *
314
+ * @returns {object} The logger options
315
+ * @returns {string} return.name - Logger name
316
+ * @returns {number} return.debugLevel - Debug level
317
+ * @returns {string} return.prefix - Log prefix
318
+ * @returns {object} return.colours - Colour configuration
319
+ * @returns {boolean} return.stackTrace - Stack trace enabled
320
+ */
321
+ get options(): object;
322
+ /**
323
+ * Extract file and function information from stack trace
324
+ *
325
+ * @private
326
+ * @returns {string} Caller tag
327
+ */
328
+ private extractFileFunction;
329
+ /**
330
+ * Create a new debug function with a specific tag
331
+ *
332
+ * @param {string} tag - Tag to prepend to debug messages
333
+ * @returns {Function} Debug function with the tag
334
+ */
335
+ newDebug(tag: string): Function;
194
336
  /**
195
337
  * Log a debug message with specified verbosity level.
196
338
  * Level 0 means debug OFF - use levels 1-4 for actual debug output.
@@ -202,20 +344,44 @@ declare class Glog {
202
344
  * @throws {Error} If level < 1 (level 0 = debug OFF)
203
345
  */
204
346
  debug(message: string, level?: number, ...arg: unknown[]): void;
205
- info(message: any, ...arg: any[]): void;
206
- warn(message: any, ...arg: any[]): void;
207
- error(message: any, ...arg: any[]): void;
208
- execute(...args: any[]): void;
209
347
  /**
210
- * Log a colorized message using template literals
348
+ * Log an informational message
349
+ *
350
+ * @param {string} message - Info message to log
351
+ * @param {...unknown} arg - Additional arguments to log
352
+ */
353
+ info(message: string, ...arg: unknown[]): void;
354
+ /**
355
+ * Log a warning message
356
+ *
357
+ * @param {string} message - Warning message to log
358
+ * @param {...unknown} arg - Additional arguments to log
359
+ */
360
+ warn(message: string, ...arg: unknown[]): void;
361
+ /**
362
+ * Log an error message
363
+ *
364
+ * @param {string} message - Error message to log
365
+ * @param {...unknown} arg - Additional arguments to log
366
+ */
367
+ error(message: string, ...arg: unknown[]): void;
368
+ /**
369
+ * Instance execute method for configured loggers
370
+ * Can be called as: logger(data) or logger(level, data)
371
+ *
372
+ * @param {...unknown} args - Arguments (optional level number, then data)
373
+ */
374
+ execute(...args: unknown[]): void;
375
+ /**
376
+ * Log a colourized message using template literals
211
377
  *
212
378
  * @param {Array<string>} strings - Template strings
213
379
  * @param {...unknown} values - Template values
214
- * @example logger.colorize`{success}Operation completed{/} in {bold}${time}ms{/}`
380
+ * @example logger.colourize`{success}Operation completed{/} in {bold}${time}ms{/}`
215
381
  */
216
- colorize(strings: Array<string>, ...values: unknown[]): void;
382
+ colourize(strings: Array<string>, ...values: unknown[]): void;
217
383
  /**
218
- * Log a success message with green color
384
+ * Log a success message with green colour
219
385
  *
220
386
  * @param {string} message - Success message
221
387
  * @param {...unknown} args - Additional arguments
@@ -275,6 +441,15 @@ declare class Glog {
275
441
  * Get a raw logger that outputs without name/tag formatting
276
442
  *
277
443
  * @returns {object} Raw logger interface
444
+ * @returns {Function} return.debug - Raw debug output function
445
+ * @returns {Function} return.info - Raw info output function
446
+ * @returns {Function} return.warn - Raw warning output function
447
+ * @returns {Function} return.error - Raw error output function
448
+ * @returns {Function} return.log - Raw log output function
449
+ * @returns {Function} return.success - Raw success output function
450
+ * @returns {Function} return.table - Raw table output function
451
+ * @returns {Function} return.group - Raw group start function
452
+ * @returns {Function} return.groupEnd - Raw group end function
278
453
  */
279
454
  get raw(): object;
280
455
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"Glog.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Glog.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuDA;IAEE,wBAAmB;IACnB,yBAAqB;IACrB,mBAAoB;IACpB,2BAAyB;IACzB,oBAAgB;IAChB,8BAA4B;IAgD5B;;;;;OAKG;IACH,4BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,0BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;;;;;;OAUG;IACH,2BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,gCAHW,OAAO,GACL,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,mCAHW,OAAO,GACL,OAAO,IAAI,CAMvB;IAID;;;;;OAKG;IACH,wBAHW,MAAM,GACJ,IAAI,CAIhB;IAuLD;;;;;OAKG;IACH,wBAFc,OAAO,EAAA,QAsBpB;IAuBD;;;;;OAKG;IACH,yBAHW,KAAK,CAAC,MAAM,CAAC,aACV,OAAO,EAAA,QAOpB;IAYD;;;;;OAKG;IACH,wBAHW,MAAM,WACH,OAAO,EAAA,QAap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M,GAAG,MAAM,YAEvB;QAAgC,UAAU,GAAlC,KAAK,CAAC,MAAM,CAAC;QACK,UAAU,GAA5B,OAAO;QACW,aAAa,GAA/B,OAAO;KACjB,QAkBA;IA4CD;;;;OAIG;IACH,mBAEC;IAED;;;;OAIG;IACH,WAFa,MAAM,CAclB;;CAoBF"}
1
+ {"version":3,"file":"Glog.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Glog.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;GAUG;AACH,4BARU,MAAM,CAqBf;AAED;;;;;;;;;GASG;AACH,yBAPU,MAAM,CAaf;;;AAYD;IAEE,wBAAmB;IACnB,yBAAqB;IACrB,oBAAqB;IACrB,2BAAyB;IACzB,oBAAgB;IAChB,8BAA4B;IA4E5B;;;;;OAKG;IACH,4BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,0BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;;;;;;OAUG;IACH,6BAHW,MAAM,GACJ,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,gCAHW,OAAO,GACL,OAAO,IAAI,CAMvB;IAED;;;;;OAKG;IACH,mCAHW,OAAO,GACL,OAAO,IAAI,CAMvB;IAED;;;;;;;;;OASG;IACH,mBANW,MAAM,GACJ,MAAM,CAyClB;IAID;;;;;OAKG;IACH,wBAHW,MAAM,GACJ,IAAI,CAIhB;IA6TD;;;;;OAKG;IACH,wBAFc,OAAO,EAAA,QAsBpB;IA4BD;;;;;OAKG;IACH,0BAHW,KAAK,CAAC,MAAM,CAAC,aACV,OAAO,EAAA,QAOpB;IAYD;;;;;OAKG;IACH,wBAHW,MAAM,WACH,OAAO,EAAA,QAapB;IAED;;;;OAIG;IACH,sBAFc,OAAO,EAAA,QAOpB;IAED;;OAEG;IACH,wBAEC;IAED;;;;;OAKG;IACH,2BAHW,MAAM,UACN,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