namirasoft-log 1.3.10 → 1.3.11

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.
@@ -1,11 +1,11 @@
1
1
  export declare enum LogLevel {
2
- "Trace" = 0,
3
- "Verbose" = 1,
4
- "Debug" = 2,
5
- "Info" = 3,
6
- "Success" = 4,
7
- "Warning" = 5,
8
- "Error" = 6,
9
- "Critical" = 7,
10
- "Fatal" = 8
2
+ Trace = "Trace",
3
+ Verbose = "Verbose",
4
+ Debug = "Debug",
5
+ Info = "Info",
6
+ Success = "Success",
7
+ Warning = "Warning",
8
+ Error = "Error",
9
+ Critical = "Critical",
10
+ Fatal = "Fatal"
11
11
  }
package/dist/LogLevel.js CHANGED
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LogLevel = void 0;
4
4
  var LogLevel;
5
5
  (function (LogLevel) {
6
- LogLevel[LogLevel["Trace"] = 0] = "Trace";
7
- LogLevel[LogLevel["Verbose"] = 1] = "Verbose";
8
- LogLevel[LogLevel["Debug"] = 2] = "Debug";
9
- LogLevel[LogLevel["Info"] = 3] = "Info";
10
- LogLevel[LogLevel["Success"] = 4] = "Success";
11
- LogLevel[LogLevel["Warning"] = 5] = "Warning";
12
- LogLevel[LogLevel["Error"] = 6] = "Error";
13
- LogLevel[LogLevel["Critical"] = 7] = "Critical";
14
- LogLevel[LogLevel["Fatal"] = 8] = "Fatal";
6
+ LogLevel["Trace"] = "Trace";
7
+ LogLevel["Verbose"] = "Verbose";
8
+ LogLevel["Debug"] = "Debug";
9
+ LogLevel["Info"] = "Info";
10
+ LogLevel["Success"] = "Success";
11
+ LogLevel["Warning"] = "Warning";
12
+ LogLevel["Error"] = "Error";
13
+ LogLevel["Critical"] = "Critical";
14
+ LogLevel["Fatal"] = "Fatal";
15
15
  })(LogLevel || (exports.LogLevel = LogLevel = {}));
16
16
  //# sourceMappingURL=LogLevel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LogLevel.js","sourceRoot":"","sources":["../src/LogLevel.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAWX;AAXD,WAAY,QAAQ;IAEhB,yCAAO,CAAA;IACP,6CAAS,CAAA;IACT,yCAAO,CAAA;IACP,uCAAM,CAAA;IACN,6CAAS,CAAA;IACT,6CAAS,CAAA;IACT,yCAAO,CAAA;IACP,+CAAU,CAAA;IACV,yCAAO,CAAA;AACX,CAAC,EAXW,QAAQ,wBAAR,QAAQ,QAWnB"}
1
+ {"version":3,"file":"LogLevel.js","sourceRoot":"","sources":["../src/LogLevel.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAWX;AAXD,WAAY,QAAQ;IAEhB,2BAAe,CAAA;IACf,+BAAmB,CAAA;IACnB,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,+BAAmB,CAAA;IACnB,+BAAmB,CAAA;IACnB,2BAAe,CAAA;IACf,iCAAqB,CAAA;IACrB,2BAAe,CAAA;AACnB,CAAC,EAXW,QAAQ,wBAAR,QAAQ,QAWnB"}
@@ -5,31 +5,29 @@ const namirasoft_core_1 = require("namirasoft-core");
5
5
  const LogLevel_1 = require("./LogLevel");
6
6
  class StreamConsole {
7
7
  write(log, formated) {
8
- let writter = (data) => {
8
+ let getFormatted = (data) => {
9
9
  if (log.level == LogLevel_1.LogLevel.Trace)
10
- namirasoft_core_1.ConsoleOperation.trace(data);
11
- else if (log.level == LogLevel_1.LogLevel.Verbose)
12
- namirasoft_core_1.ConsoleOperation.log(data);
13
- else if (log.level == LogLevel_1.LogLevel.Debug)
14
- namirasoft_core_1.ConsoleOperation.debug(data);
15
- else if (log.level == LogLevel_1.LogLevel.Info)
16
- namirasoft_core_1.ConsoleOperation.info(data);
17
- else if (log.level == LogLevel_1.LogLevel.Success)
18
- namirasoft_core_1.ConsoleOperation.success(data);
19
- else if (log.level == LogLevel_1.LogLevel.Warning)
20
- namirasoft_core_1.ConsoleOperation.warning(data);
21
- else if (log.level == LogLevel_1.LogLevel.Error)
22
- namirasoft_core_1.ConsoleOperation.error(data);
23
- else if (log.level == LogLevel_1.LogLevel.Critical)
24
- namirasoft_core_1.ConsoleOperation.error(data);
25
- else if (log.level == LogLevel_1.LogLevel.Fatal)
26
- namirasoft_core_1.ConsoleOperation.error(data);
27
- else
28
- namirasoft_core_1.ConsoleOperation.log(data);
10
+ return namirasoft_core_1.ConsoleOperation.trace(data);
11
+ if (log.level == LogLevel_1.LogLevel.Verbose)
12
+ return namirasoft_core_1.ConsoleOperation.log(data);
13
+ if (log.level == LogLevel_1.LogLevel.Debug)
14
+ return namirasoft_core_1.ConsoleOperation.debug(data);
15
+ if (log.level == LogLevel_1.LogLevel.Info)
16
+ return namirasoft_core_1.ConsoleOperation.info(data);
17
+ if (log.level == LogLevel_1.LogLevel.Success)
18
+ return namirasoft_core_1.ConsoleOperation.success(data);
19
+ if (log.level == LogLevel_1.LogLevel.Warning)
20
+ return namirasoft_core_1.ConsoleOperation.warning(data);
21
+ if (log.level == LogLevel_1.LogLevel.Error)
22
+ return namirasoft_core_1.ConsoleOperation.error(data);
23
+ if (log.level == LogLevel_1.LogLevel.Critical)
24
+ return namirasoft_core_1.ConsoleOperation.error(data);
25
+ if (log.level == LogLevel_1.LogLevel.Fatal)
26
+ return namirasoft_core_1.ConsoleOperation.error(data);
27
+ return namirasoft_core_1.ConsoleOperation.log(data);
29
28
  };
30
- formated.pre.forEach(f => namirasoft_core_1.ConsoleOperation.log(f));
31
- formated.messages.forEach(f => writter(f));
32
- formated.post.forEach(f => namirasoft_core_1.ConsoleOperation.log(f));
29
+ let lines = [...formated.pre.map(f => namirasoft_core_1.ConsoleOperation.formatLogColor(f)), ...formated.messages.map(f => getFormatted(f)), ...formated.post.map(f => namirasoft_core_1.ConsoleOperation.log(f))];
30
+ console.log(lines.join("\n"));
33
31
  }
34
32
  }
35
33
  exports.StreamConsole = StreamConsole;
@@ -1 +1 @@
1
- {"version":3,"file":"StreamConsole.js","sourceRoot":"","sources":["../src/StreamCons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7B,OAAO,kCAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YAC1C,IAAI,GAAG,CAAC,KAAK,IAAI,mBAAQ,CAAC,KAAK;gBAC3B,OAAO,kCAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACxC,IAAI,GAAG,CAAC,KAAK,IAAI,mBAAQ,CAAC,QAAQ;gBAC9B,OAAO,kCAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACxC,IAAI,GAAG,CAAC,KAAK,IAAI,mBAAQ,CAAC,KAAK;gBAC3B,OAAO,kCAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACxC,OAAO,kCAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,CAAC,CAAA;QACD,IAAI,KAAK,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,kCAAgB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,kCAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QAC9K,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClC,CAAC;CACJ;AA7BD,sCA6BC"}
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "framework": "npm",
9
9
  "application": "package",
10
10
  "private": false,
11
- "version": "1.3.10",
11
+ "version": "1.3.11",
12
12
  "author": "Amir Abolhasani",
13
13
  "license": "MIT",
14
14
  "main": "./dist/index.js",
package/src/LogLevel.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export enum LogLevel
2
2
  {
3
- "Trace",
4
- "Verbose",
5
- "Debug",
6
- "Info",
7
- "Success",
8
- "Warning",
9
- "Error",
10
- "Critical",
11
- "Fatal"
12
- }
3
+ Trace = "Trace",
4
+ Verbose = "Verbose",
5
+ Debug = "Debug",
6
+ Info = "Info",
7
+ Success = "Success",
8
+ Warning = "Warning",
9
+ Error = "Error",
10
+ Critical = "Critical",
11
+ Fatal = "Fatal"
12
+ }
@@ -7,31 +7,29 @@ export class StreamConsole implements IStream
7
7
  {
8
8
  write(log: Log, formated: { pre: string[], messages: string[], post: string[] }): void
9
9
  {
10
- let writter = (data: string) =>
10
+ let getFormatted = (data: string) =>
11
11
  {
12
12
  if (log.level == LogLevel.Trace)
13
- ConsoleOperation.trace(data);
14
- else if (log.level == LogLevel.Verbose)
15
- ConsoleOperation.log(data);
16
- else if (log.level == LogLevel.Debug)
17
- ConsoleOperation.debug(data);
18
- else if (log.level == LogLevel.Info)
19
- ConsoleOperation.info(data);
20
- else if (log.level == LogLevel.Success)
21
- ConsoleOperation.success(data);
22
- else if (log.level == LogLevel.Warning)
23
- ConsoleOperation.warning(data);
24
- else if (log.level == LogLevel.Error)
25
- ConsoleOperation.error(data);
26
- else if (log.level == LogLevel.Critical)
27
- ConsoleOperation.error(data);
28
- else if (log.level == LogLevel.Fatal)
29
- ConsoleOperation.error(data);
30
- else
31
- ConsoleOperation.log(data);
13
+ return ConsoleOperation.trace(data);
14
+ if (log.level == LogLevel.Verbose)
15
+ return ConsoleOperation.log(data);
16
+ if (log.level == LogLevel.Debug)
17
+ return ConsoleOperation.debug(data);
18
+ if (log.level == LogLevel.Info)
19
+ return ConsoleOperation.info(data);
20
+ if (log.level == LogLevel.Success)
21
+ return ConsoleOperation.success(data);
22
+ if (log.level == LogLevel.Warning)
23
+ return ConsoleOperation.warning(data);
24
+ if (log.level == LogLevel.Error)
25
+ return ConsoleOperation.error(data);
26
+ if (log.level == LogLevel.Critical)
27
+ return ConsoleOperation.error(data);
28
+ if (log.level == LogLevel.Fatal)
29
+ return ConsoleOperation.error(data);
30
+ return ConsoleOperation.log(data);
32
31
  }
33
- formated.pre.forEach(f => ConsoleOperation.log(f));
34
- formated.messages.forEach(f => writter(f));
35
- formated.post.forEach(f => ConsoleOperation.log(f));
32
+ let lines = [...formated.pre.map(f => ConsoleOperation.formatLogColor(f)), ...formated.messages.map(f => getFormatted(f)), ...formated.post.map(f => ConsoleOperation.log(f))]
33
+ console.log(lines.join("\n"));
36
34
  }
37
35
  }