@gesslar/toolkit 3.20.0 → 3.21.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 +2 -2
- package/src/node/lib/Glog.js +51 -6
- package/types/node/lib/Glog.d.ts +29 -0
- package/types/node/lib/Glog.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "gesslar",
|
|
6
6
|
"url": "https://gesslar.dev"
|
|
7
7
|
},
|
|
8
|
-
"version": "3.
|
|
8
|
+
"version": "3.21.0",
|
|
9
9
|
"license": "Unlicense",
|
|
10
10
|
"homepage": "https://github.com/gesslar/toolkit#readme",
|
|
11
11
|
"repository": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"yaml": "^2.8.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@gesslar/uglier": "^0.
|
|
61
|
+
"@gesslar/uglier": "^1.0.0",
|
|
62
62
|
"eslint": "^9.39.2",
|
|
63
63
|
"happy-dom": "^20.1.0",
|
|
64
64
|
"typescript": "^5.9.3"
|
package/src/node/lib/Glog.js
CHANGED
|
@@ -79,6 +79,7 @@ class Glog {
|
|
|
79
79
|
static stackTrace = false
|
|
80
80
|
static name = ""
|
|
81
81
|
static tagsAsStrings = false
|
|
82
|
+
static symbols = null
|
|
82
83
|
|
|
83
84
|
// Instance properties (for configured loggers)
|
|
84
85
|
#logLevel = 0
|
|
@@ -88,6 +89,7 @@ class Glog {
|
|
|
88
89
|
#name = ""
|
|
89
90
|
#tagsAsStrings = false
|
|
90
91
|
#displayName = true
|
|
92
|
+
#symbols = null
|
|
91
93
|
#vscodeError = null
|
|
92
94
|
#vscodeWarn = null
|
|
93
95
|
#vscodeInfo = null
|
|
@@ -101,6 +103,7 @@ class Glog {
|
|
|
101
103
|
* @param {number} [options.logLevel] - Alias for debugLevel
|
|
102
104
|
* @param {string} [options.prefix] - Prefix to prepend to all log messages
|
|
103
105
|
* @param {object} [options.colours] - Colour configuration object
|
|
106
|
+
* @param {object} [options.symbols] - Custom log level symbols (e.g., {info: '🚒', warn: '🚨', error: '🔥', success: '💧', debug: '🧯'})
|
|
104
107
|
* @param {boolean} [options.stackTrace=false] - Enable stack trace extraction
|
|
105
108
|
* @param {boolean} [options.tagsAsStrings=false] - Use string tags instead of symbols
|
|
106
109
|
* @param {boolean} [options.displayName=true] - Display logger name in output
|
|
@@ -135,6 +138,7 @@ class Glog {
|
|
|
135
138
|
* @param {number} [options.logLevel] - Alias for debugLevel
|
|
136
139
|
* @param {string} [options.prefix] - Prefix to prepend to all log messages
|
|
137
140
|
* @param {object} [options.colours] - Colour configuration object
|
|
141
|
+
* @param {object} [options.symbols] - Custom log level symbols (e.g., {info: '🚒', warn: '🚨', error: '🔥', success: '💧', debug: '🧯'})
|
|
138
142
|
* @param {boolean} [options.stackTrace] - Enable stack trace extraction
|
|
139
143
|
* @param {boolean} [options.tagsAsStrings] - Use string tags instead of symbols
|
|
140
144
|
* @param {boolean} [options.displayName] - Display logger name in output
|
|
@@ -145,6 +149,7 @@ class Glog {
|
|
|
145
149
|
this.#logLevel = options.debugLevel ?? options.logLevel ?? this.#logLevel
|
|
146
150
|
this.#logPrefix = options.prefix ?? this.#logPrefix
|
|
147
151
|
this.#colours = options.colours ?? this.#colours
|
|
152
|
+
this.#symbols = options.symbols ?? this.#symbols
|
|
148
153
|
this.#stackTrace = options.stackTrace ?? this.#stackTrace
|
|
149
154
|
this.#tagsAsStrings = options.tagsAsStrings ?? this.#tagsAsStrings
|
|
150
155
|
this.#displayName = options.displayName ?? this.#displayName
|
|
@@ -231,6 +236,23 @@ class Glog {
|
|
|
231
236
|
return this
|
|
232
237
|
}
|
|
233
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Customize log level symbols for global usage
|
|
241
|
+
* Merges with existing symbols (can pass partial config)
|
|
242
|
+
* Only affects output when tagsAsStrings is false
|
|
243
|
+
* Shape: {debug?: string, info?: string, warn?: string, error?: string, success?: string}
|
|
244
|
+
*
|
|
245
|
+
* @param {object} [symbols=logSymbols] - Symbol configuration object (partial or complete)
|
|
246
|
+
* @returns {typeof Glog} The Glog class for chaining
|
|
247
|
+
* @example
|
|
248
|
+
* Glog.withSymbols({info: '🚒', warn: '🚨', error: '🔥', success: '💧', debug: '🧯'})
|
|
249
|
+
*/
|
|
250
|
+
static withSymbols(symbols = logSymbols) {
|
|
251
|
+
this.symbols = Object.assign({}, this.symbols ?? logSymbols, symbols)
|
|
252
|
+
|
|
253
|
+
return this
|
|
254
|
+
}
|
|
255
|
+
|
|
234
256
|
/**
|
|
235
257
|
* Create a temporary scoped logger with a custom prefix for a single chain (static version)
|
|
236
258
|
* The prefix replaces all formatting (name, tags) with just the prefix + message
|
|
@@ -368,6 +390,23 @@ class Glog {
|
|
|
368
390
|
return this
|
|
369
391
|
}
|
|
370
392
|
|
|
393
|
+
/**
|
|
394
|
+
* Customize log level symbols for this logger instance
|
|
395
|
+
* Merges with existing symbols (can pass partial config)
|
|
396
|
+
* Only affects output when tagsAsStrings is false
|
|
397
|
+
* Shape: {debug?: string, info?: string, warn?: string, error?: string, success?: string}
|
|
398
|
+
*
|
|
399
|
+
* @param {object} [symbols=logSymbols] - Symbol configuration object (partial or complete)
|
|
400
|
+
* @returns {Glog} This Glog instance for chaining
|
|
401
|
+
* @example
|
|
402
|
+
* logger.withSymbols({info: '🚒', warn: '🚨', error: '🔥', success: '💧', debug: '🧯'})
|
|
403
|
+
*/
|
|
404
|
+
withSymbols(symbols = logSymbols) {
|
|
405
|
+
this.#symbols = Object.assign({}, this.#symbols ?? logSymbols, symbols)
|
|
406
|
+
|
|
407
|
+
return this
|
|
408
|
+
}
|
|
409
|
+
|
|
371
410
|
/**
|
|
372
411
|
* Disable displaying the logger name in output for this instance
|
|
373
412
|
*
|
|
@@ -474,7 +513,8 @@ class Glog {
|
|
|
474
513
|
const name = this.#name || Glog.name || "Log"
|
|
475
514
|
const useStrings = this.#tagsAsStrings || Glog.tagsAsStrings
|
|
476
515
|
const showName = this.#displayName
|
|
477
|
-
const
|
|
516
|
+
const symbols = this.#symbols || Glog.symbols || logSymbols
|
|
517
|
+
const tag = useStrings ? Util.capitalize(level) : symbols[level]
|
|
478
518
|
const namePrefix = showName ? `[${name}] ` : ""
|
|
479
519
|
|
|
480
520
|
if(!colours) {
|
|
@@ -693,7 +733,8 @@ class Glog {
|
|
|
693
733
|
const colours = this.colours || loggerColours
|
|
694
734
|
const name = this.name || "Log"
|
|
695
735
|
const useStrings = this.tagsAsStrings
|
|
696
|
-
const
|
|
736
|
+
const symbols = this.symbols || logSymbols
|
|
737
|
+
const tag = useStrings ? "Success" : symbols.success
|
|
697
738
|
const colourCode = colours.success || "{F046}"
|
|
698
739
|
const formatted = useStrings
|
|
699
740
|
? c`[${name}] ${colourCode}${tag}{/}: ${message}`
|
|
@@ -731,7 +772,8 @@ class Glog {
|
|
|
731
772
|
const colours = this.colours || loggerColours
|
|
732
773
|
const name = this.name || "Log"
|
|
733
774
|
const useStrings = this.tagsAsStrings
|
|
734
|
-
const
|
|
775
|
+
const symbols = this.symbols || logSymbols
|
|
776
|
+
const tag = useStrings ? "Debug" : symbols.debug
|
|
735
777
|
const colourCode = colours.debug[level] || colours.debug[0]
|
|
736
778
|
const label = useStrings
|
|
737
779
|
? c`[${name}] ${colourCode}${tag}{/}: ${message}`
|
|
@@ -749,7 +791,8 @@ class Glog {
|
|
|
749
791
|
const colours = this.colours || loggerColours
|
|
750
792
|
const name = this.name || "Log"
|
|
751
793
|
const useStrings = this.tagsAsStrings
|
|
752
|
-
const
|
|
794
|
+
const symbols = this.symbols || logSymbols
|
|
795
|
+
const tag = useStrings ? "Info" : symbols.info
|
|
753
796
|
const label = useStrings
|
|
754
797
|
? c`[${name}] ${colours.info}${tag}{/}: ${message}`
|
|
755
798
|
: c`[${name}] ${colours.info}${tag}{/} ${message}`
|
|
@@ -765,7 +808,8 @@ class Glog {
|
|
|
765
808
|
static groupSuccess(message) {
|
|
766
809
|
const name = this.name || "Log"
|
|
767
810
|
const useStrings = this.tagsAsStrings
|
|
768
|
-
const
|
|
811
|
+
const symbols = this.symbols || logSymbols
|
|
812
|
+
const tag = useStrings ? "Success" : symbols.success
|
|
769
813
|
const label = useStrings
|
|
770
814
|
? c`[${name}] {success}${tag}{/}: ${message}`
|
|
771
815
|
: c`[${name}] {success}${tag}{/} ${message}`
|
|
@@ -822,7 +866,8 @@ class Glog {
|
|
|
822
866
|
const name = this.#name || Glog.name || "Log"
|
|
823
867
|
const useStrings = this.#tagsAsStrings || Glog.tagsAsStrings
|
|
824
868
|
const showName = this.#displayName
|
|
825
|
-
const
|
|
869
|
+
const symbols = this.#symbols || Glog.symbols || logSymbols
|
|
870
|
+
const tag = useStrings ? "Success" : symbols.success
|
|
826
871
|
const namePrefix = showName ? `[${name}] ` : ""
|
|
827
872
|
const label = useStrings
|
|
828
873
|
? c`${namePrefix}{success}${tag}{/}: ${message}`
|
package/types/node/lib/Glog.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare class Glog {
|
|
|
30
30
|
static stackTrace: boolean;
|
|
31
31
|
static name: string;
|
|
32
32
|
static tagsAsStrings: boolean;
|
|
33
|
+
static symbols: any;
|
|
33
34
|
/**
|
|
34
35
|
* Set the log prefix for global usage
|
|
35
36
|
*
|
|
@@ -77,6 +78,18 @@ declare class Glog {
|
|
|
77
78
|
* @returns {typeof Glog} The Glog class for chaining
|
|
78
79
|
*/
|
|
79
80
|
static withTagsAsStrings(enabled?: boolean): typeof Glog;
|
|
81
|
+
/**
|
|
82
|
+
* Customize log level symbols for global usage
|
|
83
|
+
* Merges with existing symbols (can pass partial config)
|
|
84
|
+
* Only affects output when tagsAsStrings is false
|
|
85
|
+
* Shape: {debug?: string, info?: string, warn?: string, error?: string, success?: string}
|
|
86
|
+
*
|
|
87
|
+
* @param {object} [symbols=logSymbols] - Symbol configuration object (partial or complete)
|
|
88
|
+
* @returns {typeof Glog} The Glog class for chaining
|
|
89
|
+
* @example
|
|
90
|
+
* Glog.withSymbols({info: '🚒', warn: '🚨', error: '🔥', success: '💧', debug: '🧯'})
|
|
91
|
+
*/
|
|
92
|
+
static withSymbols(symbols?: object): typeof Glog;
|
|
80
93
|
/**
|
|
81
94
|
* Create a temporary scoped logger with a custom prefix for a single chain (static version)
|
|
82
95
|
* The prefix replaces all formatting (name, tags) with just the prefix + message
|
|
@@ -192,6 +205,7 @@ declare class Glog {
|
|
|
192
205
|
* @param {number} [options.logLevel] - Alias for debugLevel
|
|
193
206
|
* @param {string} [options.prefix] - Prefix to prepend to all log messages
|
|
194
207
|
* @param {object} [options.colours] - Colour configuration object
|
|
208
|
+
* @param {object} [options.symbols] - Custom log level symbols (e.g., {info: '🚒', warn: '🚨', error: '🔥', success: '💧', debug: '🧯'})
|
|
195
209
|
* @param {boolean} [options.stackTrace=false] - Enable stack trace extraction
|
|
196
210
|
* @param {boolean} [options.tagsAsStrings=false] - Use string tags instead of symbols
|
|
197
211
|
* @param {boolean} [options.displayName=true] - Display logger name in output
|
|
@@ -203,6 +217,7 @@ declare class Glog {
|
|
|
203
217
|
logLevel?: number;
|
|
204
218
|
prefix?: string;
|
|
205
219
|
colours?: object;
|
|
220
|
+
symbols?: object;
|
|
206
221
|
stackTrace?: boolean;
|
|
207
222
|
tagsAsStrings?: boolean;
|
|
208
223
|
displayName?: boolean;
|
|
@@ -217,6 +232,7 @@ declare class Glog {
|
|
|
217
232
|
* @param {number} [options.logLevel] - Alias for debugLevel
|
|
218
233
|
* @param {string} [options.prefix] - Prefix to prepend to all log messages
|
|
219
234
|
* @param {object} [options.colours] - Colour configuration object
|
|
235
|
+
* @param {object} [options.symbols] - Custom log level symbols (e.g., {info: '🚒', warn: '🚨', error: '🔥', success: '💧', debug: '🧯'})
|
|
220
236
|
* @param {boolean} [options.stackTrace] - Enable stack trace extraction
|
|
221
237
|
* @param {boolean} [options.tagsAsStrings] - Use string tags instead of symbols
|
|
222
238
|
* @param {boolean} [options.displayName] - Display logger name in output
|
|
@@ -228,6 +244,7 @@ declare class Glog {
|
|
|
228
244
|
logLevel?: number;
|
|
229
245
|
prefix?: string;
|
|
230
246
|
colours?: object;
|
|
247
|
+
symbols?: object;
|
|
231
248
|
stackTrace?: boolean;
|
|
232
249
|
tagsAsStrings?: boolean;
|
|
233
250
|
displayName?: boolean;
|
|
@@ -279,6 +296,18 @@ declare class Glog {
|
|
|
279
296
|
* @returns {Glog} This Glog instance for chaining
|
|
280
297
|
*/
|
|
281
298
|
withTagsAsStrings(enabled?: boolean): Glog;
|
|
299
|
+
/**
|
|
300
|
+
* Customize log level symbols for this logger instance
|
|
301
|
+
* Merges with existing symbols (can pass partial config)
|
|
302
|
+
* Only affects output when tagsAsStrings is false
|
|
303
|
+
* Shape: {debug?: string, info?: string, warn?: string, error?: string, success?: string}
|
|
304
|
+
*
|
|
305
|
+
* @param {object} [symbols=logSymbols] - Symbol configuration object (partial or complete)
|
|
306
|
+
* @returns {Glog} This Glog instance for chaining
|
|
307
|
+
* @example
|
|
308
|
+
* logger.withSymbols({info: '🚒', warn: '🚨', error: '🔥', success: '💧', debug: '🧯'})
|
|
309
|
+
*/
|
|
310
|
+
withSymbols(symbols?: object): Glog;
|
|
282
311
|
/**
|
|
283
312
|
* Disable displaying the logger name in output for this instance
|
|
284
313
|
*
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"Glog.d.ts","sourceRoot":"","sources":["../../../src/node/lib/Glog.js"],"names":[],"mappings":"AAmBA;;;;;;;;;;GAUG;AACH,4BARU,MAAM,CAqBf;AA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