@basalt.lab/basalt-logger 1.10.0 โ 1.11.2
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/build/chunk-9w8d7dhh.js +3 -0
- package/build/chunk-fjqkpbx0.js +2 -0
- package/build/common/error/basalt.error.d.ts +58 -28
- package/build/common/error/global.error.d.ts +4 -0
- package/build/common/error/index.d.ts +1 -1
- package/build/common/error/index.js +1 -1
- package/build/common/i18n/index.d.ts +9 -0
- package/build/common/i18n/index.js +1 -0
- package/build/domain/service/basaltLogger.service.d.ts +11 -4
- package/build/domain/service/basaltLogger.service.js +1 -1
- package/build/index.js +1 -1
- package/package.json +68 -13
- package/build/chunk-kadx22tz.js +0 -2
- package/build/chunk-xymy9zxw.js +0 -2
- package/build/common/error/keys.error.d.ts +0 -16
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{randomUUID as v}from"crypto";class w extends Error{cause;_uuidError=v();_date=new Date;_code;_fileName="";_line=0;_column=0;constructor(q){super(q?.key?.[0]||"error.unknown");if(super.name="BasaltError",this.cause=q?.cause,this._code=q?.key?.[1]||500,Error.captureStackTrace){Error.captureStackTrace(this,this.constructor);let u=this.stack?.split(`
|
|
2
|
+
`)[1]?.trim(),j=u?.match(/:(\d+):(\d+)\)$/);if(this._fileName=u?.split("(")[1]?.split(":")[0]||"",j)this._line=j[1]?parseInt(j[1],10):0,this._column=j[2]?parseInt(j[2],10):0}}get uuidError(){return this._uuidError}get date(){return this._date}get fileName(){return this._fileName}get line(){return this._line}get column(){return this._column}get code(){return this._code}}var A={STRATEGY_ALREADY_ADDED:["error.basalt-logger.strategy_already_added",500],STRATEGY_NOT_FOUND:["error.basalt-logger.strategy_not_found",500],NO_STRATEGY_ADDED:["error.basalt-logger.no_strategy_added",500]};
|
|
3
|
+
export{w as b,A as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as z,c as C}from"./chunk-9w8d7dhh.js";import{Transform as H}from"stream";class I{_strategies=new Map;_logStream;_pendingLogs=[];_maxPendingLogs=1e4;_writing=!1;constructor(){this._logStream=new H({objectMode:!0,transform:(q,w,x)=>{this.executeStrategies(q.level,new Date(q.date),q.object,q.strategiesNames),x()}})}addStrategy(q,w){if(this._strategies.has(q))throw new z({key:C.STRATEGY_ALREADY_ADDED,cause:{strategyName:q}});this._strategies.set(q,w)}removeStrategy(q){if(!this._strategies.has(q))throw new z({key:C.STRATEGY_NOT_FOUND,cause:{strategyName:q}});this._strategies.delete(q)}clearStrategies(){this._strategies.clear()}error(q,w){this.out("ERROR",q,w)}warn(q,w){this.out("WARN",q,w)}info(q,w){this.out("INFO",q,w)}debug(q,w){this.out("DEBUG",q,w)}log(q,w){this.out("LOG",q,w)}executeStrategies(q,w,x,D){for(let F of D)this._strategies.get(F)?.log(q,w,x)}out(q,w,x=[...this._strategies.keys()]){if(this._strategies.size===0)throw new z({key:C.NO_STRATEGY_ADDED});if(this._pendingLogs.length>=this._maxPendingLogs)return;let D={date:new Date().toISOString(),level:q,object:w,strategiesNames:x};if(this._pendingLogs.push(D),!this._writing)this._writing=!0,setImmediate(this.writeLog.bind(this))}writeLog(){let q=!0;while(q&&this._pendingLogs.length>0){let w=this._pendingLogs.shift();q=this._logStream.write(w)}if(!q)this._logStream.once("drain",this.writeLog.bind(this));else this._writing=!1}}
|
|
2
|
+
export{I as a};
|
|
@@ -1,24 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Represents the options for the Basalt error.
|
|
3
3
|
*/
|
|
4
|
-
export interface BasaltErrorOptions {
|
|
4
|
+
export interface BasaltErrorOptions<T = unknown> {
|
|
5
5
|
/**
|
|
6
6
|
* The error key.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
key?: [string, number] | undefined;
|
|
9
9
|
/**
|
|
10
|
-
* The
|
|
10
|
+
* The cause of the error.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The error detail.
|
|
15
|
-
*/
|
|
16
|
-
detail?: unknown;
|
|
12
|
+
cause?: T;
|
|
17
13
|
}
|
|
18
14
|
/**
|
|
19
|
-
*
|
|
15
|
+
* Basalt error class that extends the ({@link Error}) class and provides additional properties. (uuidError, date, code, fileName, line, column)
|
|
16
|
+
*
|
|
17
|
+
* @typeparam T - The type of the cause of the error.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* The following example demonstrates how to throw a new instance of the Basalt error.
|
|
21
|
+
* ```typescript
|
|
22
|
+
* try {
|
|
23
|
+
* throw new BasaltError();
|
|
24
|
+
* } catch (error) {
|
|
25
|
+
* console.log(error instanceof BasaltError); // true
|
|
26
|
+
* console.log(error instanceof Error); // true
|
|
27
|
+
* // u can access to uuidError, date, code, fileName, line, column, message, name, stack, cause
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
* @example
|
|
31
|
+
* The following example demonstrates how to create a new instance of the Basalt error with provided type for the cause.
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const basaltError: BasaltError<{ foo: 'bar' }> = new BasaltError({
|
|
34
|
+
* key: 'error.unknown',
|
|
35
|
+
* cause: {
|
|
36
|
+
* foo: 'bar',
|
|
37
|
+
* },
|
|
38
|
+
* });
|
|
39
|
+
* console.log(basaltError.cause); // { foo: 'bar' } if you make ctrl + space after cause. you will see the properties of the cause
|
|
40
|
+
* ```
|
|
20
41
|
*/
|
|
21
|
-
export declare class BasaltError extends Error {
|
|
42
|
+
export declare class BasaltError<T = unknown> extends Error {
|
|
43
|
+
readonly cause: T | undefined;
|
|
22
44
|
/**
|
|
23
45
|
* The unique identifier of the error.
|
|
24
46
|
* This identifier is used to track the error in the logs.
|
|
@@ -29,41 +51,49 @@ export declare class BasaltError extends Error {
|
|
|
29
51
|
*/
|
|
30
52
|
private readonly _date;
|
|
31
53
|
/**
|
|
32
|
-
* The error code.
|
|
54
|
+
* The error code. (HTTP status code)
|
|
33
55
|
*/
|
|
34
56
|
private readonly _code;
|
|
35
57
|
/**
|
|
36
|
-
* The error
|
|
58
|
+
* The fileName where the error occurred (if available).
|
|
37
59
|
*/
|
|
38
|
-
private readonly
|
|
60
|
+
private readonly _fileName;
|
|
39
61
|
/**
|
|
40
|
-
*
|
|
62
|
+
* The line number where the error occurred (if available).
|
|
63
|
+
*/
|
|
64
|
+
private readonly _line;
|
|
65
|
+
/**
|
|
66
|
+
* The column number where the error occurred (if available).
|
|
67
|
+
*/
|
|
68
|
+
private readonly _column;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a new instance of the Basalt error.
|
|
41
71
|
*
|
|
42
|
-
* @param basaltErrorOptions - The options
|
|
72
|
+
* @param basaltErrorOptions - The options for the Basalt error. ({@link BasaltErrorOptions})
|
|
43
73
|
*/
|
|
44
|
-
constructor(basaltErrorOptions
|
|
74
|
+
constructor(basaltErrorOptions?: Readonly<BasaltErrorOptions<T>>);
|
|
45
75
|
/**
|
|
46
76
|
* Gets the unique identifier of the error.
|
|
47
|
-
*
|
|
48
|
-
* @returns The unique identifier of the error.
|
|
49
77
|
*/
|
|
50
78
|
get uuidError(): string;
|
|
51
79
|
/**
|
|
52
80
|
* Gets the date when the error was created.
|
|
53
|
-
*
|
|
54
|
-
* @returns The date when the error was created.
|
|
55
81
|
*/
|
|
56
82
|
get date(): Date;
|
|
57
83
|
/**
|
|
58
|
-
* Gets the error
|
|
59
|
-
*
|
|
60
|
-
* @returns The error code.
|
|
84
|
+
* Gets the fileName where the error occurred (if available).
|
|
61
85
|
*/
|
|
62
|
-
get
|
|
86
|
+
get fileName(): string;
|
|
63
87
|
/**
|
|
64
|
-
* Gets the error
|
|
65
|
-
|
|
66
|
-
|
|
88
|
+
* Gets the line number where the error occurred (if available).
|
|
89
|
+
*/
|
|
90
|
+
get line(): number;
|
|
91
|
+
/**
|
|
92
|
+
* Gets the column number where the error occurred (if available).
|
|
67
93
|
*/
|
|
68
|
-
get
|
|
94
|
+
get column(): number;
|
|
95
|
+
/**
|
|
96
|
+
* Gets the error code.
|
|
97
|
+
*/
|
|
98
|
+
get code(): number;
|
|
69
99
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './basalt.error.ts';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './global.error.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../../chunk-x3cvtn7y.js";import{b as a,c as b}from"../../chunk-
|
|
1
|
+
import"../../chunk-x3cvtn7y.js";import{b as a,c as b}from"../../chunk-9w8d7dhh.js";export{b as GLOBAL_ERRORS,a as BasaltError};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ar from './ar.json';
|
|
2
|
+
import de from './de.json';
|
|
3
|
+
import en from './en.json';
|
|
4
|
+
import es from './es.json';
|
|
5
|
+
import fr from './fr.json';
|
|
6
|
+
import it from './it.json';
|
|
7
|
+
import ja from './ja.json';
|
|
8
|
+
import ko from './ko.json';
|
|
9
|
+
export { ar, de, en, es, fr, it, ja, ko };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a={error:{"basalt-logger":{no_strategy_added:"ูู
ูุชู
ุฅุถุงูุฉ ุฃู ุงุณุชุฑุงุชูุฌูุฉ",strategy_already_added:"ุงูุงุณุชุฑุงุชูุฌูุฉ ู
ุถุงูุฉ ุจุงููุนู",strategy_not_found:"ุงูุงุณุชุฑุงุชูุฌูุฉ ุบูุฑ ู
ูุฌูุฏุฉ"}}};var r={error:{"basalt-logger":{no_strategy_added:"Keine Strategie hinzugefรผgt",strategy_already_added:"Strategie bereits hinzugefรผgt",strategy_not_found:"Strategie nicht gefunden"}}};var o={error:{"basalt-logger":{no_strategy_added:"No strategy added",strategy_already_added:"Strategy already added",strategy_not_found:"Strategy not found"}}};var n={error:{"basalt-logger":{no_strategy_added:"No se ha aรฑadido ninguna estrategia",strategy_already_added:"Estrategia ya aรฑadida",strategy_not_found:"Estrategia no encontrada"}}};var _={error:{"basalt-logger":{no_strategy_added:"Aucune stratรฉgie ajoutรฉe",strategy_already_added:"La stratรฉgie a dรฉjร รฉtรฉ ajoutรฉe",strategy_not_found:"Stratรฉgie non trouvรฉe"}}};var i={error:{"basalt-logger":{no_strategy_added:"Nessuna strategia aggiunta",strategy_already_added:"Strategia giร aggiunta",strategy_not_found:"Strategia non trovata"}}};var f={error:{"basalt-logger":{no_strategy_added:"ๆฆ็ฅใ่ฟฝๅ ใใใฆใใพใใ",strategy_already_added:"ๆฆ็ฅใฏใใงใซ่ฟฝๅ ใใใฆใใพใ",strategy_not_found:"ๆฆ็ฅใ่ฆใคใใใพใใ"}}};var p={error:{"basalt-logger":{no_strategy_added:"์ ๋ต์ด ์ถ๊ฐ๋์ง ์์์ต๋๋ค",strategy_already_added:"์ ๋ต์ด ์ด๋ฏธ ์ถ๊ฐ๋์์ต๋๋ค",strategy_not_found:"์ ๋ต์ ์ฐพ์ ์ ์์ต๋๋ค"}}};export{p as ko,f as ja,i as it,_ as fr,n as es,o as en,r as de,a as ar};
|
|
@@ -24,7 +24,8 @@ export declare class BasaltLogger {
|
|
|
24
24
|
*/
|
|
25
25
|
private _writing;
|
|
26
26
|
/**
|
|
27
|
-
* Initializes the BasaltLogger.
|
|
27
|
+
* Initializes the BasaltLogger, creates the log stream ({@link Transform}).
|
|
28
|
+
* The log stream processes the log entries and executes the logging strategies.
|
|
28
29
|
*/
|
|
29
30
|
constructor();
|
|
30
31
|
/**
|
|
@@ -33,7 +34,7 @@ export declare class BasaltLogger {
|
|
|
33
34
|
* @param name - The name of the strategy.
|
|
34
35
|
* @param strategy - The strategy to add. ({@link LoggerStrategy})
|
|
35
36
|
*
|
|
36
|
-
* @throws ({@link BasaltError}) - If the strategy is already added. ({@link
|
|
37
|
+
* @throws ({@link BasaltError}) - If the strategy is already added. ({@link GLOBAL_ERRORS.STRATEGY_ALREADY_ADDED})
|
|
37
38
|
*/
|
|
38
39
|
addStrategy(name: string, strategy: LoggerStrategy): void;
|
|
39
40
|
/**
|
|
@@ -41,7 +42,7 @@ export declare class BasaltLogger {
|
|
|
41
42
|
*
|
|
42
43
|
* @param name - The name of the strategy.
|
|
43
44
|
*
|
|
44
|
-
* @throws ({@link BasaltError}) - If the strategy is not found. ({@link
|
|
45
|
+
* @throws ({@link BasaltError}) - If the strategy is not found. ({@link GLOBAL_ERRORS.STRATEGY_NOT_FOUND})
|
|
45
46
|
*/
|
|
46
47
|
removeStrategy(name: string): void;
|
|
47
48
|
/**
|
|
@@ -53,6 +54,8 @@ export declare class BasaltLogger {
|
|
|
53
54
|
*
|
|
54
55
|
* @param object - The object to log.
|
|
55
56
|
* @param strategiesNames - The names of the strategies to use. (default: all strategies)
|
|
57
|
+
*
|
|
58
|
+
* @throws ({@link BasaltError}) - If no strategy is added. ({@link GLOBAL_ERRORS.NO_STRATEGY_ADDED})
|
|
56
59
|
*/
|
|
57
60
|
error(object: unknown, strategiesNames?: string[]): void;
|
|
58
61
|
/**
|
|
@@ -60,6 +63,8 @@ export declare class BasaltLogger {
|
|
|
60
63
|
*
|
|
61
64
|
* @param object - The object to log.
|
|
62
65
|
* @param strategiesNames - The names of the strategies to use. (default: all strategies)
|
|
66
|
+
*
|
|
67
|
+
* @throws ({@link BasaltError}) - If no strategy is added. ({@link GLOBAL_ERRORS.NO_STRATEGY_ADDED})
|
|
63
68
|
*/
|
|
64
69
|
warn(object: unknown, strategiesNames?: string[]): void;
|
|
65
70
|
/**
|
|
@@ -67,6 +72,8 @@ export declare class BasaltLogger {
|
|
|
67
72
|
*
|
|
68
73
|
* @param object - The object to log.
|
|
69
74
|
* @param strategiesNames - The names of the strategies to use. (default: all strategies)
|
|
75
|
+
*
|
|
76
|
+
* @throws ({@link BasaltError}) - If no strategy is added. ({@link GLOBAL_ERRORS.NO_STRATEGY_ADDED})
|
|
70
77
|
*/
|
|
71
78
|
info(object: unknown, strategiesNames?: string[]): void;
|
|
72
79
|
/**
|
|
@@ -99,7 +106,7 @@ export declare class BasaltLogger {
|
|
|
99
106
|
* @param object - The object to log.
|
|
100
107
|
* @param strategiesNames - The names of the strategies to use. (default: all strategies)
|
|
101
108
|
*
|
|
102
|
-
* @throws ({@link BasaltError}) - If no strategy is added. ({@link
|
|
109
|
+
* @throws ({@link BasaltError}) - If no strategy is added. ({@link GLOBAL_ERRORS.NO_STRATEGY_ADDED})
|
|
103
110
|
*/
|
|
104
111
|
private out;
|
|
105
112
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-fjqkpbx0.js";import"../../chunk-9w8d7dhh.js";import"../../chunk-mcf4zz53.js";export{a as BasaltLogger};
|
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-x3cvtn7y.js";import"./chunk-amcnfafr.js";import{a as u}from"./chunk-
|
|
1
|
+
import"./chunk-x3cvtn7y.js";import"./chunk-amcnfafr.js";import{a as u}from"./chunk-fjqkpbx0.js";import{b as l,c as p}from"./chunk-9w8d7dhh.js";import{d as w,e as z}from"./chunk-wp46zt40.js";import{f as q}from"./chunk-mcf4zz53.js";export{q as LogLevels,p as GLOBAL_ERRORS,z as FileLoggerStrategy,w as ConsoleLoggerStrategy,u as BasaltLogger,l as BasaltError};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basalt.lab/basalt-logger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.2",
|
|
4
4
|
"description": "Logger module for Basalt Framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
"types": "./build/domain/service/strategy/index.d.js",
|
|
35
35
|
"import": "./build/domain/service/strategy/index.js",
|
|
36
36
|
"require": "./build/domain/service/strategy/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./translation": {
|
|
39
|
+
"types": "./build/common/i18n/index.d.js",
|
|
40
|
+
"import": "./build/common/i18n/index.js",
|
|
41
|
+
"require": "./build/common/i18n/index.js"
|
|
37
42
|
}
|
|
38
43
|
},
|
|
39
44
|
"scripts": {
|
|
@@ -61,17 +66,67 @@
|
|
|
61
66
|
"url": "https://github.com/Basalt-Lab/basalt-logger/issues"
|
|
62
67
|
},
|
|
63
68
|
"devDependencies": {
|
|
64
|
-
"@types/bun": "^1.1.
|
|
65
|
-
"@types/node": "^22.
|
|
66
|
-
"@eslint/js": "^9.
|
|
67
|
-
"@stylistic/eslint-plugin": "^2.
|
|
68
|
-
"eslint": "^9.
|
|
69
|
-
"eslint-plugin-tsdoc": "^0.
|
|
70
|
-
"
|
|
71
|
-
"typescript-eslint": "^8.13.0",
|
|
69
|
+
"@types/bun": "^1.1.14",
|
|
70
|
+
"@types/node": "^22.10.2",
|
|
71
|
+
"@eslint/js": "^9.17.0",
|
|
72
|
+
"@stylistic/eslint-plugin": "^2.12.1",
|
|
73
|
+
"eslint": "^9.17.0",
|
|
74
|
+
"eslint-plugin-tsdoc": "^0.4.0",
|
|
75
|
+
"typescript-eslint": "^8.18.1",
|
|
72
76
|
"tsc-alias": "^1.8.10",
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
77
|
+
"typedoc": "^0.27.5",
|
|
78
|
+
"typescript": "^5.7.2"
|
|
79
|
+
},
|
|
80
|
+
"changelog": {
|
|
81
|
+
"types": {
|
|
82
|
+
"feat": {
|
|
83
|
+
"title": "๐ Enhancements",
|
|
84
|
+
"semver": "minor"
|
|
85
|
+
},
|
|
86
|
+
"perf": {
|
|
87
|
+
"title": "โก Performance",
|
|
88
|
+
"semver": "patch"
|
|
89
|
+
},
|
|
90
|
+
"fix": {
|
|
91
|
+
"title": "๐ง Fixes",
|
|
92
|
+
"semver": "patch"
|
|
93
|
+
},
|
|
94
|
+
"refactor": {
|
|
95
|
+
"title": "๐งน Refactors",
|
|
96
|
+
"semver": "patch"
|
|
97
|
+
},
|
|
98
|
+
"docs": {
|
|
99
|
+
"title": "๐ Documentation",
|
|
100
|
+
"semver": "patch"
|
|
101
|
+
},
|
|
102
|
+
"build": {
|
|
103
|
+
"title": "๐ฆ Build",
|
|
104
|
+
"semver": "patch"
|
|
105
|
+
},
|
|
106
|
+
"types": {
|
|
107
|
+
"title": "๐ Types",
|
|
108
|
+
"semver": "patch"
|
|
109
|
+
},
|
|
110
|
+
"chore": {
|
|
111
|
+
"title": "๐ฆ Chore"
|
|
112
|
+
},
|
|
113
|
+
"examples": {
|
|
114
|
+
"title": "๐ Examples"
|
|
115
|
+
},
|
|
116
|
+
"test": {
|
|
117
|
+
"title": "๐งช Tests"
|
|
118
|
+
},
|
|
119
|
+
"style": {
|
|
120
|
+
"title": "๐จ Styles"
|
|
121
|
+
},
|
|
122
|
+
"ci": {
|
|
123
|
+
"title": "๐ค CI"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"templates": {
|
|
127
|
+
"commitMessage": "chore(๐ฆ): v{{newVersion}}",
|
|
128
|
+
"tagMessage": "v{{newVersion}}",
|
|
129
|
+
"tagBody": "v{{newVersion}}"
|
|
130
|
+
}
|
|
76
131
|
}
|
|
77
|
-
}
|
|
132
|
+
}
|
package/build/chunk-kadx22tz.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{randomUUID as k}from"crypto";class q extends Error{_uuidError=k();_date=new Date;_code;_detail;constructor(j){super();if(this._code=j.code??500,this.message=j.messageKey,this._detail=j.detail,this.name="BasaltError",Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}get uuidError(){return this._uuidError}get date(){return this._date}get code(){return this._code}get detail(){return this._detail}}var x={STRATEGY_ALREADY_ADDED:"error.basalt-logger.strategy_already_added",STRATEGY_NOT_FOUND:"error.basalt-logger.strategy_not_found",NO_STRATEGY_ADDED:"error.basalt-logger.no_strategy_added"};
|
|
2
|
-
export{q as b,x as c};
|
package/build/chunk-xymy9zxw.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{b as z,c as A}from"./chunk-kadx22tz.js";import{Transform as F}from"stream";class G{_strategies=new Map;_logStream;_pendingLogs=[];_maxPendingLogs=1e4;_writing=!1;constructor(){this._logStream=new F({objectMode:!0,transform:(q,w,x)=>{this.executeStrategies(q.level,new Date(q.date),q.object,q.strategiesNames),x()}})}addStrategy(q,w){if(this._strategies.has(q))throw new z({messageKey:A.STRATEGY_ALREADY_ADDED,detail:{strategyName:q}});this._strategies.set(q,w)}removeStrategy(q){if(!this._strategies.has(q))throw new z({messageKey:A.STRATEGY_NOT_FOUND,detail:{strategyName:q}});this._strategies.delete(q)}clearStrategies(){this._strategies.clear()}error(q,w){this.out("ERROR",q,w)}warn(q,w){this.out("WARN",q,w)}info(q,w){this.out("INFO",q,w)}debug(q,w){this.out("DEBUG",q,w)}log(q,w){this.out("LOG",q,w)}executeStrategies(q,w,x,C){for(let D of C)this._strategies.get(D)?.log(q,w,x)}out(q,w,x=[...this._strategies.keys()]){if(this._strategies.size===0)throw new z({messageKey:A.NO_STRATEGY_ADDED});if(this._pendingLogs.length>=this._maxPendingLogs)return;let C={date:new Date().toISOString(),level:q,object:w,strategiesNames:x};if(this._pendingLogs.push(C),!this._writing)this._writing=!0,setImmediate(this.writeLog.bind(this))}writeLog(){let q=!0;while(q&&this._pendingLogs.length>0){let w=this._pendingLogs.shift();q=this._logStream.write(w)}if(!q)this._logStream.once("drain",this.writeLog.bind(this));else this._writing=!1}}
|
|
2
|
-
export{G as a};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error keys for the Basalt logger
|
|
3
|
-
*/
|
|
4
|
-
export declare const ErrorKeys: {
|
|
5
|
-
/**
|
|
6
|
-
* Interpolation :
|
|
7
|
-
* - strategyName : The name of the strategy.
|
|
8
|
-
*/
|
|
9
|
-
STRATEGY_ALREADY_ADDED: string;
|
|
10
|
-
/**
|
|
11
|
-
* Interpolation :
|
|
12
|
-
* - strategyName : The name of the strategy
|
|
13
|
-
*/
|
|
14
|
-
STRATEGY_NOT_FOUND: string;
|
|
15
|
-
NO_STRATEGY_ADDED: string;
|
|
16
|
-
};
|