@spinajs/log 1.1.7 → 1.2.8
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/.eslintignore +2 -0
- package/.eslintrc.js +43 -0
- package/lib/bootstrap.d.ts +4 -0
- package/lib/bootstrap.js +30 -0
- package/lib/bootstrap.js.map +1 -0
- package/lib/config/log.js +3 -3
- package/lib/config/log.js.map +1 -1
- package/lib/decorators.d.ts +3 -3
- package/lib/decorators.js +4 -4
- package/lib/decorators.js.map +1 -1
- package/lib/index.d.ts +7 -2
- package/lib/index.js +8 -2
- package/lib/index.js.map +1 -1
- package/lib/log.d.ts +8 -32
- package/lib/log.js +59 -123
- package/lib/log.js.map +1 -1
- package/lib/logger.d.ts +3 -7
- package/lib/logger.js +14 -24
- package/lib/logger.js.map +1 -1
- package/lib/schemas/log.configuration.d.ts +1 -0
- package/lib/schemas/log.configuration.js +91 -97
- package/lib/schemas/log.configuration.js.map +1 -1
- package/lib/targets/BlackHoleTarget.d.ts +3 -3
- package/lib/targets/BlackHoleTarget.js.map +1 -1
- package/lib/targets/ColoredConsoleTarget.d.ts +4 -5
- package/lib/targets/ColoredConsoleTarget.js +18 -14
- package/lib/targets/ColoredConsoleTarget.js.map +1 -1
- package/lib/targets/FileTarget.d.ts +3 -4
- package/lib/targets/FileTarget.js +84 -112
- package/lib/targets/FileTarget.js.map +1 -1
- package/lib/targets/LogTarget.d.ts +10 -5
- package/lib/targets/LogTarget.js +38 -36
- package/lib/targets/LogTarget.js.map +1 -1
- package/lib/targets/index.d.ts +1 -0
- package/lib/targets/index.js +1 -0
- package/lib/targets/index.js.map +1 -1
- package/lib/types.d.ts +13 -10
- package/lib/types.js +8 -8
- package/lib/types.js.map +1 -1
- package/lib/variables/date.d.ts +1 -1
- package/lib/variables/date.js +7 -7
- package/lib/variables/date.js.map +1 -1
- package/lib/variables/env.d.ts +1 -1
- package/lib/variables/env.js +4 -4
- package/lib/variables/env.js.map +1 -1
- package/lib/variables/process.d.ts +2 -3
- package/lib/variables/process.js +4 -16
- package/lib/variables/process.js.map +1 -1
- package/package.json +14 -39
- package/tsconfig.build.json +9 -0
|
@@ -1,68 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
2
|
+
/* eslint security/detect-non-literal-fs-filename:0 -- Safe as no value holds user input */
|
|
14
3
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
15
4
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16
5
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
17
6
|
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;
|
|
18
7
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
8
|
};
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
-
if (mod && mod.__esModule) return mod;
|
|
22
|
-
var result = {};
|
|
23
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
-
__setModuleDefault(result, mod);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
-
};
|
|
30
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
10
|
exports.FileTarget = void 0;
|
|
32
11
|
const di_1 = require("@spinajs/di");
|
|
33
12
|
const LogTarget_1 = require("./LogTarget");
|
|
34
|
-
const
|
|
35
|
-
const
|
|
13
|
+
const fs = require("fs");
|
|
14
|
+
const path = require("path");
|
|
36
15
|
const node_schedule_1 = require("node-schedule");
|
|
37
16
|
const exceptions_1 = require("@spinajs/exceptions");
|
|
38
17
|
const os_1 = require("os");
|
|
39
|
-
const glob =
|
|
40
|
-
const zlib =
|
|
18
|
+
const glob = require("glob");
|
|
19
|
+
const zlib = require("zlib");
|
|
41
20
|
let FileTarget = class FileTarget extends LogTarget_1.LogTarget {
|
|
42
21
|
constructor() {
|
|
43
22
|
super(...arguments);
|
|
44
23
|
this.BufferSize = 0;
|
|
45
24
|
this.Buffer = [];
|
|
46
25
|
}
|
|
47
|
-
resolve(
|
|
26
|
+
resolve() {
|
|
48
27
|
this.Options.options = Object.assign({
|
|
49
28
|
compress: true,
|
|
50
29
|
maxSize: 1024 * 1024,
|
|
51
30
|
maxArchiveFiles: 5,
|
|
52
31
|
bufferSize: 8 * 1024,
|
|
53
|
-
flushTimeout: 10 * 1000
|
|
32
|
+
flushTimeout: 10 * 1000,
|
|
54
33
|
}, this.Options.options);
|
|
55
34
|
this.initialize();
|
|
56
35
|
this.rotate();
|
|
57
36
|
process.on("exit", () => {
|
|
58
37
|
this.flush();
|
|
59
38
|
if (this.LogFileDescriptor) {
|
|
60
|
-
|
|
39
|
+
fs.closeSync(this.LogFileDescriptor);
|
|
61
40
|
}
|
|
62
41
|
});
|
|
63
|
-
super.resolve(
|
|
42
|
+
super.resolve();
|
|
64
43
|
}
|
|
65
|
-
|
|
44
|
+
write(data) {
|
|
66
45
|
if (!this.Options.enabled) {
|
|
67
46
|
return;
|
|
68
47
|
}
|
|
@@ -78,60 +57,57 @@ let FileTarget = class FileTarget extends LogTarget_1.LogTarget {
|
|
|
78
57
|
}
|
|
79
58
|
}
|
|
80
59
|
archive() {
|
|
81
|
-
const files = glob
|
|
60
|
+
const files = glob
|
|
61
|
+
.sync(path.join(this.ArchiveDirPath, `archived_${this.LogBaseName}*{${this.LogFileExt},.gzip}`))
|
|
62
|
+
.map((f) => {
|
|
82
63
|
return {
|
|
83
64
|
name: f,
|
|
84
|
-
stat:
|
|
65
|
+
stat: fs.statSync(f),
|
|
85
66
|
};
|
|
86
|
-
})
|
|
67
|
+
})
|
|
68
|
+
.sort((x) => x.stat.mtime.getTime());
|
|
87
69
|
const newestFile = files.length !== 0 ? files[files.length - 1].name : undefined;
|
|
88
|
-
const fIndex = newestFile
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
70
|
+
const fIndex = newestFile
|
|
71
|
+
? parseInt(newestFile.substring(newestFile.lastIndexOf("_") + 1, newestFile.lastIndexOf("_") + 2), 10) + 1
|
|
72
|
+
: 1;
|
|
73
|
+
const archPath = path.join(this.ArchiveDirPath, `archived_${this.LogBaseName}_${fIndex}${this.LogFileExt}`);
|
|
74
|
+
this.flush();
|
|
75
|
+
if (!fs.existsSync(this.LogPath)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
fs.closeSync(this.LogFileDescriptor);
|
|
79
|
+
fs.copyFileSync(this.LogPath, archPath);
|
|
80
|
+
fs.unlinkSync(this.LogPath);
|
|
81
|
+
this.initialize();
|
|
82
|
+
if (this.Options.options.compress) {
|
|
83
|
+
const zippedPath = path.join(this.ArchiveDirPath, `archived_${this.LogBaseName}_${fIndex}${this.LogFileExt}.gzip`);
|
|
84
|
+
const zip = zlib.createGzip();
|
|
85
|
+
const read = fs.createReadStream(archPath);
|
|
86
|
+
const write = fs.createWriteStream(zippedPath);
|
|
87
|
+
read.pipe(zip).pipe(write);
|
|
88
|
+
write.on("finish", () => {
|
|
89
|
+
read.close();
|
|
90
|
+
zip.close();
|
|
91
|
+
write.close();
|
|
92
|
+
fs.unlink(archPath, () => {
|
|
93
|
+
return;
|
|
110
94
|
});
|
|
111
|
-
}
|
|
112
|
-
if (files.length >= this.Options.options.maxArchiveFiles) {
|
|
113
|
-
fs_1.default.unlink(files[0].name, () => { return; });
|
|
114
|
-
}
|
|
95
|
+
});
|
|
115
96
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
97
|
+
if (files.length >= this.Options.options.maxArchiveFiles) {
|
|
98
|
+
fs.unlink(files[0].name, () => {
|
|
99
|
+
return;
|
|
100
|
+
});
|
|
119
101
|
}
|
|
120
102
|
}
|
|
121
103
|
flush() {
|
|
122
104
|
if (!this.LogFileDescriptor || this.HasError || this.BufferSize === 0) {
|
|
123
105
|
return;
|
|
124
106
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
this.BufferSize = 0;
|
|
130
|
-
}
|
|
131
|
-
catch (err) {
|
|
132
|
-
this.HasError = true;
|
|
133
|
-
this.Error = err;
|
|
134
|
-
}
|
|
107
|
+
fs.writeFileSync(this.LogFileDescriptor, this.Buffer.join());
|
|
108
|
+
this.CurrentFileSize += this.BufferSize;
|
|
109
|
+
this.Buffer = [];
|
|
110
|
+
this.BufferSize = 0;
|
|
135
111
|
}
|
|
136
112
|
rotate() {
|
|
137
113
|
if (this.Options.options.rotate) {
|
|
@@ -141,48 +117,44 @@ let FileTarget = class FileTarget extends LogTarget_1.LogTarget {
|
|
|
141
117
|
}
|
|
142
118
|
}
|
|
143
119
|
initialize() {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
if (fs_1.default.existsSync(this.LogPath)) {
|
|
170
|
-
const { size } = fs_1.default.statSync(this.LogPath);
|
|
171
|
-
this.CurrentFileSize = size;
|
|
172
|
-
}
|
|
173
|
-
this.LogFileDescriptor = fs_1.default.openSync(this.LogPath, "a");
|
|
174
|
-
if (this.Options.options.flushTimeout !== 0) {
|
|
175
|
-
setTimeout(() => {
|
|
176
|
-
this.flush();
|
|
177
|
-
}, this.Options.options.flushTimeout);
|
|
120
|
+
this.flush();
|
|
121
|
+
if (this.LogFileDescriptor >= 0) {
|
|
122
|
+
fs.closeSync(this.LogFileDescriptor);
|
|
123
|
+
this.LogFileDescriptor = 0;
|
|
124
|
+
}
|
|
125
|
+
this.CurrentFileSize = 0;
|
|
126
|
+
this.LogDirPath = this.format(null, path.dirname(path.resolve(this.Options.options.path)));
|
|
127
|
+
this.ArchiveDirPath = this.Options.options.archivePath
|
|
128
|
+
? this.format(null, path.resolve(this.Options.options.archivePath))
|
|
129
|
+
: this.LogDirPath;
|
|
130
|
+
this.LogFileName = this.format(null, path.basename(this.Options.options.path));
|
|
131
|
+
this.LogPath = path.join(this.LogDirPath, this.LogFileName);
|
|
132
|
+
const { name, ext } = path.parse(this.LogFileName);
|
|
133
|
+
this.LogFileExt = ext;
|
|
134
|
+
this.LogBaseName = name;
|
|
135
|
+
if (!this.LogDirPath) {
|
|
136
|
+
throw new exceptions_1.InvalidOption("Missing LogDirPath log option");
|
|
137
|
+
}
|
|
138
|
+
if (!fs.existsSync(this.LogDirPath)) {
|
|
139
|
+
fs.mkdirSync(this.LogDirPath);
|
|
140
|
+
}
|
|
141
|
+
if (this.ArchiveDirPath) {
|
|
142
|
+
if (!fs.existsSync(this.ArchiveDirPath)) {
|
|
143
|
+
fs.mkdirSync(this.ArchiveDirPath);
|
|
178
144
|
}
|
|
179
|
-
this.HasError = false;
|
|
180
|
-
this.Error = null;
|
|
181
145
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
this.
|
|
146
|
+
if (fs.existsSync(this.LogPath)) {
|
|
147
|
+
const { size } = fs.statSync(this.LogPath);
|
|
148
|
+
this.CurrentFileSize = size;
|
|
149
|
+
}
|
|
150
|
+
this.LogFileDescriptor = fs.openSync(this.LogPath, "a");
|
|
151
|
+
if (this.Options.options.flushTimeout !== 0) {
|
|
152
|
+
setTimeout(() => {
|
|
153
|
+
this.flush();
|
|
154
|
+
}, this.Options.options.flushTimeout);
|
|
185
155
|
}
|
|
156
|
+
this.HasError = false;
|
|
157
|
+
this.Error = null;
|
|
186
158
|
}
|
|
187
159
|
};
|
|
188
160
|
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,2FAA2F;;;;;;;;;AAE3F,oCAAsD;AACtD,2CAAwC;AAExC,yBAAyB;AACzB,6BAA6B;AAC7B,iDAAiD;AACjD,oDAAoD;AACpD,2BAAyB;AACzB,6BAA6B;AAC7B,6BAA6B;AAI7B,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,qBAA6B;IAA7D;;QAeY,eAAU,GAAG,CAAC,CAAC;QAEf,WAAM,GAAU,EAAE,CAAC;IAyM/B,CAAC;IAvMQ,OAAO;QACZ,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAClC;YACE,QAAQ,EAAE,IAAI;YACd,OAAO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AC,KAAK,EAAE,CAAC;YACf,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;SACvC;QAED,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;CACF,CAAA;AA1NY,UAAU;IAFtB,IAAA,eAAU,EAAC,YAAY,CAAC;IACxB,IAAA,gBAAW,GAAE;GACD,UAAU,CA0NtB;AA1NY,gCAAU"}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { ICommonTargetOptions } from './../types';
|
|
2
1
|
import { SyncModule } from "@spinajs/di";
|
|
3
|
-
import { LogVariable,
|
|
2
|
+
import { LogVariable, ILogEntry, ICommonTargetOptions, LogVariables, ILogRule, ITargetsOption } from "@spinajs/log-common";
|
|
3
|
+
export interface ILogTargetDesc {
|
|
4
|
+
instance: LogTarget<ICommonTargetOptions>;
|
|
5
|
+
options?: ITargetsOption;
|
|
6
|
+
rule: ILogRule;
|
|
7
|
+
}
|
|
4
8
|
export declare abstract class LogTarget<T extends ICommonTargetOptions> extends SyncModule {
|
|
5
9
|
protected Variables: LogVariable[];
|
|
6
10
|
HasError: boolean;
|
|
7
|
-
Error: Error | null;
|
|
11
|
+
Error: Error | null | unknown;
|
|
8
12
|
protected VariablesDictionary: Map<string, LogVariable>;
|
|
9
13
|
protected LayoutRegexp: RegExp;
|
|
10
14
|
protected Options: T;
|
|
11
15
|
constructor(Variables: LogVariable[], options: T);
|
|
12
|
-
abstract write(data:
|
|
13
|
-
protected format(customVars:
|
|
16
|
+
abstract write(data: ILogEntry): Promise<void>;
|
|
17
|
+
protected format(customVars: LogVariables | null, layout: string): string;
|
|
18
|
+
protected _format(vars: LogVariables, txt: string): string;
|
|
14
19
|
}
|
package/lib/targets/LogTarget.js
CHANGED
|
@@ -8,14 +8,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.LogTarget = void 0;
|
|
16
13
|
const di_1 = require("@spinajs/di");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
14
|
+
const _ = require("lodash");
|
|
15
|
+
const log_common_1 = require("@spinajs/log-common");
|
|
19
16
|
let LogTarget = class LogTarget extends di_1.SyncModule {
|
|
20
17
|
constructor(Variables, options) {
|
|
21
18
|
super();
|
|
@@ -23,56 +20,61 @@ let LogTarget = class LogTarget extends di_1.SyncModule {
|
|
|
23
20
|
this.HasError = false;
|
|
24
21
|
this.Error = null;
|
|
25
22
|
this.VariablesDictionary = new Map();
|
|
26
|
-
this.Variables.forEach(v => {
|
|
23
|
+
this.Variables.forEach((v) => {
|
|
27
24
|
this.VariablesDictionary.set(v.Name, v);
|
|
28
25
|
});
|
|
29
26
|
this.LayoutRegexp = /\{((.*?)(:(.*?))?)\}/gm;
|
|
30
27
|
if (options) {
|
|
31
|
-
this.Options =
|
|
28
|
+
this.Options = _.merge(_.merge(this.Options, {
|
|
32
29
|
enabled: true,
|
|
33
|
-
layout: "{datetime} {level} {message} {error} ({logger})"
|
|
30
|
+
layout: "{datetime} {level} {message} {error} ({logger})",
|
|
34
31
|
}), options);
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
34
|
format(customVars, layout) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return _format(Object.assign(Object.assign({}, customVars), { message: _format(customVars, customVars.message) }), layout);
|
|
35
|
+
if (customVars === null || customVars === void 0 ? void 0 : customVars.message) {
|
|
36
|
+
return this._format(Object.assign(Object.assign({}, customVars), { message: this._format(customVars, customVars.message) }), layout);
|
|
41
37
|
}
|
|
42
|
-
return _format(customVars, layout);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
38
|
+
return this._format(customVars, layout);
|
|
39
|
+
}
|
|
40
|
+
_format(vars, txt) {
|
|
41
|
+
this.LayoutRegexp.lastIndex = 0;
|
|
42
|
+
const varMatch = [...txt.matchAll(this.LayoutRegexp)];
|
|
43
|
+
if (!varMatch) {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
let result = txt;
|
|
47
|
+
varMatch.forEach((v) => {
|
|
48
|
+
if (vars && vars[v[2]]) {
|
|
49
|
+
const fVar = vars[v[2]];
|
|
50
|
+
if (fVar instanceof Function) {
|
|
51
|
+
result = result.replace(v[0], fVar());
|
|
53
52
|
}
|
|
54
53
|
else {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
result = result.replace(v[0], fVar);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const variable = this.VariablesDictionary.get(v[2]);
|
|
59
|
+
if (variable) {
|
|
60
|
+
// optional parameter eg. {env:PORT}
|
|
61
|
+
if (v[4]) {
|
|
62
|
+
result = result.replace(v[0], variable.Value(v[4]));
|
|
64
63
|
}
|
|
65
64
|
else {
|
|
66
|
-
result = result.replace(v[0],
|
|
65
|
+
result = result.replace(v[0], variable.Value());
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
else {
|
|
69
|
+
result = result.replace(v[0], "");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return result;
|
|
72
74
|
}
|
|
73
75
|
};
|
|
74
76
|
LogTarget = __decorate([
|
|
75
|
-
(0, di_1.Inject)(Array.ofType(
|
|
77
|
+
(0, di_1.Inject)(Array.ofType(log_common_1.LogVariable)),
|
|
76
78
|
__metadata("design:paramtypes", [Array, Object])
|
|
77
79
|
], LogTarget);
|
|
78
80
|
exports.LogTarget = LogTarget;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogTarget.js","sourceRoot":"","sources":["../../src/targets/LogTarget.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LogTarget.js","sourceRoot":"","sources":["../../src/targets/LogTarget.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAAiD;AACjD,4BAA4B;AAC5B,oDAO6B;AAS7B,IAAsB,SAAS,GAA/B,MAAsB,SAEpB,SAAQ,eAAU;IAOlB,YAAsB,SAAwB,EAAE,OAAU;QACxD,KAAK,EAAE,CAAC;QADY,cAAS,GAAT,SAAS,CAAe;QANvC,aAAQ,GAAG,KAAK,CAAC;QACjB,UAAK,GAA2B,IAAI,CAAC;QAClC,wBAAmB,GAA6B,IAAI,GAAG,EAAE,CAAC;QAOlE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC3B,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,YAAY,GAAG,wBAAwB,CAAC;QAE7C,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,iDAAiD;aAC1D,CAAC,EACF,OAAO,CACR,CAAC;SACH;IACH,CAAC;IAIS,MAAM,CAAC,UAA+B,EAAE,MAAc;QAC9D,IAAI,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,OAAO,EAAE;YACvB,OAAO,I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AQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;qBACrD;yBAAM;wBACL,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;qBACjD;iBACF;qBAAM;oBACL,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;iBACnC;aACF;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF,CAAA;AAhFqB,SAAS;IAD9B,IAAA,WAAM,EAAC,KAAK,CAAC,MAAM,CAAC,wBAAW,CAAC,CAAC;;GACZ,SAAS,CAgF9B;AAhFqB,8BAAS"}
|
package/lib/targets/index.d.ts
CHANGED
package/lib/targets/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./BlackHoleTarget"), exports);
|
|
13
14
|
__exportStar(require("./ColoredConsoleTarget"), exports);
|
|
14
15
|
__exportStar(require("./FileTarget"), exports);
|
|
15
16
|
__exportStar(require("./LogTarget"), exports);
|
package/lib/targets/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/targets/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yDAAuC;AACvC,+CAA6B;AAC7B,8CAA4B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/targets/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAkC;AAClC,yDAAuC;AACvC,+CAA6B;AAC7B,8CAA4B"}
|
package/lib/types.d.ts
CHANGED
|
@@ -45,13 +45,13 @@ export interface ITargetsOption {
|
|
|
45
45
|
export interface ILogOptions {
|
|
46
46
|
targets: ITargetsOption[];
|
|
47
47
|
rules: ILogRule[];
|
|
48
|
-
variables:
|
|
48
|
+
variables: Record<string, unknown>;
|
|
49
49
|
}
|
|
50
50
|
export interface ICommonTargetOptions {
|
|
51
51
|
/**
|
|
52
52
|
* Message layout. You can use variables
|
|
53
53
|
*
|
|
54
|
-
* Default message layout is:
|
|
54
|
+
* Default message layout is: datetime level message (logger)
|
|
55
55
|
*/
|
|
56
56
|
layout: string;
|
|
57
57
|
/**
|
|
@@ -67,8 +67,6 @@ export interface ICommonTargetOptions {
|
|
|
67
67
|
*/
|
|
68
68
|
enabled: boolean;
|
|
69
69
|
}
|
|
70
|
-
export interface IBlackHoleTargetOptions extends ICommonTargetOptions {
|
|
71
|
-
}
|
|
72
70
|
export interface IColoredConsoleTargetOptions extends ICommonTargetOptions {
|
|
73
71
|
/**
|
|
74
72
|
* Color theme for console message. Best leave it for default.
|
|
@@ -134,12 +132,17 @@ export interface IFileTargetOptions extends ICommonTargetOptions {
|
|
|
134
132
|
flushTimeout: number;
|
|
135
133
|
};
|
|
136
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
|
+
}
|
|
137
144
|
export interface ILogTargetData {
|
|
138
145
|
Level: LogLevel;
|
|
139
|
-
Variables:
|
|
140
|
-
error: Error | undefined;
|
|
141
|
-
level: string;
|
|
142
|
-
logger: string;
|
|
143
|
-
message: string;
|
|
144
|
-
};
|
|
146
|
+
Variables: LogVariables;
|
|
145
147
|
}
|
|
148
|
+
export declare type LogVariables = ILogStaticVariables & ILogVariable;
|
package/lib/types.js
CHANGED
|
@@ -13,14 +13,14 @@ var LogLevel;
|
|
|
13
13
|
LogLevel[LogLevel["Trace"] = 0] = "Trace";
|
|
14
14
|
})(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
|
|
15
15
|
exports.StrToLogLevel = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
trace: LogLevel.Trace,
|
|
17
|
+
debug: LogLevel.Debug,
|
|
18
|
+
info: LogLevel.Info,
|
|
19
|
+
success: LogLevel.Success,
|
|
20
|
+
warn: LogLevel.Warn,
|
|
21
|
+
error: LogLevel.Error,
|
|
22
|
+
fatal: LogLevel.Fatal,
|
|
23
|
+
security: LogLevel.Security,
|
|
24
24
|
};
|
|
25
25
|
exports.LogLevelStrings = {
|
|
26
26
|
[LogLevel.Debug]: "debug",
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAgBX;AAhBD,WAAY,QAAQ;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAgBX;AAhBD,WAAY,QAAQ;IAClB,iDAAc,CAAA;IAEd,yCAAS,CAAA;IAET,yCAAS,CAAA;IAET,uCAAQ,CAAA;IAER,6CAAW,CAAA;IAEX,uCAAQ,CAAA;IAER,yCAAS,CAAA;IAET,yCAAS,CAAA;AACX,CAAC,EAhBW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAgBnB;AAEY,QAAA,aAAa,GAAG;IAC3B,KAAK,EAAE,QAAQ,CAAC,KAAK;IACrB,KAAK,EAAE,QAAQ,CAAC,KAAK;IACrB,IAAI,EAAE,QAAQ,CAAC,IAAI;IACnB,OAAO,EAAE,QAAQ,CAAC,OAAO;IACzB,IAAI,EAAE,QAAQ,CAAC,IAAI;IACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;IACrB,KAAK,EAAE,QAAQ,CAAC,KAAK;IACrB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;CAC5B,CAAC;AAEW,QAAA,eAAe,GAAG;IAC7B,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO;IACzB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO;IACzB,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO;IACzB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM;IACvB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU;IAC/B,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS;IAC7B,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO;IACzB,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM;CACxB,CAAC;AAEF,MAAsB,WAAW;CAGhC;AAHD,kCAGC"}
|
package/lib/variables/date.d.ts
CHANGED
package/lib/variables/date.js
CHANGED
|
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.TimeLogVariable = exports.DateLogVariable = exports.DateTimeLogVariable = void 0;
|
|
13
13
|
const di_1 = require("@spinajs/di");
|
|
14
14
|
const luxon_1 = require("luxon");
|
|
15
|
-
const
|
|
16
|
-
let DateTimeLogVariable = class DateTimeLogVariable extends
|
|
15
|
+
const log_common_1 = require("@spinajs/log-common");
|
|
16
|
+
let DateTimeLogVariable = class DateTimeLogVariable extends log_common_1.LogVariable {
|
|
17
17
|
get Name() {
|
|
18
18
|
return "datetime";
|
|
19
19
|
}
|
|
@@ -22,10 +22,10 @@ let DateTimeLogVariable = class DateTimeLogVariable extends types_1.LogVariable
|
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
DateTimeLogVariable = __decorate([
|
|
25
|
-
(0, di_1.Injectable)(
|
|
25
|
+
(0, di_1.Injectable)(log_common_1.LogVariable)
|
|
26
26
|
], DateTimeLogVariable);
|
|
27
27
|
exports.DateTimeLogVariable = DateTimeLogVariable;
|
|
28
|
-
let DateLogVariable = class DateLogVariable extends
|
|
28
|
+
let DateLogVariable = class DateLogVariable extends log_common_1.LogVariable {
|
|
29
29
|
constructor(format) {
|
|
30
30
|
super();
|
|
31
31
|
this.format = format;
|
|
@@ -38,11 +38,11 @@ let DateLogVariable = class DateLogVariable extends types_1.LogVariable {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
DateLogVariable = __decorate([
|
|
41
|
-
(0, di_1.Injectable)(
|
|
41
|
+
(0, di_1.Injectable)(log_common_1.LogVariable),
|
|
42
42
|
__metadata("design:paramtypes", [String])
|
|
43
43
|
], DateLogVariable);
|
|
44
44
|
exports.DateLogVariable = DateLogVariable;
|
|
45
|
-
let TimeLogVariable = class TimeLogVariable extends
|
|
45
|
+
let TimeLogVariable = class TimeLogVariable extends log_common_1.LogVariable {
|
|
46
46
|
constructor(format) {
|
|
47
47
|
super();
|
|
48
48
|
this.format = format;
|
|
@@ -55,7 +55,7 @@ let TimeLogVariable = class TimeLogVariable extends types_1.LogVariable {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
TimeLogVariable = __decorate([
|
|
58
|
-
(0, di_1.Injectable)(
|
|
58
|
+
(0, di_1.Injectable)(log_common_1.LogVariable),
|
|
59
59
|
__metadata("design:paramtypes", [String])
|
|
60
60
|
], TimeLogVariable);
|
|
61
61
|
exports.TimeLogVariable = TimeLogVariable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/variables/date.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAAyC;AACzC,iCAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../src/variables/date.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAAyC;AACzC,iCAAiC;AACjC,oDAAkD;AAGlD,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