@spinajs/log-common 1.2.79 → 1.2.81
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/index.d.ts +14 -11
- package/lib/index.js +20 -1
- package/lib/index.js.map +1 -1
- package/package.json +5 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SyncModule } from "@spinajs/di";
|
|
1
2
|
export declare enum LogLevel {
|
|
2
3
|
Security = 999,
|
|
3
4
|
Fatal = 6,
|
|
@@ -115,17 +116,6 @@ export interface IFileTargetOptions extends ICommonTargetOptions {
|
|
|
115
116
|
* Eg. to store max 5 archive files, set it to 5. Oldest by modification time are deleted.
|
|
116
117
|
*/
|
|
117
118
|
maxArchiveFiles: number;
|
|
118
|
-
/**
|
|
119
|
-
* Buffer size for incoming log messages. Messages are stored in buffer before write to file.
|
|
120
|
-
*
|
|
121
|
-
* Default is 8kb
|
|
122
|
-
*/
|
|
123
|
-
bufferSize: number;
|
|
124
|
-
/**
|
|
125
|
-
* 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)
|
|
126
|
-
* Default time is 10s.
|
|
127
|
-
*/
|
|
128
|
-
flushTimeout: number;
|
|
129
119
|
};
|
|
130
120
|
}
|
|
131
121
|
export interface ILogStaticVariables {
|
|
@@ -141,7 +131,20 @@ export interface ILogEntry {
|
|
|
141
131
|
Level: LogLevel;
|
|
142
132
|
Variables: LogVariables;
|
|
143
133
|
}
|
|
134
|
+
export declare abstract class LogTarget<T extends ICommonTargetOptions> extends SyncModule {
|
|
135
|
+
HasError: boolean;
|
|
136
|
+
Error: Error | null | unknown;
|
|
137
|
+
Options: T;
|
|
138
|
+
constructor(options: T);
|
|
139
|
+
abstract write(data: ILogEntry): void;
|
|
140
|
+
}
|
|
141
|
+
export interface ILogTargetDesc {
|
|
142
|
+
instance: LogTarget<ICommonTargetOptions>;
|
|
143
|
+
options?: ITargetsOption;
|
|
144
|
+
rule: ILogRule;
|
|
145
|
+
}
|
|
144
146
|
export interface ILog {
|
|
147
|
+
Targets: ILogTargetDesc[];
|
|
145
148
|
trace(message: string, ...args: any[]): void;
|
|
146
149
|
trace(err: Error, message: string, ...args: any[]): void;
|
|
147
150
|
trace(err: Error | string, message: string | any[], ...args: any[]): void;
|
package/lib/index.js
CHANGED
|
@@ -22,8 +22,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createLogMessageObject = exports.LogLevelStrings = exports.StrToLogLevel = exports.LogLevel = void 0;
|
|
29
|
+
exports.createLogMessageObject = exports.LogTarget = exports.LogLevelStrings = exports.StrToLogLevel = exports.LogLevel = void 0;
|
|
30
|
+
const di_1 = require("@spinajs/di");
|
|
31
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
27
32
|
const util = __importStar(require("util"));
|
|
28
33
|
var LogLevel;
|
|
29
34
|
(function (LogLevel) {
|
|
@@ -56,6 +61,20 @@ exports.LogLevelStrings = {
|
|
|
56
61
|
[LogLevel.Trace]: "trace",
|
|
57
62
|
[LogLevel.Warn]: "warn",
|
|
58
63
|
};
|
|
64
|
+
class LogTarget extends di_1.SyncModule {
|
|
65
|
+
constructor(options) {
|
|
66
|
+
super();
|
|
67
|
+
this.HasError = false;
|
|
68
|
+
this.Error = null;
|
|
69
|
+
if (options) {
|
|
70
|
+
this.Options = lodash_1.default.merge(lodash_1.default.merge(this.Options, {
|
|
71
|
+
enabled: true,
|
|
72
|
+
layout: "${datetime} ${level} ${message} ${error} (${logger})",
|
|
73
|
+
}), options);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.LogTarget = LogTarget;
|
|
59
78
|
function createLogMessageObject(err, message, level, logger, variables, ...args) {
|
|
60
79
|
const sMsg = err instanceof Error ? message : err;
|
|
61
80
|
const tMsg = args.length !== 0 ? util.format(sMsg, ...args) : sMsg;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAyC;AACzC,oDAAuB;AACvB,2CAA6B;AAE7B,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,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,CAAC,CAAC,WAAW,EAAE,EAChD,MAAM,EAAE,KAAK,EACb,OAAO,EAAE,IAAI,IACV,SAAS,CACb;KACF,CAAC;AACJ,CAAC;AAtBD,wDAsBC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.2.
|
|
2
|
+
"version": "1.2.81",
|
|
3
3
|
"description": "Log lib for all spinejs related libs",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"private": false,
|
|
@@ -39,5 +39,8 @@
|
|
|
39
39
|
"bugs": {
|
|
40
40
|
"url": "https://github.com/spinajs/main/issues"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "dd58385e770069586eb8814a13365ce889d46b34",
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@spinajs/di": "^1.2.81"
|
|
45
|
+
}
|
|
43
46
|
}
|