namirasoft-log 1.1.1 → 1.1.3
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/dist/StreamConsole.js +19 -9
- package/dist/StreamConsole.js.map +1 -1
- package/package.json +2 -2
- package/src/StreamConsole.ts +19 -9
package/dist/StreamConsole.js
CHANGED
|
@@ -14,25 +14,35 @@ const LogLevel_1 = require("./LogLevel");
|
|
|
14
14
|
class StreamConsole {
|
|
15
15
|
write(log, formated) {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const colors = {
|
|
18
|
+
reset: '\x1b[0m',
|
|
19
|
+
red: '\x1b[31m',
|
|
20
|
+
green: '\x1b[32m',
|
|
21
|
+
yellow: '\x1b[33m',
|
|
22
|
+
blue: '\x1b[34m',
|
|
23
|
+
magenta: '\x1b[35m',
|
|
24
|
+
cyan: '\x1b[36m',
|
|
25
|
+
white: '\x1b[37m',
|
|
26
|
+
};
|
|
17
27
|
formated.forEach(f => {
|
|
18
28
|
if (log.level == LogLevel_1.LogLevel.Trace)
|
|
19
|
-
console.trace(f);
|
|
29
|
+
console.trace(colors.blue + f + colors.reset);
|
|
20
30
|
else if (log.level == LogLevel_1.LogLevel.Verbose)
|
|
21
|
-
console.log(f);
|
|
31
|
+
console.log(colors.cyan + f + colors.reset);
|
|
22
32
|
else if (log.level == LogLevel_1.LogLevel.Debug)
|
|
23
|
-
console.debug(f);
|
|
33
|
+
console.debug(colors.magenta + f + colors.reset);
|
|
24
34
|
else if (log.level == LogLevel_1.LogLevel.Info)
|
|
25
|
-
console.info(f);
|
|
35
|
+
console.info(colors.green + f + colors.reset);
|
|
26
36
|
else if (log.level == LogLevel_1.LogLevel.Warning)
|
|
27
|
-
console.warn(f);
|
|
37
|
+
console.warn(colors.yellow + f + colors.reset);
|
|
28
38
|
else if (log.level == LogLevel_1.LogLevel.Error)
|
|
29
|
-
console.error(f);
|
|
39
|
+
console.error(colors.red + f + colors.reset);
|
|
30
40
|
else if (log.level == LogLevel_1.LogLevel.Critical)
|
|
31
|
-
console.error(f);
|
|
41
|
+
console.error(colors.red + f + colors.reset);
|
|
32
42
|
else if (log.level == LogLevel_1.LogLevel.Fatal)
|
|
33
|
-
console.error(f);
|
|
43
|
+
console.error(colors.red + f + colors.reset);
|
|
34
44
|
else
|
|
35
|
-
console.log(f);
|
|
45
|
+
console.log(colors.white + f + colors.reset);
|
|
36
46
|
});
|
|
37
47
|
});
|
|
38
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StreamConsole.js","sourceRoot":"","sources":["../src/StreamConsole.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAsC;AAEtC,MAAa,aAAa;IAEhB,KAAK,CAAC,GAAQ,EAAE,QAAkB;;YAEpC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;gBAEjB,IAAI,GAAG,CAAC,KAAK,IAAI,mBAAQ,CAAC,KAAK;oBAC3B,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"StreamConsole.js","sourceRoot":"","sources":["../src/StreamConsole.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yCAAsC;AAEtC,MAAa,aAAa;IAEhB,KAAK,CAAC,GAAQ,EAAE,QAAkB;;YAEpC,MAAM,MAAM,GAAG;gBACX,KAAK,EAAE,SAAS;gBAChB,GAAG,EAAE,UAAU;gBACf,KAAK,EAAE,UAAU;gBACjB,MAAM,EAAE,UAAU;gBAClB,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,UAAU;gBACnB,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;aACpB,CAAC;YACF,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;gBAEjB,IAAI,GAAG,CAAC,KAAK,IAAI,mBAAQ,CAAC,KAAK;oBAC3B,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,GAAG,CA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AC;YACrD,CAAC,CAAC,CAAA;QACN,CAAC;KAAA;CACJ;AApCD,sCAoCC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "namirasoft-log",
|
|
3
3
|
"description": "Namira Software Corporation Log NPM Package",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.3",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"scripts": {},
|
|
8
8
|
"author": "Amir Abolhasani",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"devDependencies": {
|
|
11
|
-
"@types/node": "^20.9.
|
|
11
|
+
"@types/node": "^20.9.5"
|
|
12
12
|
}
|
|
13
13
|
}
|
package/src/StreamConsole.ts
CHANGED
|
@@ -6,26 +6,36 @@ export class StreamConsole implements IStream
|
|
|
6
6
|
{
|
|
7
7
|
async write(log: Log, formated: string[]): Promise<void>
|
|
8
8
|
{
|
|
9
|
+
const colors = {
|
|
10
|
+
reset: '\x1b[0m',
|
|
11
|
+
red: '\x1b[31m',
|
|
12
|
+
green: '\x1b[32m',
|
|
13
|
+
yellow: '\x1b[33m',
|
|
14
|
+
blue: '\x1b[34m',
|
|
15
|
+
magenta: '\x1b[35m',
|
|
16
|
+
cyan: '\x1b[36m',
|
|
17
|
+
white: '\x1b[37m',
|
|
18
|
+
};
|
|
9
19
|
formated.forEach(f =>
|
|
10
20
|
{
|
|
11
21
|
if (log.level == LogLevel.Trace)
|
|
12
|
-
console.trace(f);
|
|
22
|
+
console.trace(colors.blue + f + colors.reset);
|
|
13
23
|
else if (log.level == LogLevel.Verbose)
|
|
14
|
-
console.log(f);
|
|
24
|
+
console.log(colors.cyan + f + colors.reset);
|
|
15
25
|
else if (log.level == LogLevel.Debug)
|
|
16
|
-
console.debug(f);
|
|
26
|
+
console.debug(colors.magenta + f + colors.reset);
|
|
17
27
|
else if (log.level == LogLevel.Info)
|
|
18
|
-
console.info(f);
|
|
28
|
+
console.info(colors.green + f + colors.reset);
|
|
19
29
|
else if (log.level == LogLevel.Warning)
|
|
20
|
-
console.warn(f);
|
|
30
|
+
console.warn(colors.yellow + f + colors.reset);
|
|
21
31
|
else if (log.level == LogLevel.Error)
|
|
22
|
-
console.error(f);
|
|
32
|
+
console.error(colors.red + f + colors.reset);
|
|
23
33
|
else if (log.level == LogLevel.Critical)
|
|
24
|
-
console.error(f);
|
|
34
|
+
console.error(colors.red + f + colors.reset);
|
|
25
35
|
else if (log.level == LogLevel.Fatal)
|
|
26
|
-
console.error(f);
|
|
36
|
+
console.error(colors.red + f + colors.reset);
|
|
27
37
|
else
|
|
28
|
-
console.log(f);
|
|
38
|
+
console.log(colors.white + f + colors.reset);
|
|
29
39
|
})
|
|
30
40
|
}
|
|
31
41
|
}
|