@spinajs/log 1.2.79 → 1.2.85
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/log.d.ts +2 -3
- 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 +15 -29
- package/lib/targets/ColoredConsoleTarget.js.map +1 -1
- package/lib/targets/FileTarget.d.ts +13 -14
- package/lib/targets/FileTarget.js +94 -62
- package/lib/targets/FileTarget.js.map +1 -1
- package/lib/targets/index.d.ts +0 -1
- package/lib/targets/index.js +0 -1
- package/lib/targets/index.js.map +1 -1
- package/package.json +10 -8
- package/lib/targets/LogTarget.d.ts +0 -14
- package/lib/targets/LogTarget.js +0 -43
- package/lib/targets/LogTarget.js.map +0 -1
package/lib/log.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Container, SyncModule } from "@spinajs/di";
|
|
2
|
-
import { ILogTargetDesc } from "
|
|
3
|
-
import { ILogOptions, ILogRule, ILogEntry, LogVariables, ILog } from "@spinajs/log-common";
|
|
2
|
+
import { ILogOptions, ILogRule, ILogEntry, LogVariables, ILog, ILogTargetDesc } from "@spinajs/log-common";
|
|
4
3
|
/**
|
|
5
4
|
* Default log implementation interface. Taken from bunyan. Feel free to implement own.
|
|
6
5
|
*/
|
|
@@ -15,11 +14,11 @@ export declare class Log extends SyncModule implements ILog {
|
|
|
15
14
|
*/
|
|
16
15
|
static Loggers: Map<string, Log>;
|
|
17
16
|
Timers: Map<string, Date>;
|
|
17
|
+
Targets: ILogTargetDesc[];
|
|
18
18
|
static clearLoggers(): void;
|
|
19
19
|
protected static AttachedToExitEvents: boolean;
|
|
20
20
|
protected Options: ILogOptions;
|
|
21
21
|
protected Rules: ILogRule[];
|
|
22
|
-
protected Targets: ILogTargetDesc[];
|
|
23
22
|
protected Variables: Record<string, any>;
|
|
24
23
|
protected Container: Container;
|
|
25
24
|
constructor(Name: string, variables?: Record<string, unknown>, Parent?: Log);
|
package/lib/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,sDAAsD;AACtD,0DAA0D;AAC1D,0DAAuD;AACvD,oCAA6F;
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,sDAAsD;AACtD,0DAA0D;AAC1D,0DAAuD;AACvD,oCAA6F;AAC7F,oDAA6L;AAC7L,oEAA0C;AAC1C,oDAAoD;AAEpD,SAAS,SAAS,CAAY,KAAe;IAC3C,OAAO,CAAC,GAAmB,EAAE,OAAuB,EAAE,GAAG,IAAW,EAAE,EAAE;QACtE,IAAI,GAAG,YAAY,KAAK,EAAE;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,mCAAsB,EAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;SACpG;aAAM;YACL,IAAI,OAAO,EAAE;gBACX,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,mCAAsB,EAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;aAC/G;iBAAM;gBACL,OAAO,IAAI,CAAC,KAAK,CAAC,IAA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AQ,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AAE9C,6CAA6C;AAC7C,mDAAmD;AACnD,cAAc;AACd,OAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AAExC,uCAAuC;AACvC,8BAA8B;AAC9B,2CAA2C;AAC3C,OAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,uBAAuB,CAAC,CAAC"}
|
|
@@ -21,35 +21,6 @@ declare const CONFIGURATION_SCHEMA: {
|
|
|
21
21
|
type: {
|
|
22
22
|
type: string;
|
|
23
23
|
};
|
|
24
|
-
theme: {
|
|
25
|
-
type: string;
|
|
26
|
-
properties: {
|
|
27
|
-
security: {
|
|
28
|
-
type: string;
|
|
29
|
-
};
|
|
30
|
-
fatal: {
|
|
31
|
-
type: string;
|
|
32
|
-
};
|
|
33
|
-
error: {
|
|
34
|
-
type: string;
|
|
35
|
-
};
|
|
36
|
-
warn: {
|
|
37
|
-
type: string;
|
|
38
|
-
};
|
|
39
|
-
success: {
|
|
40
|
-
type: string;
|
|
41
|
-
};
|
|
42
|
-
info: {
|
|
43
|
-
type: string;
|
|
44
|
-
};
|
|
45
|
-
debug: {
|
|
46
|
-
type: string;
|
|
47
|
-
};
|
|
48
|
-
trace: {
|
|
49
|
-
type: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
24
|
enabled: {
|
|
54
25
|
type: string;
|
|
55
26
|
};
|
|
@@ -23,35 +23,6 @@ const CONFIGURATION_SCHEMA = {
|
|
|
23
23
|
type: {
|
|
24
24
|
type: "string",
|
|
25
25
|
},
|
|
26
|
-
theme: {
|
|
27
|
-
type: "object",
|
|
28
|
-
properties: {
|
|
29
|
-
security: {
|
|
30
|
-
type: "string",
|
|
31
|
-
},
|
|
32
|
-
fatal: {
|
|
33
|
-
type: "string",
|
|
34
|
-
},
|
|
35
|
-
error: {
|
|
36
|
-
type: "string",
|
|
37
|
-
},
|
|
38
|
-
warn: {
|
|
39
|
-
type: "string",
|
|
40
|
-
},
|
|
41
|
-
success: {
|
|
42
|
-
type: "string",
|
|
43
|
-
},
|
|
44
|
-
info: {
|
|
45
|
-
type: "string",
|
|
46
|
-
},
|
|
47
|
-
debug: {
|
|
48
|
-
type: "string",
|
|
49
|
-
},
|
|
50
|
-
trace: {
|
|
51
|
-
type: "string",
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
26
|
enabled: {
|
|
56
27
|
type: "boolean",
|
|
57
28
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.configuration.js","sourceRoot":"","sources":["../../src/schemas/log.configuration.ts"],"names":[],"mappings":";;AAAA,MAAM,oBAAoB,GAAG;IAC3B,GAAG,EAAE,uCAAuC;IAC5C,oBAAoB,EAAE,QAAQ;IAC9B,WAAW,EAAE,wCAAwC;IACrD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,OAAO,EAAE;YACP,WAAW,EACT,wEAAwE;YAC1E,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,CAAC;YACX,WAAW,EAAE,IAAI;YACjB,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE;wBACN,IAAI,EAAE,QAAQ;qBACf;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;qBACf;oBACD,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;qBACf;oBACD,
|
|
1
|
+
{"version":3,"file":"log.configuration.js","sourceRoot":"","sources":["../../src/schemas/log.configuration.ts"],"names":[],"mappings":";;AAAA,MAAM,oBAAoB,GAAG;IAC3B,GAAG,EAAE,uCAAuC;IAC5C,oBAAoB,EAAE,QAAQ;IAC9B,WAAW,EAAE,wCAAwC;IACrD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,OAAO,EAAE;YACP,WAAW,EACT,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,EAAE;wBACN,KAAK,EAAE;4BACL;gCACE,IAAI,EAAE,QAAQ;6BACf;4BACD;gCACE,IAAI,EAAE,OAAO;gCACb,KAAK,EAAE;oCACL,IAAI,EAAE,QAAQ;iCACf;6BACF;yBACF;qBACF;iBACF;gBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC;aACtC;SACF;KACF;CACF,CAAC;AAEF,kBAAe,oBAAoB,CAAC"}
|
|
@@ -7,12 +7,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.BlackHoleTarget = void 0;
|
|
10
|
+
const log_common_1 = require("@spinajs/log-common");
|
|
10
11
|
const di_1 = require("@spinajs/di");
|
|
11
|
-
const LogTarget_1 = require("./LogTarget");
|
|
12
12
|
/**
|
|
13
13
|
* Empty writer, usefull for tests or when we dont want to get any messages
|
|
14
14
|
*/
|
|
15
|
-
let BlackHoleTarget = class BlackHoleTarget extends
|
|
15
|
+
let BlackHoleTarget = class BlackHoleTarget extends log_common_1.LogTarget {
|
|
16
16
|
async write() {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlackHoleTarget.js","sourceRoot":"","sources":["../../src/targets/BlackHoleTarget.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"BlackHoleTarget.js","sourceRoot":"","sources":["../../src/targets/BlackHoleTarget.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsE;AACtE,oCAAoD;AAGpD;;GAEG;AAGH,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,sBAA+B;IAC3D,KAAK,CAAC,KAAK;QAChB,OAAO;IACT,CAAC;CACF,CAAA;AAJY,eAAe;IAF3B,IAAA,cAAS,GAAE;IACX,IAAA,eAAU,EAAC,iBAAiB,CAAC;GACjB,eAAe,CAI3B;AAJY,0CAAe"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IColoredConsoleTargetOptions, ILogEntry } from "@spinajs/log-common";
|
|
2
|
-
import {
|
|
1
|
+
import { IColoredConsoleTargetOptions, ILogEntry, LogTarget } from "@spinajs/log-common";
|
|
2
|
+
import { Chalk } from "chalk";
|
|
3
3
|
export declare const DEFAULT_THEME: {
|
|
4
4
|
security: string[];
|
|
5
5
|
fatal: string;
|
|
@@ -11,6 +11,7 @@ export declare const DEFAULT_THEME: {
|
|
|
11
11
|
trace: string;
|
|
12
12
|
};
|
|
13
13
|
export declare class ColoredConsoleTarget extends LogTarget<IColoredConsoleTargetOptions> {
|
|
14
|
+
protected theme: Chalk[];
|
|
14
15
|
protected StdConsoleCallbackMap: {
|
|
15
16
|
5: {
|
|
16
17
|
(...data: any[]): void;
|
|
@@ -45,6 +46,6 @@ export declare class ColoredConsoleTarget extends LogTarget<IColoredConsoleTarge
|
|
|
45
46
|
(message?: any, ...optionalParams: any[]): void;
|
|
46
47
|
};
|
|
47
48
|
};
|
|
48
|
-
resolve(): void
|
|
49
|
+
resolve(): Promise<void>;
|
|
49
50
|
write(data: ILogEntry): Promise<void>;
|
|
50
51
|
}
|
|
@@ -1,40 +1,19 @@
|
|
|
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
|
-
});
|
|
18
2
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
3
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
4
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
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;
|
|
22
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
7
|
};
|
|
24
|
-
var
|
|
25
|
-
|
|
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;
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
10
|
};
|
|
31
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
12
|
exports.ColoredConsoleTarget = exports.DEFAULT_THEME = void 0;
|
|
33
13
|
const log_common_1 = require("@spinajs/log-common");
|
|
34
14
|
const di_1 = require("@spinajs/di");
|
|
35
|
-
const LogTarget_1 = require("./LogTarget");
|
|
36
15
|
const __1 = require("..");
|
|
37
|
-
const
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
38
17
|
const configuration_1 = require("@spinajs/configuration");
|
|
39
18
|
exports.DEFAULT_THEME = {
|
|
40
19
|
security: ["red", "bgBrightWhite"],
|
|
@@ -46,9 +25,10 @@ exports.DEFAULT_THEME = {
|
|
|
46
25
|
debug: "gray",
|
|
47
26
|
trace: "gray",
|
|
48
27
|
};
|
|
49
|
-
let ColoredConsoleTarget = class ColoredConsoleTarget extends
|
|
28
|
+
let ColoredConsoleTarget = class ColoredConsoleTarget extends log_common_1.LogTarget {
|
|
50
29
|
constructor() {
|
|
51
30
|
super(...arguments);
|
|
31
|
+
this.theme = [];
|
|
52
32
|
this.StdConsoleCallbackMap = {
|
|
53
33
|
[__1.LogLevel.Error]: console.error,
|
|
54
34
|
[__1.LogLevel.Fatal]: console.error,
|
|
@@ -60,9 +40,15 @@ let ColoredConsoleTarget = class ColoredConsoleTarget extends LogTarget_1.LogTar
|
|
|
60
40
|
[__1.LogLevel.Warn]: console.warn,
|
|
61
41
|
};
|
|
62
42
|
}
|
|
63
|
-
resolve() {
|
|
64
|
-
|
|
65
|
-
|
|
43
|
+
async resolve() {
|
|
44
|
+
this.theme[__1.LogLevel.Trace] = chalk_1.default.gray;
|
|
45
|
+
this.theme[__1.LogLevel.Debug] = chalk_1.default.gray;
|
|
46
|
+
this.theme[__1.LogLevel.Info] = chalk_1.default.white;
|
|
47
|
+
this.theme[__1.LogLevel.Success] = chalk_1.default.white.bgGreen;
|
|
48
|
+
this.theme[__1.LogLevel.Warn] = chalk_1.default.yellow;
|
|
49
|
+
this.theme[__1.LogLevel.Error] = chalk_1.default.red;
|
|
50
|
+
this.theme[__1.LogLevel.Fatal] = chalk_1.default.white.bgRed;
|
|
51
|
+
this.theme[__1.LogLevel.Security] = chalk_1.default.yellow.bgRed;
|
|
66
52
|
super.resolve();
|
|
67
53
|
}
|
|
68
54
|
async write(data) {
|
|
@@ -74,7 +60,7 @@ let ColoredConsoleTarget = class ColoredConsoleTarget extends LogTarget_1.LogTar
|
|
|
74
60
|
* we are safe to call, disable eslint
|
|
75
61
|
*/
|
|
76
62
|
/* eslint-disable */
|
|
77
|
-
|
|
63
|
+
this.theme[data.Level]((0, configuration_1.format)(data.Variables, this.Options.layout)));
|
|
78
64
|
}
|
|
79
65
|
};
|
|
80
66
|
ColoredConsoleTarget = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColoredConsoleTarget.js","sourceRoot":"","sources":["../../src/targets/ColoredConsoleTarget.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ColoredConsoleTarget.js","sourceRoot":"","sources":["../../src/targets/ColoredConsoleTarget.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAyF;AACzF,oCAAoD;AACpD,0BAA8B;AAC9B,kDAAqC;AACrC,0DAAgD;AAEnC,QAAA,aAAa,GAAG;IAC3B,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC;IAClC,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,WAAW;IAClB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,MAAM;IACb,KAAK,EAAE,MAAM;CACd,CAAC;AAIF,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,sBAAuC;IAAjF;;QACY,UAAK,GAAa,EAAE,CAAC;QAErB,0BAAqB,GAAG;YAChC,CAAC,YAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK;YAC/B,CAAC,YAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK;YAC/B,CAAC,YAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,KAAK;YAElC,CAAC,YAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,GAAG;YAC5B,CAAC,YAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG;YAE/B,CAAC,YAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK;YAC/B,CAAC,YAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,KAAK;YAE/B,CAAC,YAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI;SAC9B,CAAC;IA6BJ,CAAC;IA3BQ,KAAK,CAA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BAAoB,CA4ChC;AA5CY,oDAAoB"}
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { LogTarget } from "
|
|
3
|
-
import { IFileTargetOptions, ILogEntry } from "@spinajs/log-common";
|
|
2
|
+
import { IFileTargetOptions, ILogEntry, LogTarget } from "@spinajs/log-common";
|
|
4
3
|
import * as fs from "fs";
|
|
5
4
|
import { Job } from "node-schedule";
|
|
5
|
+
import { Readable } from "stream";
|
|
6
6
|
export declare class FileTarget extends LogTarget<IFileTargetOptions> {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
LogDirPath: string;
|
|
8
|
+
LogFileName: string;
|
|
9
|
+
LogPath: string;
|
|
10
|
+
LogFileExt: string;
|
|
11
|
+
LogBaseName: string;
|
|
12
|
+
ArchiveDirPath: string;
|
|
13
13
|
protected RotateJob: Job;
|
|
14
|
-
protected ArchiveJob: Job;
|
|
15
14
|
protected CurrentFileSize: number;
|
|
16
|
-
protected
|
|
17
|
-
protected FlushTimeout: NodeJS.Timeout;
|
|
18
|
-
protected Buffer: any[];
|
|
15
|
+
protected IsArchiving: boolean;
|
|
19
16
|
protected WriteStream: fs.WriteStream;
|
|
20
|
-
|
|
17
|
+
protected ReadStream: Readable;
|
|
18
|
+
resolve(): Promise<void>;
|
|
21
19
|
write(data: ILogEntry): Promise<void>;
|
|
22
20
|
protected archive(): void;
|
|
23
21
|
private rotate;
|
|
24
22
|
private initialize;
|
|
25
|
-
private
|
|
23
|
+
private close;
|
|
24
|
+
private open;
|
|
26
25
|
}
|
|
@@ -30,58 +30,52 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.FileTarget = void 0;
|
|
33
|
+
const os_1 = require("os");
|
|
33
34
|
/* eslint security/detect-non-literal-fs-filename:0 -- Safe as no value holds user input */
|
|
34
35
|
const di_1 = require("@spinajs/di");
|
|
35
|
-
const
|
|
36
|
+
const log_common_1 = require("@spinajs/log-common");
|
|
36
37
|
const fs = __importStar(require("fs"));
|
|
37
38
|
const path = __importStar(require("path"));
|
|
38
39
|
const node_schedule_1 = require("node-schedule");
|
|
39
40
|
const exceptions_1 = require("@spinajs/exceptions");
|
|
40
|
-
const os_1 = require("os");
|
|
41
41
|
const glob = __importStar(require("glob"));
|
|
42
42
|
const zlib = __importStar(require("zlib"));
|
|
43
43
|
const configuration_1 = require("@spinajs/configuration");
|
|
44
|
-
const
|
|
45
|
-
let FileTarget = class FileTarget extends
|
|
44
|
+
const stream_1 = require("stream");
|
|
45
|
+
let FileTarget = class FileTarget extends log_common_1.LogTarget {
|
|
46
46
|
constructor() {
|
|
47
47
|
super(...arguments);
|
|
48
|
-
this.
|
|
49
|
-
this.Buffer = [];
|
|
48
|
+
this.IsArchiving = false;
|
|
50
49
|
}
|
|
51
|
-
resolve() {
|
|
50
|
+
async resolve() {
|
|
52
51
|
this.Options.options = Object.assign({
|
|
53
52
|
compress: true,
|
|
54
53
|
maxSize: 1024 * 1024,
|
|
55
54
|
maxArchiveFiles: 5,
|
|
56
|
-
bufferSize: 8 * 1024,
|
|
57
|
-
flushTimeout: 10 * 1000,
|
|
58
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
|
+
});
|
|
59
61
|
this.initialize();
|
|
60
62
|
this.rotate();
|
|
61
63
|
super.resolve();
|
|
62
64
|
}
|
|
63
|
-
write(data) {
|
|
65
|
+
async write(data) {
|
|
64
66
|
if (!this.Options.enabled) {
|
|
65
67
|
return;
|
|
66
68
|
}
|
|
67
|
-
const result = (0, configuration_1.format)(data.Variables, this.Options.layout) + os_1.EOL;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const ok = this.WriteStream.write(result, (err) => {
|
|
71
|
-
if (err) {
|
|
72
|
-
console.debug(`Cannot write to log stream at path ${this.LogPath}`);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
if (!ok) {
|
|
76
|
-
this.WriteStream.once("drain", () => {
|
|
77
|
-
void this.write(data);
|
|
78
|
-
});
|
|
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();
|
|
79
72
|
}
|
|
80
|
-
if (this.CurrentFileSize
|
|
73
|
+
if (this.CurrentFileSize >= this.Options.options.maxSize && !this.IsArchiving) {
|
|
81
74
|
this.archive();
|
|
82
75
|
}
|
|
83
76
|
}
|
|
84
77
|
archive() {
|
|
78
|
+
this.IsArchiving = true;
|
|
85
79
|
const files = glob
|
|
86
80
|
.sync(path.join(this.ArchiveDirPath, `archived_${this.LogBaseName}*{${this.LogFileExt},.gzip}`))
|
|
87
81
|
.map((f) => {
|
|
@@ -93,33 +87,63 @@ let FileTarget = class FileTarget extends LogTarget_1.LogTarget {
|
|
|
93
87
|
.sort((x) => x.stat.mtime.getTime());
|
|
94
88
|
const newestFile = files.length !== 0 ? files[files.length - 1].name : undefined;
|
|
95
89
|
const fIndex = newestFile ? parseInt(newestFile.substring(newestFile.lastIndexOf("_") + 1, newestFile.lastIndexOf("_") + 2), 10) + 1 : 1;
|
|
90
|
+
const renPath = this.LogPath + ".bck";
|
|
96
91
|
const archPath = path.join(this.ArchiveDirPath, `archived_${this.LogBaseName}_${fIndex}${this.LogFileExt}`);
|
|
97
92
|
if (!fs.existsSync(this.LogPath)) {
|
|
98
93
|
return;
|
|
99
94
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
+
this.initialize();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (this.Options.options.compress) {
|
|
109
|
+
const zippedPath = path.join(this.ArchiveDirPath, `archived_${this.LogBaseName}_${fIndex}${this.LogFileExt}.gzip`);
|
|
110
|
+
const zip = zlib.createGzip();
|
|
111
|
+
const read = fs.createReadStream(archPath);
|
|
112
|
+
const write = fs.createWriteStream(zippedPath);
|
|
113
|
+
(0, stream_1.pipeline)(read, zip, write, (err) => {
|
|
114
|
+
if (err) {
|
|
115
|
+
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);
|
|
116
|
+
fs.unlink(zippedPath, () => {
|
|
117
|
+
return;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
fs.unlink(renPath, () => {
|
|
121
|
+
return;
|
|
122
|
+
});
|
|
123
|
+
fs.unlink(archPath, () => {
|
|
124
|
+
return;
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
read.pipe(zip).pipe(write);
|
|
128
|
+
write.on("finish", () => {
|
|
129
|
+
read.close();
|
|
130
|
+
zip.close();
|
|
131
|
+
write.close();
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
if (files.length >= this.Options.options.maxArchiveFiles) {
|
|
135
|
+
fs.unlink(files[0].name, () => {
|
|
136
|
+
return;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
this.initialize();
|
|
143
|
+
}
|
|
116
144
|
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
fs.unlink(files[0].name, () => {
|
|
120
|
-
return;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
145
|
+
});
|
|
146
|
+
this.close();
|
|
123
147
|
}
|
|
124
148
|
rotate() {
|
|
125
149
|
if (this.Options.options.rotate) {
|
|
@@ -130,9 +154,10 @@ let FileTarget = class FileTarget extends LogTarget_1.LogTarget {
|
|
|
130
154
|
}
|
|
131
155
|
initialize() {
|
|
132
156
|
this.CurrentFileSize = 0;
|
|
157
|
+
this.IsArchiving = false;
|
|
133
158
|
this.LogDirPath = path.dirname(path.resolve((0, configuration_1.format)(null, this.Options.options.path)));
|
|
134
159
|
this.ArchiveDirPath = this.Options.options.archivePath ? path.resolve((0, configuration_1.format)(null, this.Options.options.archivePath)) : this.LogDirPath;
|
|
135
|
-
this.LogFileName = (0, configuration_1.format)(
|
|
160
|
+
this.LogFileName = (0, configuration_1.format)({ logger: this.Options.name }, path.basename(this.Options.options.path));
|
|
136
161
|
this.LogPath = path.join(this.LogDirPath, this.LogFileName);
|
|
137
162
|
const { name, ext } = path.parse(this.LogFileName);
|
|
138
163
|
this.LogFileExt = ext;
|
|
@@ -148,29 +173,36 @@ let FileTarget = class FileTarget extends LogTarget_1.LogTarget {
|
|
|
148
173
|
fs.mkdirSync(this.ArchiveDirPath);
|
|
149
174
|
}
|
|
150
175
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (this.WriteStream) {
|
|
155
|
-
this.WriteStream.removeAllListeners();
|
|
156
|
-
this.WriteStream.close((err) => {
|
|
157
|
-
console.debug(`Cannot close log write stream ${this.LogPath}, reason: ${err.message}`);
|
|
158
|
-
});
|
|
159
|
-
this.WriteStream = null;
|
|
176
|
+
try {
|
|
177
|
+
const { size } = fs.statSync(this.LogPath);
|
|
178
|
+
this.CurrentFileSize = size;
|
|
160
179
|
}
|
|
180
|
+
catch (_a) { }
|
|
181
|
+
this.open();
|
|
182
|
+
}
|
|
183
|
+
close() {
|
|
184
|
+
this.ReadStream.unpipe(this.WriteStream);
|
|
185
|
+
this.WriteStream.end();
|
|
186
|
+
this.WriteStream = null;
|
|
187
|
+
}
|
|
188
|
+
open() {
|
|
161
189
|
this.WriteStream = fs.createWriteStream(this.LogPath, {
|
|
162
190
|
flags: "a",
|
|
163
191
|
encoding: "utf-8",
|
|
164
192
|
});
|
|
165
|
-
this.
|
|
166
|
-
|
|
193
|
+
this.ReadStream.pipe(this.WriteStream);
|
|
194
|
+
this.WriteStream.once("open", () => {
|
|
195
|
+
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);
|
|
167
196
|
});
|
|
168
|
-
this.WriteStream.
|
|
169
|
-
|
|
170
|
-
this.reopenStream();
|
|
197
|
+
this.WriteStream.once("close", () => {
|
|
198
|
+
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);
|
|
171
199
|
});
|
|
172
|
-
this.WriteStream.
|
|
173
|
-
|
|
200
|
+
this.WriteStream.once("error", (err) => {
|
|
201
|
+
this.ReadStream.unpipe(this.WriteStream);
|
|
202
|
+
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);
|
|
203
|
+
setTimeout(() => {
|
|
204
|
+
this.initialize();
|
|
205
|
+
}, 1000);
|
|
174
206
|
});
|
|
175
207
|
}
|
|
176
208
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileTarget.js","sourceRoot":"","sources":["../../src/targets/FileTarget.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2FAA2F;AAC3F,oCAAsD;AACtD,
|
|
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;IA8LhC,CAAC;IAzLQ,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,CAAC,eAAe,IAAI,KAAK,CAAC,MAAM,CAAC;QACvC,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAA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,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;AAzMY,UAAU;IAFtB,IAAA,gBAAW,GAAE;IACb,IAAA,eAAU,EAAC,YAAY,CAAC;GACZ,UAAU,CAyMtB;AAzMY,gCAAU"}
|
package/lib/targets/index.d.ts
CHANGED
package/lib/targets/index.js
CHANGED
|
@@ -17,5 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./BlackHoleTarget"), exports);
|
|
18
18
|
__exportStar(require("./ColoredConsoleTarget"), exports);
|
|
19
19
|
__exportStar(require("./FileTarget"), exports);
|
|
20
|
-
__exportStar(require("./LogTarget"), exports);
|
|
21
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":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,yDAAuC;AACvC,+CAA6B
|
|
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.85",
|
|
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": "06030775e7704de5eceb11c3e6951a6038e76d7b"
|
|
45
47
|
}
|
|
@@ -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,43 +0,0 @@
|
|
|
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
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.LogTarget = void 0;
|
|
27
|
-
const di_1 = require("@spinajs/di");
|
|
28
|
-
const _ = __importStar(require("lodash"));
|
|
29
|
-
class LogTarget extends di_1.SyncModule {
|
|
30
|
-
constructor(options) {
|
|
31
|
-
super();
|
|
32
|
-
this.HasError = false;
|
|
33
|
-
this.Error = null;
|
|
34
|
-
if (options) {
|
|
35
|
-
this.Options = _.merge(_.merge(this.Options, {
|
|
36
|
-
enabled: true,
|
|
37
|
-
layout: "${datetime} ${level} ${message} ${error} (${logger})",
|
|
38
|
-
}), options);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.LogTarget = LogTarget;
|
|
43
|
-
//# sourceMappingURL=LogTarget.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LogTarget.js","sourceRoot":"","sources":["../../src/targets/LogTarget.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAyC;AACzC,0CAA4B;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"}
|