emilsoftware-utilities 1.1.4 → 1.1.5

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/logger.d.ts CHANGED
@@ -8,6 +8,7 @@ export declare class Logger {
8
8
  private readonly winstonLogger;
9
9
  private readonly tag;
10
10
  private logFormat;
11
+ private replaceAll;
11
12
  constructor(tag: string);
12
13
  private getFileName;
13
14
  execStart(prefix?: string): number;
package/logger.js CHANGED
@@ -48,12 +48,11 @@ var LogLevels;
48
48
  })(LogLevels || (exports.LogLevels = LogLevels = {}));
49
49
  var Logger = /** @class */ (function () {
50
50
  function Logger(tag) {
51
+ var _this = this;
51
52
  this.tag = "[UNTAGGED]";
52
53
  this.logFormat = winston_1.default.format.printf(function (tmp) {
53
54
  var time = tmp.time, file = tmp.file, level = tmp.level, message = tmp.message;
54
- var oldChar = "\\";
55
- var newChar = "/";
56
- return "".concat(JSON.stringify({ time: time, file: file === null || file === void 0 ? void 0 : file.replace(new RegExp(oldChar, 'g'), newChar), level: level, message: message }), ",");
55
+ return "".concat(JSON.stringify({ time: time, file: _this.replaceAll(file, "\\", "/"), level: level, message: message }), ",");
57
56
  });
58
57
  var fileName = this.getFileName();
59
58
  var logsDirectory = "logs";
@@ -67,6 +66,9 @@ var Logger = /** @class */ (function () {
67
66
  transports: [new winston_1.default.transports.File({ filename: logFilePath, format: this.logFormat })],
68
67
  });
69
68
  }
69
+ Logger.prototype.replaceAll = function (string, match, replacer) {
70
+ return string.replace(new RegExp(match, 'g'), replacer);
71
+ };
70
72
  Logger.prototype.getFileName = function () {
71
73
  var now = new Date();
72
74
  return now.getDate() + "-" + (now.getMonth() + 1) + "-" + now.getFullYear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emilsoftware-utilities",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "Utilities for EmilSoftware",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/logger.ts CHANGED
@@ -12,12 +12,13 @@ export class Logger {
12
12
 
13
13
  private logFormat: winston.Logform.Format = winston.format.printf((tmp: winston.Logform.TransformableInfo): string => {
14
14
  const {time, file, level, message} = tmp;
15
-
16
- let oldChar: string = "\\";
17
- let newChar: string = "/";
18
- return `${JSON.stringify({time, file: file?.replace(new RegExp(oldChar, 'g'), newChar), level, message})},`;
15
+ return `${JSON.stringify({time, file: this.replaceAll(file, "\\", "/"), level, message})},`;
19
16
  });
20
17
 
18
+ private replaceAll(string: string, match: string, replacer: string) {
19
+ return string.replace(new RegExp(match, 'g'), replacer);
20
+ }
21
+
21
22
  constructor(tag: string) {
22
23
  const fileName: string = this.getFileName();
23
24
  const logsDirectory = "logs";