emilsoftware-utilities 1.2.2 → 1.2.4

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.
Files changed (3) hide show
  1. package/logger.js +12 -3
  2. package/package.json +1 -1
  3. package/src/logger.ts +12 -3
package/logger.js CHANGED
@@ -80,7 +80,16 @@ var Logger = /** @class */ (function () {
80
80
  };
81
81
  Logger.prototype.getFileName = function () {
82
82
  var now = new Date();
83
- return now.getDate() + "-" + (now.getMonth() + 1) + "-" + now.getFullYear();
83
+ var date = now.getDate();
84
+ var dateString = "" + date;
85
+ if (date < 10)
86
+ dateString = "0" + dateString;
87
+ var month = (now.getMonth() + 1);
88
+ var monthString = "" + month;
89
+ if (month < 10)
90
+ monthString = "0" + monthString;
91
+ var yearString = now.getFullYear() + "";
92
+ return dateString + "-" + monthString + "-" + yearString;
84
93
  };
85
94
  Logger.prototype.execStart = function (prefix) {
86
95
  if (prefix === void 0) { prefix = ""; }
@@ -156,7 +165,7 @@ var Logger = /** @class */ (function () {
156
165
  file: tag, time: now,
157
166
  level: level
158
167
  };
159
- var logEntry = { level: level, message: __spreadArray([], data, true).join(",") };
168
+ var logEntry = { level: level.toLowerCase(), message: __spreadArray([], data, true).join(",") };
160
169
  //JSON.stringify([...data]);
161
170
  switch (level) {
162
171
  case LogLevels.INFO:
@@ -176,7 +185,7 @@ var Logger = /** @class */ (function () {
176
185
  console.log("[LOG][".concat(now, "][").concat(tag, "]"), logEntry.message);
177
186
  }
178
187
  case LogLevels.DATABASE: {
179
- this.winstonLogger.log(logEntry);
188
+ this.winstonLogger.info(logEntry);
180
189
  console.log("[DATABASE][".concat(now, "][").concat(tag, "]"), logEntry.message);
181
190
  }
182
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emilsoftware-utilities",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Utilities for EmilSoftware",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/logger.ts CHANGED
@@ -48,7 +48,16 @@ export class Logger {
48
48
 
49
49
  private getFileName(): string {
50
50
  const now = new Date();
51
- return now.getDate() + "-" + (now.getMonth() + 1) + "-" + now.getFullYear();
51
+ let date = now.getDate();
52
+ let dateString = "" + date;
53
+ if (date < 10) dateString = "0" + dateString;
54
+
55
+ let month = (now.getMonth() + 1);
56
+ let monthString = "" + month;
57
+ if (month < 10) monthString = "0" + monthString;
58
+
59
+ let yearString = now.getFullYear() + "";
60
+ return dateString + "-" + monthString + "-" + yearString;
52
61
  }
53
62
 
54
63
  public execStart(prefix: string = ""): number {
@@ -106,7 +115,7 @@ export class Logger {
106
115
  file: tag, time: now, level
107
116
  };
108
117
 
109
- let logEntry: winston.LogEntry = {level: level, message: [...data].join(",")};
118
+ let logEntry: winston.LogEntry = {level: level.toLowerCase(), message: [...data].join(",")};
110
119
  //JSON.stringify([...data]);
111
120
  switch (level) {
112
121
  case LogLevels.INFO:
@@ -126,7 +135,7 @@ export class Logger {
126
135
  console.log(`[LOG][${now}][${tag}]`, logEntry.message);
127
136
  }
128
137
  case LogLevels.DATABASE: {
129
- this.winstonLogger.log(logEntry);
138
+ this.winstonLogger.info(logEntry);
130
139
  console.log(`[DATABASE][${now}][${tag}]`, logEntry.message);
131
140
  }
132
141
  }