@spinajs/log 1.2.75 → 1.2.83
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/lib/bootstrap.js +4 -1
- package/lib/bootstrap.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/log.d.ts +2 -3
- package/lib/log.js +9 -4
- package/lib/log.js.map +1 -1
- package/lib/schemas/log.configuration.d.ts +0 -29
- package/lib/schemas/log.configuration.js +0 -29
- package/lib/schemas/log.configuration.js.map +1 -1
- package/lib/targets/BlackHoleTarget.d.ts +1 -2
- package/lib/targets/BlackHoleTarget.js +2 -2
- package/lib/targets/BlackHoleTarget.js.map +1 -1
- package/lib/targets/ColoredConsoleTarget.d.ts +4 -3
- package/lib/targets/ColoredConsoleTarget.js +16 -7
- package/lib/targets/ColoredConsoleTarget.js.map +1 -1
- package/lib/targets/FileTarget.d.ts +16 -13
- package/lib/targets/FileTarget.js +124 -66
- package/lib/targets/FileTarget.js.map +1 -1
- package/lib/targets/index.d.ts +0 -1
- package/lib/targets/index.js +5 -2
- package/lib/targets/index.js.map +1 -1
- package/package.json +10 -8
- package/lib/config/log.d.ts +0 -8
- package/lib/config/log.js +0 -15
- package/lib/config/log.js.map +0 -1
- package/lib/logger.d.ts +0 -4
- package/lib/logger.js +0 -30
- package/lib/logger.js.map +0 -1
- package/lib/targets/LogTarget.d.ts +0 -14
- package/lib/targets/LogTarget.js +0 -20
- package/lib/targets/LogTarget.js.map +0 -1
- package/lib/types.d.ts +0 -148
- package/lib/types.js +0 -38
- package/lib/types.js.map +0 -1
- package/lib/variables/date.d.ts +0 -17
- package/lib/variables/date.js +0 -62
- package/lib/variables/date.js.map +0 -1
- package/lib/variables/env.d.ts +0 -5
- package/lib/variables/env.js +0 -25
- package/lib/variables/env.js.map +0 -1
- package/lib/variables/index.d.ts +0 -3
- package/lib/variables/index.js +0 -16
- package/lib/variables/index.js.map +0 -1
- package/lib/variables/process.d.ts +0 -5
- package/lib/variables/process.js +0 -24
- package/lib/variables/process.js.map +0 -1
- package/yarn-error.log +0 -2383
|
@@ -1,60 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
2
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
21
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
23
|
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
+
if (mod && mod.__esModule) return mod;
|
|
26
|
+
var result = {};
|
|
27
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
+
__setModuleDefault(result, mod);
|
|
29
|
+
return result;
|
|
30
|
+
};
|
|
8
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
32
|
exports.FileTarget = void 0;
|
|
33
|
+
const os_1 = require("os");
|
|
10
34
|
/* eslint security/detect-non-literal-fs-filename:0 -- Safe as no value holds user input */
|
|
11
35
|
const di_1 = require("@spinajs/di");
|
|
12
|
-
const
|
|
13
|
-
const fs = require("fs");
|
|
14
|
-
const path = require("path");
|
|
36
|
+
const log_common_1 = require("@spinajs/log-common");
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
15
39
|
const node_schedule_1 = require("node-schedule");
|
|
16
40
|
const exceptions_1 = require("@spinajs/exceptions");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const zlib = require("zlib");
|
|
41
|
+
const glob = __importStar(require("glob"));
|
|
42
|
+
const zlib = __importStar(require("zlib"));
|
|
20
43
|
const configuration_1 = require("@spinajs/configuration");
|
|
21
|
-
|
|
44
|
+
const stream_1 = require("stream");
|
|
45
|
+
let FileTarget = class FileTarget extends log_common_1.LogTarget {
|
|
22
46
|
constructor() {
|
|
23
47
|
super(...arguments);
|
|
24
|
-
this.
|
|
25
|
-
this.Buffer = [];
|
|
48
|
+
this.IsArchiving = false;
|
|
26
49
|
}
|
|
27
|
-
resolve() {
|
|
50
|
+
async resolve() {
|
|
28
51
|
this.Options.options = Object.assign({
|
|
29
52
|
compress: true,
|
|
30
53
|
maxSize: 1024 * 1024,
|
|
31
54
|
maxArchiveFiles: 5,
|
|
32
|
-
bufferSize: 8 * 1024,
|
|
33
|
-
flushTimeout: 10 * 1000,
|
|
34
55
|
}, this.Options.options);
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
57
|
+
this.ReadStream = new stream_1.Readable({ encoding: "utf-8", read: () => { } });
|
|
58
|
+
this.ReadStream.on("data", (chunk) => {
|
|
59
|
+
this.CurrentFileSize += chunk.length;
|
|
60
|
+
});
|
|
35
61
|
this.initialize();
|
|
36
62
|
this.rotate();
|
|
37
|
-
process.on("exit", () => {
|
|
38
|
-
this.flush();
|
|
39
|
-
});
|
|
40
63
|
super.resolve();
|
|
41
64
|
}
|
|
42
|
-
write(data) {
|
|
65
|
+
async write(data) {
|
|
43
66
|
if (!this.Options.enabled) {
|
|
44
67
|
return;
|
|
45
68
|
}
|
|
46
|
-
const result = (0, configuration_1.format)(data.Variables, this.Options.layout) + os_1.EOL;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.Buffer.push(result);
|
|
50
|
-
if (this.BufferSize > this.Options.options.bufferSize) {
|
|
51
|
-
this.flush();
|
|
69
|
+
const result = this.ReadStream.push((0, configuration_1.format)(data.Variables, this.Options.layout) + os_1.EOL);
|
|
70
|
+
if (!result) {
|
|
71
|
+
throw new Error();
|
|
52
72
|
}
|
|
53
|
-
if (this.CurrentFileSize
|
|
73
|
+
if (this.CurrentFileSize >= this.Options.options.maxSize && !this.IsArchiving) {
|
|
54
74
|
this.archive();
|
|
55
75
|
}
|
|
56
76
|
}
|
|
57
77
|
archive() {
|
|
78
|
+
this.IsArchiving = true;
|
|
58
79
|
const files = glob
|
|
59
80
|
.sync(path.join(this.ArchiveDirPath, `archived_${this.LogBaseName}*{${this.LogFileExt},.gzip}`))
|
|
60
81
|
.map((f) => {
|
|
@@ -66,45 +87,62 @@ let FileTarget = class FileTarget extends LogTarget_1.LogTarget {
|
|
|
66
87
|
.sort((x) => x.stat.mtime.getTime());
|
|
67
88
|
const newestFile = files.length !== 0 ? files[files.length - 1].name : undefined;
|
|
68
89
|
const fIndex = newestFile ? parseInt(newestFile.substring(newestFile.lastIndexOf("_") + 1, newestFile.lastIndexOf("_") + 2), 10) + 1 : 1;
|
|
90
|
+
const renPath = this.LogPath + ".bck";
|
|
69
91
|
const archPath = path.join(this.ArchiveDirPath, `archived_${this.LogBaseName}_${fIndex}${this.LogFileExt}`);
|
|
70
|
-
this.flush();
|
|
71
92
|
if (!fs.existsSync(this.LogPath)) {
|
|
72
93
|
return;
|
|
73
94
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
this.WriteStream.once("close", () => {
|
|
96
|
+
fs.rename(this.LogPath, renPath, (err) => {
|
|
97
|
+
if (!err) {
|
|
98
|
+
fs.copyFile(renPath, archPath, (err) => {
|
|
99
|
+
if (!err) {
|
|
100
|
+
fs.unlink(this.LogPath, () => {
|
|
101
|
+
this.initialize();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (this.Options.options.compress) {
|
|
108
|
+
const zippedPath = path.join(this.ArchiveDirPath, `archived_${this.LogBaseName}_${fIndex}${this.LogFileExt}.gzip`);
|
|
109
|
+
const zip = zlib.createGzip();
|
|
110
|
+
const read = fs.createReadStream(archPath);
|
|
111
|
+
const write = fs.createWriteStream(zippedPath);
|
|
112
|
+
(0, stream_1.pipeline)(read, zip, write, (err) => {
|
|
113
|
+
if (err) {
|
|
114
|
+
this.ReadStream.push((0, configuration_1.format)((0, log_common_1.createLogMessageObject)(err, `Cannot compress log file at ${this.LogPath}`, log_common_1.LogLevel.Trace, "log-file-target", {}).Variables, this.Options.layout) + os_1.EOL);
|
|
115
|
+
fs.unlink(zippedPath, () => {
|
|
116
|
+
return;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
fs.unlink(renPath, () => {
|
|
120
|
+
return;
|
|
121
|
+
});
|
|
122
|
+
fs.unlink(archPath, () => {
|
|
123
|
+
return;
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
read.pipe(zip).pipe(write);
|
|
127
|
+
write.on("finish", () => {
|
|
128
|
+
read.close();
|
|
129
|
+
zip.close();
|
|
130
|
+
write.close();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (files.length >= this.Options.options.maxArchiveFiles) {
|
|
134
|
+
fs.unlink(files[0].name, () => {
|
|
135
|
+
return;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
this.initialize();
|
|
142
|
+
}
|
|
95
143
|
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
flush() {
|
|
99
|
-
if (this.HasError || this.BufferSize === 0) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const fd = fs.openSync(this.LogPath, "a");
|
|
103
|
-
fs.writeFileSync(fd, this.Buffer.join());
|
|
104
|
-
fs.closeSync(fd);
|
|
105
|
-
this.CurrentFileSize += this.BufferSize;
|
|
106
|
-
this.Buffer = [];
|
|
107
|
-
this.BufferSize = 0;
|
|
144
|
+
});
|
|
145
|
+
this.close();
|
|
108
146
|
}
|
|
109
147
|
rotate() {
|
|
110
148
|
if (this.Options.options.rotate) {
|
|
@@ -114,11 +152,11 @@ let FileTarget = class FileTarget extends LogTarget_1.LogTarget {
|
|
|
114
152
|
}
|
|
115
153
|
}
|
|
116
154
|
initialize() {
|
|
117
|
-
this.flush();
|
|
118
155
|
this.CurrentFileSize = 0;
|
|
156
|
+
this.IsArchiving = false;
|
|
119
157
|
this.LogDirPath = path.dirname(path.resolve((0, configuration_1.format)(null, this.Options.options.path)));
|
|
120
158
|
this.ArchiveDirPath = this.Options.options.archivePath ? path.resolve((0, configuration_1.format)(null, this.Options.options.archivePath)) : this.LogDirPath;
|
|
121
|
-
this.LogFileName = (0, configuration_1.format)(
|
|
159
|
+
this.LogFileName = (0, configuration_1.format)({ logger: this.Options.name }, path.basename(this.Options.options.path));
|
|
122
160
|
this.LogPath = path.join(this.LogDirPath, this.LogFileName);
|
|
123
161
|
const { name, ext } = path.parse(this.LogFileName);
|
|
124
162
|
this.LogFileExt = ext;
|
|
@@ -134,17 +172,37 @@ let FileTarget = class FileTarget extends LogTarget_1.LogTarget {
|
|
|
134
172
|
fs.mkdirSync(this.ArchiveDirPath);
|
|
135
173
|
}
|
|
136
174
|
}
|
|
137
|
-
|
|
175
|
+
try {
|
|
138
176
|
const { size } = fs.statSync(this.LogPath);
|
|
139
177
|
this.CurrentFileSize = size;
|
|
140
178
|
}
|
|
141
|
-
|
|
179
|
+
catch (_a) { }
|
|
180
|
+
this.open();
|
|
181
|
+
}
|
|
182
|
+
close() {
|
|
183
|
+
this.ReadStream.unpipe(this.WriteStream);
|
|
184
|
+
this.WriteStream.end();
|
|
185
|
+
this.WriteStream = null;
|
|
186
|
+
}
|
|
187
|
+
open() {
|
|
188
|
+
this.WriteStream = fs.createWriteStream(this.LogPath, {
|
|
189
|
+
flags: "a",
|
|
190
|
+
encoding: "utf-8",
|
|
191
|
+
});
|
|
192
|
+
this.ReadStream.pipe(this.WriteStream);
|
|
193
|
+
this.WriteStream.once("open", () => {
|
|
194
|
+
this.ReadStream.push((0, configuration_1.format)((0, log_common_1.createLogMessageObject)(`Log file opened at ${this.LogPath}`, [], log_common_1.LogLevel.Trace, "log-file-target", {}).Variables, this.Options.layout) + os_1.EOL);
|
|
195
|
+
});
|
|
196
|
+
this.WriteStream.once("close", () => {
|
|
197
|
+
this.ReadStream.push((0, configuration_1.format)((0, log_common_1.createLogMessageObject)(`Log file closed at ${this.LogPath}`, [], log_common_1.LogLevel.Trace, "log-file-target", {}).Variables, this.Options.layout) + os_1.EOL);
|
|
198
|
+
});
|
|
199
|
+
this.WriteStream.once("error", (err) => {
|
|
200
|
+
this.ReadStream.unpipe(this.WriteStream);
|
|
201
|
+
this.ReadStream.push((0, configuration_1.format)((0, log_common_1.createLogMessageObject)(err, `Cannot write to log file at ${this.LogPath}`, log_common_1.LogLevel.Error, "log-file-target", {}).Variables, this.Options.layout) + os_1.EOL);
|
|
142
202
|
setTimeout(() => {
|
|
143
|
-
this.
|
|
144
|
-
},
|
|
145
|
-
}
|
|
146
|
-
this.HasError = false;
|
|
147
|
-
this.Error = null;
|
|
203
|
+
this.initialize();
|
|
204
|
+
}, 1000);
|
|
205
|
+
});
|
|
148
206
|
}
|
|
149
207
|
};
|
|
150
208
|
FileTarget = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileTarget.js","sourceRoot":"","sources":["../../src/targets/FileTarget.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileTarget.js","sourceRoot":"","sources":["../../src/targets/FileTarget.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAAyB;AACzB,2FAA2F;AAC3F,oCAAsD;AACtD,oDAAiH;AACjH,uCAAyB;AACzB,2CAA6B;AAC7B,iDAAiD;AACjD,oDAAoD;AACpD,2CAA6B;AAC7B,2CAA6B;AAC7B,0DAAgD;AAChD,mCAA4C;AAI5C,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,sBAA6B;IAA7D;;QAWY,gBAAW,GAAG,KAAK,CAAC;IA6LhC,CAAC;IAxLQ,KAAK,CAAC,OAAO;QAClB,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAClC;YACE,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI,GAAG,IAAI;YACpB,eAAe,EAAE,CAAC;SACnB,EACD,IAAI,CAAC,OAAO,CAAC,OAAO,CACrB,CAAC;QAEF,gEAAgE;QAChE,IAAI,CAAC,UAAU,GAAG,IAAI,iBAAQ,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC;QACtE,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE;YAC3C,IAAI,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,EAAC,GAAG,EAAE,+BAA+B,IAAI,CAAC,OAAO,EAAE,EAAE,qBAAQ,CAAC,KAAK,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,QAAG,CAAC,CAAC;YAErL,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,CAAC,EAAE,IAAI,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAxMY,UAAU;IAFtB,IAAA,gBAAW,GAAE;IACb,IAAA,eAAU,EAAC,YAAY,CAAC;GACZ,UAAU,CAwMtB;AAxMY,gCAAU"}
|
package/lib/targets/index.d.ts
CHANGED
package/lib/targets/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -13,5 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
17
|
__exportStar(require("./BlackHoleTarget"), exports);
|
|
14
18
|
__exportStar(require("./ColoredConsoleTarget"), exports);
|
|
15
19
|
__exportStar(require("./FileTarget"), exports);
|
|
16
|
-
__exportStar(require("./LogTarget"), exports);
|
|
17
20
|
//# sourceMappingURL=index.js.map
|
package/lib/targets/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/targets/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/targets/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,yDAAuC;AACvC,+CAA6B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spinajs/log",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.83",
|
|
4
4
|
"description": "Log lib for all spinejs related libs",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -26,12 +26,13 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/spinajs/log#readme",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@spinajs/
|
|
31
|
-
"@spinajs/
|
|
32
|
-
"@spinajs/
|
|
29
|
+
"@colors/colors": "^1.5.0",
|
|
30
|
+
"@spinajs/configuration": "^1.2.81",
|
|
31
|
+
"@spinajs/di": "^1.2.81",
|
|
32
|
+
"@spinajs/exceptions": "^1.2.81",
|
|
33
|
+
"@spinajs/log-common": "^1.2.81",
|
|
33
34
|
"ajv": "^8.8.2",
|
|
34
|
-
"
|
|
35
|
+
"chalk": "4.1.2",
|
|
35
36
|
"glob": "^7.2.0",
|
|
36
37
|
"glob-to-regexp": "^0.4.1",
|
|
37
38
|
"lodash": "^4.17.14",
|
|
@@ -39,7 +40,8 @@
|
|
|
39
40
|
"node-schedule": "^2.1.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@types/
|
|
43
|
+
"@types/mock-fs": "^4.13.1",
|
|
44
|
+
"mock-fs": "^5.1.2"
|
|
43
45
|
},
|
|
44
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "e2502149a863bdfc453a0b75ccc497f21d8ebef5"
|
|
45
47
|
}
|
package/lib/config/log.d.ts
DELETED
package/lib/config/log.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const path_1 = require("path");
|
|
4
|
-
function dir(path) {
|
|
5
|
-
return (0, path_1.resolve)((0, path_1.normalize)((0, path_1.join)(__dirname, path)));
|
|
6
|
-
}
|
|
7
|
-
const config = {
|
|
8
|
-
system: {
|
|
9
|
-
dirs: {
|
|
10
|
-
schemas: [dir("./../schemas")],
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
exports.default = config;
|
|
15
|
-
//# sourceMappingURL=log.js.map
|
package/lib/config/log.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/config/log.ts"],"names":[],"mappings":";;AAAA,+BAAgD;AAEhD,SAAS,GAAG,CAAC,IAAY;IACvB,OAAO,IAAA,cAAO,EAAC,IAAA,gBAAS,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,MAAM,GAAG;IACb,MAAM,EAAE;QACN,IAAI,EAAE;YACJ,OAAO,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;SAC/B;KACF;CACF,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
package/lib/logger.d.ts
DELETED
package/lib/logger.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.Logger = void 0;
|
|
10
|
-
const di_1 = require("@spinajs/di");
|
|
11
|
-
const log_1 = require("./log");
|
|
12
|
-
const log_configuration_1 = require("./schemas/log.configuration");
|
|
13
|
-
let Logger = class Logger extends di_1.Bootstrapper {
|
|
14
|
-
async bootstrap() {
|
|
15
|
-
di_1.DI.register(log_configuration_1.default).asValue("__configurationSchema__");
|
|
16
|
-
process.on("uncaughtException", (err) => {
|
|
17
|
-
const log = di_1.DI.resolve(log_1.Log, ["process"]);
|
|
18
|
-
log.fatal(err, "Unhandled exception occured");
|
|
19
|
-
});
|
|
20
|
-
process.on("unhandledRejection", (reason, p) => {
|
|
21
|
-
const log = di_1.DI.resolve(log_1.Log, ["process"]);
|
|
22
|
-
log.fatal(reason, "Unhandled rejection at Promise %s", p);
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
Logger = __decorate([
|
|
27
|
-
di_1.Autoinject
|
|
28
|
-
], Logger);
|
|
29
|
-
exports.Logger = Logger;
|
|
30
|
-
//# sourceMappingURL=logger.js.map
|
package/lib/logger.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oCAA2D;AAC3D,+BAA4B;AAC5B,mEAA+D;AAG/D,IAAa,MAAM,GAAnB,MAAa,MAAO,SAAQ,iBAAY;IAC/B,KAAK,CAAC,SAAS;QACpB,OAAE,CAAC,QAAQ,CAAC,2BAAoB,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;QAErE,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;YACtC,MAAM,GAAG,GAAG,OAAE,CAAC,OAAO,CAAC,SAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;YACzC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,6BAA6B,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC7C,MAAM,GAAG,GAAG,OAAE,CAAC,OAAO,CAAC,SAAG,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;YACzC,GAAG,CAAC,KAAK,CAAC,MAAe,EAAE,mCAAmC,EAAE,CAAC,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAdY,MAAM;IADlB,eAAU;GACE,MAAM,CAclB;AAdY,wBAAM"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SyncModule } from "@spinajs/di";
|
|
2
|
-
import { ILogEntry, ICommonTargetOptions, ILogRule, ITargetsOption } from "@spinajs/log-common";
|
|
3
|
-
export interface ILogTargetDesc {
|
|
4
|
-
instance: LogTarget<ICommonTargetOptions>;
|
|
5
|
-
options?: ITargetsOption;
|
|
6
|
-
rule: ILogRule;
|
|
7
|
-
}
|
|
8
|
-
export declare abstract class LogTarget<T extends ICommonTargetOptions> extends SyncModule {
|
|
9
|
-
HasError: boolean;
|
|
10
|
-
Error: Error | null | unknown;
|
|
11
|
-
Options: T;
|
|
12
|
-
constructor(options: T);
|
|
13
|
-
abstract write(data: ILogEntry): Promise<void>;
|
|
14
|
-
}
|
package/lib/targets/LogTarget.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LogTarget = void 0;
|
|
4
|
-
const di_1 = require("@spinajs/di");
|
|
5
|
-
const _ = require("lodash");
|
|
6
|
-
class LogTarget extends di_1.SyncModule {
|
|
7
|
-
constructor(options) {
|
|
8
|
-
super();
|
|
9
|
-
this.HasError = false;
|
|
10
|
-
this.Error = null;
|
|
11
|
-
if (options) {
|
|
12
|
-
this.Options = _.merge(_.merge(this.Options, {
|
|
13
|
-
enabled: true,
|
|
14
|
-
layout: "${datetime} ${level} ${message} ${error} (${logger})",
|
|
15
|
-
}), options);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.LogTarget = LogTarget;
|
|
20
|
-
//# sourceMappingURL=LogTarget.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LogTarget.js","sourceRoot":"","sources":["../../src/targets/LogTarget.ts"],"names":[],"mappings":";;;AAAA,oCAAyC;AACzC,4BAA4B;AAS5B,MAAsB,SAA0C,SAAQ,eAAU;IAKhF,YAAY,OAAU;QACpB,KAAK,EAAE,CAAC;QALH,aAAQ,GAAG,KAAK,CAAC;QACjB,UAAK,GAA2B,IAAI,CAAC;QAM1C,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,KAAK,CACpB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE;gBACpB,OAAO,EAAE,IAAI;gBACb,MAAM,EAAE,sDAAsD;aAC/D,CAAC,EACF,OAAO,CACR,CAAC;SACH;IACH,CAAC;CAGF;AApBD,8BAoBC"}
|
package/lib/types.d.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
export declare enum LogLevel {
|
|
2
|
-
Security = 999,
|
|
3
|
-
Fatal = 6,
|
|
4
|
-
Error = 5,
|
|
5
|
-
Warn = 4,
|
|
6
|
-
Success = 3,
|
|
7
|
-
Info = 2,
|
|
8
|
-
Debug = 1,
|
|
9
|
-
Trace = 0
|
|
10
|
-
}
|
|
11
|
-
export declare const StrToLogLevel: {
|
|
12
|
-
trace: LogLevel;
|
|
13
|
-
debug: LogLevel;
|
|
14
|
-
info: LogLevel;
|
|
15
|
-
success: LogLevel;
|
|
16
|
-
warn: LogLevel;
|
|
17
|
-
error: LogLevel;
|
|
18
|
-
fatal: LogLevel;
|
|
19
|
-
security: LogLevel;
|
|
20
|
-
};
|
|
21
|
-
export declare const LogLevelStrings: {
|
|
22
|
-
1: string;
|
|
23
|
-
5: string;
|
|
24
|
-
6: string;
|
|
25
|
-
2: string;
|
|
26
|
-
999: string;
|
|
27
|
-
3: string;
|
|
28
|
-
0: string;
|
|
29
|
-
4: string;
|
|
30
|
-
};
|
|
31
|
-
export declare abstract class LogVariable {
|
|
32
|
-
abstract get Name(): string;
|
|
33
|
-
abstract Value(option?: string): string;
|
|
34
|
-
}
|
|
35
|
-
export interface ILogRule {
|
|
36
|
-
name: string;
|
|
37
|
-
level: "trace" | "debug" | "info" | "warn" | "error" | "fatal" | "security" | "success";
|
|
38
|
-
target: string | string[];
|
|
39
|
-
}
|
|
40
|
-
export interface ITargetsOption {
|
|
41
|
-
name: string;
|
|
42
|
-
type: string;
|
|
43
|
-
options: ICommonTargetOptions;
|
|
44
|
-
}
|
|
45
|
-
export interface ILogOptions {
|
|
46
|
-
targets: ITargetsOption[];
|
|
47
|
-
rules: ILogRule[];
|
|
48
|
-
variables: Record<string, unknown>;
|
|
49
|
-
}
|
|
50
|
-
export interface ICommonTargetOptions {
|
|
51
|
-
/**
|
|
52
|
-
* Message layout. You can use variables
|
|
53
|
-
*
|
|
54
|
-
* Default message layout is: datetime level message (logger)
|
|
55
|
-
*/
|
|
56
|
-
layout: string;
|
|
57
|
-
/**
|
|
58
|
-
* Target name
|
|
59
|
-
*/
|
|
60
|
-
name: string;
|
|
61
|
-
/**
|
|
62
|
-
* Target type
|
|
63
|
-
*/
|
|
64
|
-
type: string;
|
|
65
|
-
/**
|
|
66
|
-
* Is logger enabled
|
|
67
|
-
*/
|
|
68
|
-
enabled: boolean;
|
|
69
|
-
}
|
|
70
|
-
export interface IColoredConsoleTargetOptions extends ICommonTargetOptions {
|
|
71
|
-
/**
|
|
72
|
-
* Color theme for console message. Best leave it for default.
|
|
73
|
-
*/
|
|
74
|
-
theme: {
|
|
75
|
-
security: string | string[];
|
|
76
|
-
fatal: string | string[];
|
|
77
|
-
error: string | string[];
|
|
78
|
-
warn: string | string[];
|
|
79
|
-
success: string | string[];
|
|
80
|
-
info: string | string[];
|
|
81
|
-
debug: string | string[];
|
|
82
|
-
trace: string | string[];
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export interface IFileTargetOptions extends ICommonTargetOptions {
|
|
86
|
-
options: {
|
|
87
|
-
/**
|
|
88
|
-
* path whre log is stored. It is allowed to use variables to create path eg. date / time etc.
|
|
89
|
-
*/
|
|
90
|
-
path: string;
|
|
91
|
-
/**
|
|
92
|
-
* Archive path for logs eg. when size is exceeded. Is is allowed to use variables eg. date / time etc.
|
|
93
|
-
*
|
|
94
|
-
* Default is none. When not set archive files are stored in same folder as logs.
|
|
95
|
-
*/
|
|
96
|
-
archivePath: string;
|
|
97
|
-
/**
|
|
98
|
-
* Maximum log file size, if exceeded it is moved to archive, and new log file is created
|
|
99
|
-
*
|
|
100
|
-
* Default is 1mb
|
|
101
|
-
*/
|
|
102
|
-
maxSize: number;
|
|
103
|
-
/**
|
|
104
|
-
* Should compress log file when moved to archive
|
|
105
|
-
*
|
|
106
|
-
* Default is false
|
|
107
|
-
*/
|
|
108
|
-
compress: boolean;
|
|
109
|
-
/**
|
|
110
|
-
* Should rotate log file eg. new file every new day.
|
|
111
|
-
* You should use cron like definition eg. at 1am every day: 0 1 * * *
|
|
112
|
-
* When rotate event occurs, old file is moved to archive, and new one is created
|
|
113
|
-
*
|
|
114
|
-
* Default is not set
|
|
115
|
-
*/
|
|
116
|
-
rotate: string;
|
|
117
|
-
/**
|
|
118
|
-
* How mutch archive files should be preserved before deletion. Default is 0
|
|
119
|
-
* Eg. to store max 5 archive files, set it to 5. Oldest by modification time are deleted.
|
|
120
|
-
*/
|
|
121
|
-
maxArchiveFiles: number;
|
|
122
|
-
/**
|
|
123
|
-
* Buffer size for incoming log messages. Messages are stored in buffer before write to file.
|
|
124
|
-
*
|
|
125
|
-
* Default is 8kb
|
|
126
|
-
*/
|
|
127
|
-
bufferSize: number;
|
|
128
|
-
/**
|
|
129
|
-
* Time in ms after whitch flush will be forced. If set to 0 feature is disabled ( any data hangin in temp buffer will not be saved before it reaches bufferSize)
|
|
130
|
-
* Default time is 10s.
|
|
131
|
-
*/
|
|
132
|
-
flushTimeout: number;
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
export interface ILogStaticVariables {
|
|
136
|
-
error: Error | undefined;
|
|
137
|
-
level: string;
|
|
138
|
-
logger: string;
|
|
139
|
-
message: string;
|
|
140
|
-
}
|
|
141
|
-
export interface ILogVariable {
|
|
142
|
-
[key: string]: string | (() => string);
|
|
143
|
-
}
|
|
144
|
-
export interface ILogTargetData {
|
|
145
|
-
Level: LogLevel;
|
|
146
|
-
Variables: LogVariables;
|
|
147
|
-
}
|
|
148
|
-
export declare type LogVariables = ILogStaticVariables & ILogVariable;
|