analogger 1.29.4 → 1.30.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/ana-logger.d.cts CHANGED
@@ -99,7 +99,7 @@ declare class ____AnaLogger {
99
99
  isBrowser(): boolean;
100
100
  resetLogger(): void;
101
101
  resetOptions(): void;
102
- setOptions({ contextLenMax, idLenMax, lidLenMax, symbolLenMax, messageLenMax, hideLog, hideError, hideHookMessage, hidePassingTests, logToDom, logToFile, logMaxSize, logMaxArchives, logIndexArchive, addArchiveTimestamp, addArchiveIndex, compressArchives, compressionLevel, logToRemote, logToRemoteUrl, logToRemoteBinaryUrl, loopback, requiredLogLevel, oneConsolePerContext, silent, enableDate, protocol, host, port, pathname, binarypathname }?: any): void;
102
+ setOptions({ contextLenMax, idLenMax, lidLenMax, symbolLenMax, messageLenMax, hideLog, hideError, hideHookMessage, hidePassingTests, logToDom, logToFile, logMaxSize, logMaxArchives, logIndexArchive, addArchiveTimestamp, addArchiveIndex, compressArchives, compressionLevel, logToRemote, logToRemoteUrl, logToRemoteBinaryUrl, loopback, requiredLogLevel, oneConsolePerContext, silent, enableDate, protocol, host, port, pathname, binarypathname, loadHtmlToImage }?: any): void;
103
103
  EOL: string;
104
104
  getOptions(): {
105
105
  hideHookMessage: boolean;
@@ -336,6 +336,29 @@ declare class ____AnaLogger {
336
336
  info(...args: any[]): void;
337
337
  warn(...args: any[]): void;
338
338
  table(...args: any[]): void;
339
+ /**
340
+ * Takes a screenshot of the specified DOM element.
341
+ *
342
+ * @param {Object} context - The context for the screenshot.
343
+ * @param {string} context.selector - The CSS selector of the element to capture.
344
+ * @param {number} context.quality - The quality of the screenshot (0 to 1).
345
+ * @param {number} context.canvasHeight - The height of the canvas.
346
+ * @param {number} context.canvasWidth - The width of the canvas.
347
+ * @param {("Png"|"Jpeg"|"Svg"|"Blob"|"Canvas"|"PixelData")} context.imageType - The type of the image
348
+ * @param {number} context.width Width in pixels to be applied to DOM node before rendering.
349
+ * @param {number} context.height Height in pixels to be applied to the DOM node before rendering.
350
+ * @param {number} context.pixelRatio
351
+ */
352
+ takeScreenshot(context?: {
353
+ selector: string;
354
+ quality: number;
355
+ canvasHeight: number;
356
+ canvasWidth: number;
357
+ imageType: ("Png" | "Jpeg" | "Svg" | "Blob" | "Canvas" | "PixelData");
358
+ width: number;
359
+ height: number;
360
+ pixelRatio: number;
361
+ }): Promise<any>;
339
362
  alert(...args: any[]): void;
340
363
  assert(condition: any, expected?: boolean, ...args: any[]): boolean;
341
364
  /**
@@ -0,0 +1,488 @@
1
+ export namespace DEFAULT_LOG_TARGETS {
2
+ const ALL: string;
3
+ const USER: string;
4
+ }
5
+ export namespace DEFAULT_LOG_LEVELS {
6
+ export const FATAL: number;
7
+ export const ERROR: number;
8
+ export const WARN: number;
9
+ export const INFO: number;
10
+ export const LOG: number;
11
+ export const DEBUG: number;
12
+ const ALL_1: number;
13
+ export { ALL_1 as ALL };
14
+ export const OFF: number;
15
+ export const INHERIT: number;
16
+ }
17
+ export namespace DEFAULT_LOG_CONTEXTS {
18
+ export namespace DEFAULT {
19
+ export const contextName: string;
20
+ import logLevel = DEFAULT_LOG_LEVELS.LOG;
21
+ export { logLevel };
22
+ export const symbol: string;
23
+ }
24
+ export namespace LOG_1 {
25
+ const contextName_1: string;
26
+ export { contextName_1 as contextName };
27
+ import logLevel_1 = DEFAULT_LOG_LEVELS.LOG;
28
+ export { logLevel_1 as logLevel };
29
+ const symbol_1: string;
30
+ export { symbol_1 as symbol };
31
+ }
32
+ export { LOG_1 as LOG };
33
+ export namespace DEBUG_1 {
34
+ const contextName_2: string;
35
+ export { contextName_2 as contextName };
36
+ import logLevel_2 = DEFAULT_LOG_LEVELS.DEBUG;
37
+ export { logLevel_2 as logLevel };
38
+ }
39
+ export { DEBUG_1 as DEBUG };
40
+ export namespace INFO_1 {
41
+ const contextName_3: string;
42
+ export { contextName_3 as contextName };
43
+ import logLevel_3 = DEFAULT_LOG_LEVELS.INFO;
44
+ export { logLevel_3 as logLevel };
45
+ export const color: string;
46
+ const symbol_2: string;
47
+ export { symbol_2 as symbol };
48
+ }
49
+ export { INFO_1 as INFO };
50
+ export namespace WARN_1 {
51
+ const contextName_4: string;
52
+ export { contextName_4 as contextName };
53
+ import logLevel_4 = DEFAULT_LOG_LEVELS.WARN;
54
+ export { logLevel_4 as logLevel };
55
+ const color_1: string;
56
+ export { color_1 as color };
57
+ const symbol_3: string;
58
+ export { symbol_3 as symbol };
59
+ }
60
+ export { WARN_1 as WARN };
61
+ export namespace ERROR_1 {
62
+ const contextName_5: string;
63
+ export { contextName_5 as contextName };
64
+ import logLevel_5 = DEFAULT_LOG_LEVELS.ERROR;
65
+ export { logLevel_5 as logLevel };
66
+ }
67
+ export { ERROR_1 as ERROR };
68
+ export namespace CRITICAL {
69
+ const contextName_6: string;
70
+ export { contextName_6 as contextName };
71
+ const logLevel_6: any;
72
+ export { logLevel_6 as logLevel };
73
+ }
74
+ }
75
+ export default __AnaLogger;
76
+ export const anaLogger: any;
77
+ export const AnaLogger: typeof ____AnaLogger;
78
+ export type PLUGIN_TYPE = {
79
+ LOCAL: string;
80
+ GLOBAL: string;
81
+ };
82
+ export type PLUGIN_PROPERTIES_TYPE = {
83
+ /**
84
+ * AnaLogger's real method name that is set to the AnaLogger instance *
85
+ */
86
+ methodName: string;
87
+ /**
88
+ * AnaLogger method that will be called when invoking the plugin
89
+ */
90
+ callback: Function;
91
+ /**
92
+ * Whether the plugin is accessible to the AnaLogger class or an instance
93
+ */
94
+ type: PLUGIN_TYPE;
95
+ };
96
+ declare const __AnaLogger: typeof ____AnaLogger;
97
+ /**
98
+ * @module ____AnaLogger
99
+ * @class ____AnaLogger
100
+ */
101
+ declare class ____AnaLogger {
102
+ static "__#1@#instances": any[];
103
+ static Console: any;
104
+ static ALIGN: {
105
+ LEFT: string;
106
+ RIGHT: string;
107
+ };
108
+ static ENVIRONMENT_TYPE: {
109
+ BROWSER: string;
110
+ NODE: string;
111
+ OTHER: string;
112
+ };
113
+ static instanceCount: number;
114
+ static pluginTable: {};
115
+ static generateInstance(): ____AnaLogger;
116
+ /**
117
+ * Returns an AnaLogger instance
118
+ * @returns {null}
119
+ */
120
+ static getInstance(num?: number): null;
121
+ /**
122
+ * Returns first existing AnaLogger instance,
123
+ * otherwise create a new instance
124
+ * @returns {*|____AnaLogger}
125
+ */
126
+ static generateMainInstance(): any | ____AnaLogger;
127
+ /**
128
+ * Override console.log and console.error
129
+ */
130
+ static startLogger(): void;
131
+ static stopLogger(): void;
132
+ constructor({ name }?: {
133
+ name?: string;
134
+ });
135
+ system: string;
136
+ instanceId: string;
137
+ instanceName: string;
138
+ logIndex: number;
139
+ logCounter: number;
140
+ activeTargets: any[];
141
+ indexColor: number;
142
+ format: string;
143
+ keepLog: boolean;
144
+ logHistory: any[];
145
+ $containers: any;
146
+ options: {
147
+ hideHookMessage: boolean;
148
+ };
149
+ originalFormatFunction: string;
150
+ errorTargetHandler: any;
151
+ errorUserTargetHandler: any;
152
+ rawLog: any;
153
+ rawInfo: any;
154
+ rawWarn: any;
155
+ rawError: any;
156
+ ALIGN: {
157
+ LEFT: string;
158
+ RIGHT: string;
159
+ };
160
+ ENVIRONMENT_TYPE: {
161
+ BROWSER: string;
162
+ NODE: string;
163
+ OTHER: string;
164
+ };
165
+ getName(): string;
166
+ getId(): string;
167
+ keepLogHistory(): void;
168
+ releaseLogHistory(): void;
169
+ resetLogHistory(): void;
170
+ addToLogHistory(obj: any): void;
171
+ /**
172
+ * Returns log entries
173
+ * @note This method should return the list of objects rather than
174
+ * the array of text
175
+ * @param join
176
+ * @param symbol
177
+ * @returns {string|*[]}
178
+ */
179
+ getLogHistory(join?: boolean, symbol?: string): string | any[];
180
+ getRawLogHistory(): any[];
181
+ hasSeenLid(lid: any): boolean;
182
+ forceEnvironment(system: any): void;
183
+ forcedSystem: any;
184
+ /**
185
+ * Tell whether we are in a Node environment
186
+ * @returns {boolean}
187
+ */
188
+ isNode(): boolean;
189
+ /**
190
+ * Tell whether the logger runs from a browser
191
+ * @returns {boolean}
192
+ */
193
+ isBrowser(): boolean;
194
+ resetLogger(): void;
195
+ resetOptions(): void;
196
+ setOptions({ contextLenMax, idLenMax, lidLenMax, symbolLenMax, messageLenMax, hideLog, hideError, hideHookMessage, hidePassingTests, logToDom, logToFile, logMaxSize, logMaxArchives, logIndexArchive, addArchiveTimestamp, addArchiveIndex, compressArchives, compressionLevel, logToRemote, logToRemoteUrl, logToRemoteBinaryUrl, loopback, requiredLogLevel, oneConsolePerContext, silent, enableDate, protocol, host, port, pathname, binarypathname }?: any): void;
197
+ getOptions(): {
198
+ hideHookMessage: boolean;
199
+ };
200
+ truncateMessage(input?: string, { fit, align, ellipsis }?: {
201
+ fit?: number;
202
+ align?: string;
203
+ ellipsis?: string;
204
+ }): string;
205
+ /**
206
+ * Format inputs
207
+ * @see Override {@link setLogFormat}
208
+ * @param contextName
209
+ * @param id
210
+ * @param message
211
+ * @param lid
212
+ * @param symbol
213
+ * @returns {string}
214
+ */
215
+ onBuildLog({ contextName, message, lid, symbol }?: {
216
+ contextName: any;
217
+ message?: string;
218
+ lid?: string;
219
+ symbol?: string;
220
+ }): string;
221
+ onErrorForUserTarget(context: any, ...args: any[]): void;
222
+ onError(context: any, ...args: any[]): void;
223
+ /**
224
+ * Forward input to real console log
225
+ * @param args
226
+ */
227
+ onDisplayLog(...args: any[]): void;
228
+ assistStask(error: any): any;
229
+ /**
230
+ * Forward input to real console log
231
+ * @param args
232
+ */
233
+ onDisplayError(...args: any[]): void;
234
+ /**
235
+ * Set log template
236
+ * @param format
237
+ */
238
+ setLogFormat(format: any): boolean;
239
+ resetLogFormatter(): void;
240
+ setErrorHandler(handler: any): void;
241
+ setErrorHandlerForUserTarget(handler: any): void;
242
+ isContextValid(context: any): any;
243
+ /**
244
+ * Set context properties for default context
245
+ * @param context
246
+ */
247
+ setDefaultContext(context: any): void;
248
+ /**
249
+ * Generate a default context with a default color
250
+ * @returns {*|{}}
251
+ */
252
+ generateDefaultContext(): any | {};
253
+ /**
254
+ * Generate a new context based on the default context.
255
+ * The only difference with default is that a different color will be assigned to that context automatically
256
+ * @returns {*|{}}
257
+ */
258
+ generateNewContext(): any | {};
259
+ generateErrorContext(): any;
260
+ /**
261
+ * Redefine a context
262
+ * @param contextName
263
+ * @param context
264
+ */
265
+ setContext(contextName: any, context?: {}): void;
266
+ getContext(contextName: any): any;
267
+ /**
268
+ * Load the context names that should be available to the environment.
269
+ * They are defined by the user.
270
+ * @see Context definitions {@link ./example/more/contexts-def.cjs}
271
+ * @param contextTable
272
+ */
273
+ setContexts(contextTable: any): void;
274
+ getContexts(): readonly any[];
275
+ setTargets(targetTable?: {}): void;
276
+ addTargets(targets: any): void;
277
+ getTargets(): Readonly<{}>;
278
+ /**
279
+ * Set one or more active targets
280
+ * @param targets
281
+ */
282
+ setActiveTargets(targets?: any): void;
283
+ getActiveTarget(): any[];
284
+ /**
285
+ * Set only one active target
286
+ * NOTE: Kept for backward compatibility.
287
+ * Use setActiveTargets instead
288
+ * @param target
289
+ */
290
+ setActiveTarget(target: any): void;
291
+ setLogLevel(name: any, level: any): void;
292
+ getLogLevel(name: any): any;
293
+ setLogLevels(levels: any): void;
294
+ getLogLevels(): Readonly<{}>;
295
+ isTargetAllowed(target: any): boolean;
296
+ /**
297
+ * Add many sections (columns) to a given DOM line
298
+ * @param $line
299
+ * @param context
300
+ * @param text
301
+ */
302
+ setColumns($line: any, context: any, text: any): void;
303
+ /**
304
+ * Check that the div has not too many entries
305
+ * @param $view
306
+ */
307
+ removeDomOldEntries: ($view: any) => number;
308
+ /**
309
+ * Scroll to bottom if div is already at the bottom
310
+ * @param $view
311
+ */
312
+ scrollDivToBottom: ($view: any) => void;
313
+ checkOnLoggingToDom(context: any, param2: any): any;
314
+ /**
315
+ * Add a line to the Analogger div.
316
+ * Remove older lines if exceeding limit.
317
+ * @param $view
318
+ * @param $line
319
+ * @param context
320
+ * @param addType
321
+ * @param message
322
+ * @param text
323
+ * @param args
324
+ */
325
+ addLineToDom($view: any, $line: any, { context, addType, message, text, args }: {
326
+ context: any;
327
+ addType: any;
328
+ message: any;
329
+ text: any;
330
+ args: any;
331
+ }): void;
332
+ showRemovedNotification(context: any): void;
333
+ timerAddLineToDomID: any;
334
+ writeLogToDom(context: any, fullText: any, { addType, message, args }?: {
335
+ addType?: string;
336
+ message?: string;
337
+ args?: any;
338
+ }): void;
339
+ writeLogToFile(text: any): void;
340
+ writeLogToRemote(...data: any[]): any;
341
+ /**
342
+ * Send data to the registered remote server
343
+ * @param raw
344
+ * @param context
345
+ * @param done
346
+ */
347
+ uploadDataToRemote(raw: any, context?: any, done?: any): any;
348
+ stringifyEntry(arg: any): string;
349
+ /**
350
+ * If a variable is too complex for the logger, stringify it
351
+ */
352
+ convertEntry(arg: any): any;
353
+ convertArgumentsToText(args: any): string;
354
+ writeToConsole(output: any, context: any): void;
355
+ /**
356
+ * Parse the context. If one of its keys has the same name as a registered plugin,
357
+ * the system will invoke the plugin (the value of the key must be anything truthy).
358
+ * @param context
359
+ * @param extras
360
+ * @returns {undefined|boolean}
361
+ */
362
+ checkPlugins(context: any, { message, text, args, logCounter }: {
363
+ message: any;
364
+ text: any;
365
+ args: any;
366
+ logCounter: any;
367
+ }): undefined | boolean;
368
+ /**
369
+ * If the context contain a key onLogging that is a function,
370
+ * execute
371
+ * @param context
372
+ * @param data
373
+ * @param extras
374
+ * @param callbackName
375
+ * @returns {*}
376
+ */
377
+ checkOnLogging(context: any, data: any, extras: any, callbackName: any): any;
378
+ /**
379
+ * Display log following template
380
+ * @param context
381
+ */
382
+ processOutput(context?: {}, ...args: any[]): void;
383
+ /**
384
+ * Check that a parameter uses the expected AnaLogger format.
385
+ * For this, the first parameter should be an object that contains at least
386
+ * a logging id (lid), a target, a contextName, etc
387
+ * @param options
388
+ * @returns {boolean}
389
+ */
390
+ isExtendedOptionsPassed(options: any): boolean;
391
+ /**
392
+ * Convert a string into a Context object if possible
393
+ * TODO: To implement in next version
394
+ * @param str
395
+ * @returns {string}
396
+ */
397
+ extractContextFromInput(str: any): string;
398
+ listSymbols(): void;
399
+ applySymbolByName(context: any): void;
400
+ /**
401
+ * Convert the first parameter of a console.log to a Context object
402
+ * @param options
403
+ * @param defaultContext
404
+ * @returns {*|{}}
405
+ */
406
+ convertToContext(options: any, defaultContext: any): any | {};
407
+ /**
408
+ * console.log with options set on the first parameter to dictate console log behaviours
409
+ * @param options
410
+ * @param args
411
+ */
412
+ log(options: any, ...args: any[]): void;
413
+ error(options: any, ...args: any[]): void;
414
+ overrideError(): void;
415
+ attachConsole(): boolean;
416
+ overrideConsole({ log, info, warn, error }?: {
417
+ log?: boolean;
418
+ info?: boolean;
419
+ warn?: boolean;
420
+ error?: boolean;
421
+ }): void;
422
+ removeOverrideError(): void;
423
+ removeOverride({ log, info, warn, error }?: {
424
+ log?: boolean;
425
+ info?: boolean;
426
+ warn?: boolean;
427
+ error?: boolean;
428
+ }): void;
429
+ info(...args: any[]): void;
430
+ warn(...args: any[]): void;
431
+ table(...args: any[]): void;
432
+ takeScreenshotWithImageCapture(): Promise<any>;
433
+ takeScreenshot(): void;
434
+ alert(...args: any[]): void;
435
+ assert(condition: any, expected?: boolean, ...args: any[]): boolean;
436
+ /**
437
+ * Set standard Analogger format
438
+ * @example
439
+ * // Output Example
440
+ * // [14:01:06] DEFAULT: (1060) ⚡ " ✔ My log ..."
441
+ * @param activeTarget
442
+ * @param override
443
+ * @returns {boolean}
444
+ */
445
+ applyAnalogFormatting({ activeTarget, override }?: {
446
+ activeTarget?: string;
447
+ override?: boolean;
448
+ }): boolean;
449
+ applyPredefinedFormat(name?: string, { activeTarget, override }?: {
450
+ activeTarget?: string;
451
+ override?: boolean;
452
+ }): boolean;
453
+ convertToUrl({ protocol, host, port, pathname }?: {
454
+ protocol?: string;
455
+ host?: string;
456
+ port?: number;
457
+ pathname?: string;
458
+ }): string;
459
+ generateLogToRemoteUrl(logToRemoteUrl?: any, { pathname }?: {
460
+ pathname?: string;
461
+ }): string | String;
462
+ /**
463
+ * Install a plugin against the active instance
464
+ * @param methodName
465
+ * @param callback
466
+ * @param pluginName
467
+ */
468
+ addPlugin(methodName: any, callback: any, pluginName?: string): void;
469
+ /**
470
+ * Install a plugin against the class (an instantiation with new is needed)
471
+ * @param methodName
472
+ * @param callback
473
+ * @param pluginName
474
+ */
475
+ addGlobalPlugin(methodName: any, callback: any, pluginName: any): void;
476
+ getPluginList(): string[];
477
+ /**
478
+ * At the moment, this method behaviour is equivalent to an eventual isPluginRegistered method
479
+ * @param name
480
+ * @returns {boolean}
481
+ */
482
+ validatePlugin(name: any): boolean;
483
+ #private;
484
+ }
485
+ declare namespace PLUGIN_TYPE {
486
+ const LOCAL: string;
487
+ const GLOBAL: string;
488
+ }