@spinajs/log 1.1.1 → 1.1.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/lib/config/log.d.ts +9 -0
- package/lib/config/log.js +16 -0
- package/lib/config/log.js.map +1 -0
- package/lib/index.d.ts +9 -0
- package/lib/index.js +9 -0
- package/lib/index.js.map +1 -1
- package/lib/log.d.ts +2 -3
- package/lib/log.js +29 -45
- package/lib/log.js.map +1 -1
- package/lib/logger.d.ts +8 -0
- package/lib/logger.js +40 -0
- package/lib/logger.js.map +1 -0
- package/lib/schemas/log.configuration.d.ts +115 -0
- package/lib/schemas/log.configuration.js +136 -0
- package/lib/schemas/log.configuration.js.map +1 -0
- package/lib/targets/ColoredConsoleTarget.d.ts +10 -0
- package/lib/targets/ColoredConsoleTarget.js +14 -3
- package/lib/targets/ColoredConsoleTarget.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
log: {}
|
|
14
|
+
};
|
|
15
|
+
exports.default = config;
|
|
16
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/config/log.ts"],"names":[],"mappings":";;AAAA,+BAAgD;AAEhD,SAAS,GAAG,CAAC,IAAa;IACtB,OAAO,IAAA,cAAO,EAAC,IAAA,gBAAS,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,MAAM,GAAG;IACX,MAAM,EAAE;QACJ,IAAI,EAAE;YACF,OAAO,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;SACjC;KACJ;IACD,GAAG,EAAE,EAEJ;CACJ,CAAA;AAED,kBAAe,MAAM,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We export default configuration for webpack modules
|
|
3
|
+
* Normally we load configuration from disk via filesystem
|
|
4
|
+
* But webpack is bundlig all files into one.
|
|
5
|
+
*
|
|
6
|
+
* When we export, we can see configuration variable
|
|
7
|
+
* in webpack module cache and webpack config loader can see it
|
|
8
|
+
*/
|
|
9
|
+
export * from "./config/log";
|
|
1
10
|
export * from "./types";
|
|
2
11
|
export * from "./targets";
|
|
3
12
|
export * from "./variables";
|
package/lib/index.js
CHANGED
|
@@ -10,6 +10,15 @@ 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
|
+
/**
|
|
14
|
+
* We export default configuration for webpack modules
|
|
15
|
+
* Normally we load configuration from disk via filesystem
|
|
16
|
+
* But webpack is bundlig all files into one.
|
|
17
|
+
*
|
|
18
|
+
* When we export, we can see configuration variable
|
|
19
|
+
* in webpack module cache and webpack config loader can see it
|
|
20
|
+
*/
|
|
21
|
+
__exportStar(require("./config/log"), exports);
|
|
13
22
|
__exportStar(require("./types"), exports);
|
|
14
23
|
__exportStar(require("./targets"), exports);
|
|
15
24
|
__exportStar(require("./variables"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0CAAwB;AACxB,4CAA0B;AAC1B,8CAA4B;AAC5B,wCAAsB;AACtB,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;GAOG;AACH,+CAA6B;AAC7B,0CAAwB;AACxB,4CAA0B;AAC1B,8CAA4B;AAC5B,wCAAsB;AACtB,+CAA6B"}
|
package/lib/log.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { IContainer, SyncModule } from "@spinajs/di";
|
|
2
2
|
import { LogTarget } from "./targets/LogTarget";
|
|
3
3
|
import { ICommonTargetOptions, LogLevel, ILogOptions, ILogRule, ILogTargetData, ITargetsOption } from "./types";
|
|
4
|
-
import { DataValidator } from "@spinajs/validation";
|
|
5
4
|
interface ILogTargetDesc {
|
|
6
5
|
instance: LogTarget<ICommonTargetOptions>;
|
|
7
6
|
options?: ITargetsOption;
|
|
@@ -37,15 +36,15 @@ export declare class Log extends SyncModule {
|
|
|
37
36
|
static security(err: Error, message: string, name: string, ...args: any[]): void;
|
|
38
37
|
static success(message: string, name: string, ...args: any[]): void;
|
|
39
38
|
static success(err: Error, message: string, name: string, ...args: any[]): void;
|
|
39
|
+
static clearLoggers(): void;
|
|
40
40
|
protected static LogBuffer: Map<string, ILogTargetData[]>;
|
|
41
41
|
protected static AttachedToExitEvents: boolean;
|
|
42
42
|
protected static write(err: Error | string, message: string | any[], level: LogLevel, name: string, ...args: any[]): void;
|
|
43
43
|
protected Options: ILogOptions;
|
|
44
44
|
protected Rules: ILogRule[];
|
|
45
45
|
protected Targets: ILogTargetDesc[];
|
|
46
|
-
protected Validator: DataValidator;
|
|
47
46
|
constructor(Name: string, Variables?: any, Parent?: Log);
|
|
48
|
-
resolve(
|
|
47
|
+
resolve(container: IContainer): void;
|
|
49
48
|
trace(message: string, ...args: any[]): void;
|
|
50
49
|
trace(err: Error, message: string, ...args: any[]): void;
|
|
51
50
|
debug(message: string, ...args: any[]): void;
|
package/lib/log.js
CHANGED
|
@@ -33,19 +33,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
33
33
|
var Log_1;
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.Log = void 0;
|
|
36
|
-
const
|
|
36
|
+
const types_1 = require("@spinajs/configuration/lib/types");
|
|
37
37
|
const di_1 = require("@spinajs/di");
|
|
38
|
-
const
|
|
38
|
+
const types_2 = require("./types");
|
|
39
39
|
const util = __importStar(require("util"));
|
|
40
40
|
const glob_to_regexp_1 = __importDefault(require("glob-to-regexp"));
|
|
41
|
-
const validation_1 = require("@spinajs/validation");
|
|
42
41
|
const exceptions_1 = require("@spinajs/exceptions");
|
|
43
42
|
function createLogMessageObject(err, message, level, logger, variables, ...args) {
|
|
44
43
|
const sMsg = (err instanceof Error) ? message : err;
|
|
45
44
|
const tMsg = args.length !== 0 ? util.format(sMsg, ...args) : sMsg;
|
|
45
|
+
const lName = logger !== null && logger !== void 0 ? logger : message;
|
|
46
46
|
return {
|
|
47
47
|
Level: level,
|
|
48
|
-
Variables: Object.assign({ error: (err instanceof Error) ? err : undefined, level:
|
|
48
|
+
Variables: Object.assign({ error: (err instanceof Error) ? err : undefined, level: types_2.LogLevelStrings[level].toUpperCase(), logger: lName, message: tMsg }, variables)
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
function wrapWrite(level) {
|
|
@@ -75,32 +75,35 @@ let Log = Log_1 = class Log extends di_1.SyncModule {
|
|
|
75
75
|
this.Parent = Parent;
|
|
76
76
|
}
|
|
77
77
|
static trace(err, message, name, ...args) {
|
|
78
|
-
Log_1.write(err, message,
|
|
78
|
+
Log_1.write(err, message, types_2.LogLevel.Trace, name, ...args);
|
|
79
79
|
}
|
|
80
80
|
static debug(err, message, name, ...args) {
|
|
81
|
-
Log_1.write(err, message,
|
|
81
|
+
Log_1.write(err, message, types_2.LogLevel.Debug, name, ...args);
|
|
82
82
|
}
|
|
83
83
|
static info(err, message, name, ...args) {
|
|
84
|
-
Log_1.write(err, message,
|
|
84
|
+
Log_1.write(err, message, types_2.LogLevel.Info, name, ...args);
|
|
85
85
|
}
|
|
86
86
|
static warn(err, message, name, ...args) {
|
|
87
|
-
Log_1.write(err, message,
|
|
87
|
+
Log_1.write(err, message, types_2.LogLevel.Warn, name, ...args);
|
|
88
88
|
}
|
|
89
89
|
static error(err, message, name, ...args) {
|
|
90
|
-
Log_1.write(err, message,
|
|
90
|
+
Log_1.write(err, message, types_2.LogLevel.Error, name, ...args);
|
|
91
91
|
}
|
|
92
92
|
static fatal(err, message, name, ...args) {
|
|
93
|
-
Log_1.write(err, message,
|
|
93
|
+
Log_1.write(err, message, types_2.LogLevel.Fatal, name, ...args);
|
|
94
94
|
}
|
|
95
95
|
static security(err, message, name, ...args) {
|
|
96
|
-
Log_1.write(err, message,
|
|
96
|
+
Log_1.write(err, message, types_2.LogLevel.Security, name, ...args);
|
|
97
97
|
}
|
|
98
98
|
static success(err, message, name, ...args) {
|
|
99
|
-
Log_1.write(err, message,
|
|
99
|
+
Log_1.write(err, message, types_2.LogLevel.Success, name, ...args);
|
|
100
|
+
}
|
|
101
|
+
static clearLoggers() {
|
|
102
|
+
Log_1.Loggers.clear();
|
|
100
103
|
}
|
|
101
104
|
static write(err, message, level, name, ...args) {
|
|
102
105
|
const msg = createLogMessageObject(err, message, level, name, {}, ...args);
|
|
103
|
-
const logName =
|
|
106
|
+
const logName = name !== null && name !== void 0 ? name : message;
|
|
104
107
|
// if we have already created logger write to it
|
|
105
108
|
if (Log_1.Loggers.has(logName)) {
|
|
106
109
|
Log_1.Loggers.get(logName).Targets.forEach(t => t.instance.write(msg));
|
|
@@ -114,49 +117,38 @@ let Log = Log_1 = class Log extends di_1.SyncModule {
|
|
|
114
117
|
Log_1.LogBuffer.set(logName, [msg]);
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
|
-
resolve(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*/
|
|
121
|
-
this.Validator.validate("spinajs/log.configuration.schema.json", this.Options);
|
|
120
|
+
resolve(container) {
|
|
121
|
+
const config = container.get(types_1.Configuration);
|
|
122
|
+
this.Options = config.get("logger");
|
|
122
123
|
this.matchRulesToLogger();
|
|
123
124
|
this.resolveLogTargets();
|
|
124
|
-
if (!Log_1.AttachedToExitEvents) {
|
|
125
|
-
process.on("uncaughtException", (err) => {
|
|
126
|
-
Log_1.fatal(err, "Unhandled exception occured", "process");
|
|
127
|
-
});
|
|
128
|
-
process.on("unhandledRejection", (reason, p) => {
|
|
129
|
-
Log_1.fatal(reason, "Unhandled rejection at Promise %s", "process", p);
|
|
130
|
-
});
|
|
131
|
-
Log_1.AttachedToExitEvents = true;
|
|
132
|
-
}
|
|
133
125
|
this.writeBufferedMessages();
|
|
134
|
-
super.resolve(
|
|
126
|
+
super.resolve(container);
|
|
135
127
|
Log_1.Loggers.set(this.Name, this);
|
|
136
128
|
}
|
|
137
129
|
trace(err, message, ...args) {
|
|
138
|
-
wrapWrite.apply(this, [
|
|
130
|
+
wrapWrite.apply(this, [types_2.LogLevel.Trace])(err, message, ...args);
|
|
139
131
|
}
|
|
140
132
|
debug(err, message, ...args) {
|
|
141
|
-
wrapWrite.apply(this, [
|
|
133
|
+
wrapWrite.apply(this, [types_2.LogLevel.Debug])(err, message, ...args);
|
|
142
134
|
}
|
|
143
135
|
info(err, message, ...args) {
|
|
144
|
-
wrapWrite.apply(this, [
|
|
136
|
+
wrapWrite.apply(this, [types_2.LogLevel.Info])(err, message, ...args);
|
|
145
137
|
}
|
|
146
138
|
warn(err, message, ...args) {
|
|
147
|
-
wrapWrite.apply(this, [
|
|
139
|
+
wrapWrite.apply(this, [types_2.LogLevel.Warn])(err, message, ...args);
|
|
148
140
|
}
|
|
149
141
|
error(err, message, ...args) {
|
|
150
|
-
wrapWrite.apply(this, [
|
|
142
|
+
wrapWrite.apply(this, [types_2.LogLevel.Error])(err, message, ...args);
|
|
151
143
|
}
|
|
152
144
|
fatal(err, message, ...args) {
|
|
153
|
-
wrapWrite.apply(this, [
|
|
145
|
+
wrapWrite.apply(this, [types_2.LogLevel.Fatal])(err, message, ...args);
|
|
154
146
|
}
|
|
155
147
|
security(err, message, ...args) {
|
|
156
|
-
wrapWrite.apply(this, [
|
|
148
|
+
wrapWrite.apply(this, [types_2.LogLevel.Security])(err, message, ...args);
|
|
157
149
|
}
|
|
158
150
|
success(err, message, ...args) {
|
|
159
|
-
wrapWrite.apply(this, [
|
|
151
|
+
wrapWrite.apply(this, [types_2.LogLevel.Success])(err, message, ...args);
|
|
160
152
|
}
|
|
161
153
|
child(name, variables) {
|
|
162
154
|
return di_1.DI.resolve(Log_1, [`${this.Name}.${name}`, Object.assign(Object.assign({}, this.Variables), variables), this]);
|
|
@@ -193,7 +185,7 @@ let Log = Log_1 = class Log extends di_1.SyncModule {
|
|
|
193
185
|
write(err, message, level, ...args) {
|
|
194
186
|
const lMsg = createLogMessageObject(err, message, level, this.Name, this.Variables, ...args);
|
|
195
187
|
this.Targets.forEach(t => {
|
|
196
|
-
if (level >=
|
|
188
|
+
if (level >= types_2.StrToLogLevel[t.rule.level]) {
|
|
197
189
|
t.instance.write(lMsg);
|
|
198
190
|
}
|
|
199
191
|
});
|
|
@@ -208,14 +200,6 @@ let Log = Log_1 = class Log extends di_1.SyncModule {
|
|
|
208
200
|
Log.Loggers = new Map();
|
|
209
201
|
Log.LogBuffer = new Map();
|
|
210
202
|
Log.AttachedToExitEvents = false;
|
|
211
|
-
__decorate([
|
|
212
|
-
(0, configuration_1.Config)("logger"),
|
|
213
|
-
__metadata("design:type", Object)
|
|
214
|
-
], Log.prototype, "Options", void 0);
|
|
215
|
-
__decorate([
|
|
216
|
-
(0, di_1.Autoinject)(),
|
|
217
|
-
__metadata("design:type", validation_1.DataValidator)
|
|
218
|
-
], Log.prototype, "Validator", void 0);
|
|
219
203
|
Log = Log_1 = __decorate([
|
|
220
204
|
(0, di_1.NewInstance)(),
|
|
221
205
|
__metadata("design:paramtypes", [String, Object, Log])
|
package/lib/log.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAiE;AACjE,oCAAwF;AAExF,mCAAgJ;AAChJ,2CAA6B;AAC7B,oEAA0C;AAC1C,oDAAoD;AAGpD,SAAS,sBAAsB,CAAC,GAAmB,EAAE,OAAuB,EAAE,KAAe,EAAE,MAAc,EAAE,SAAc,EAAE,GAAG,IAAW;IAE3I,MAAM,IAAI,GAAG,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,OAAiB,CAAC,CAAC,CAAC,GAAG,CAAC;IAC9D,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACnE,MAAM,KAAK,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,OAAO,CAAC;IAEhC,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,SAAS,kBACP,KAAK,EAAE,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAC/C,KAAK,EAAE,uBAAe,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,EAC3C,MAAM,EAAE,KAAK,EACb,OAAO,EAAE,IAAI,IACV,SAAS,CACb;KACF,CAAA;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAe;IAEhC,MAAM,IAAI,GAAG,IAAI,CAAC;IAElB,OAAO,CAAC,GAAmB,EAAE,OAAuB,EAAE,GAAG,IAAW,EAAQ,E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DED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AsyncModule, IContainer } from "@spinajs/di";
|
|
2
|
+
import { DataValidator } from "@spinajs/validation";
|
|
3
|
+
import { ILogOptions } from "./types";
|
|
4
|
+
export declare class LogBootstrap extends AsyncModule {
|
|
5
|
+
protected Validator: DataValidator;
|
|
6
|
+
protected Options: ILogOptions;
|
|
7
|
+
resolveAsync(_: IContainer): Promise<void>;
|
|
8
|
+
}
|
package/lib/logger.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LogBootstrap = void 0;
|
|
13
|
+
const decorators_1 = require("@spinajs/configuration/lib/decorators");
|
|
14
|
+
const di_1 = require("@spinajs/di");
|
|
15
|
+
const validation_1 = require("@spinajs/validation");
|
|
16
|
+
const log_1 = require("./log");
|
|
17
|
+
class LogBootstrap extends di_1.AsyncModule {
|
|
18
|
+
async resolveAsync(_) {
|
|
19
|
+
/**
|
|
20
|
+
* Check if options are valid, if not break, break, break
|
|
21
|
+
*/
|
|
22
|
+
this.Validator.validate("spinajs/log.configuration.schema.json", this.Options);
|
|
23
|
+
process.on("uncaughtException", (err) => {
|
|
24
|
+
log_1.Log.fatal(err, "Unhandled exception occured", "process");
|
|
25
|
+
});
|
|
26
|
+
process.on("unhandledRejection", (reason, p) => {
|
|
27
|
+
log_1.Log.fatal(reason, "Unhandled rejection at Promise %s", "process", p);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, di_1.Autoinject)(),
|
|
33
|
+
__metadata("design:type", validation_1.DataValidator)
|
|
34
|
+
], LogBootstrap.prototype, "Validator", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, decorators_1.Config)("logger"),
|
|
37
|
+
__metadata("design:type", Object)
|
|
38
|
+
], LogBootstrap.prototype, "Options", void 0);
|
|
39
|
+
exports.LogBootstrap = LogBootstrap;
|
|
40
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sEAA+D;AAC/D,oCAAkE;AAClE,oDAAoD;AAEpD,+BAA4B;AAE5B,MAAa,YAAa,SAAQ,gBAAW;IAQlC,KAAK,CAAC,YAAY,CAAC,CAAa;QACnC;;WAEG;QACH,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,uCAAuC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAG/E,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;YACpC,SAAG,CAAC,KAAK,CAAC,GAAG,EAAE,6BAA6B,EAAE,SAAS,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC3C,SAAG,CAAC,KAAK,CAAC,MAAa,EAAE,mCAAmC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QAChF,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AApBG;IADC,IAAA,eAAU,GAAE;8BACQ,0BAAa;+CAAC;AAGnC;IADC,IAAA,mBAAM,EAAC,QAAQ,CAAC;;6CACc;AANnC,oCAuBC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
declare const CONFIGURATION_SCHEMA: {
|
|
2
|
+
$id: string;
|
|
3
|
+
description: string;
|
|
4
|
+
type: string;
|
|
5
|
+
properties: {
|
|
6
|
+
targets: {
|
|
7
|
+
description: string;
|
|
8
|
+
type: string;
|
|
9
|
+
minItems: number;
|
|
10
|
+
uniqueItems: boolean;
|
|
11
|
+
items: {
|
|
12
|
+
type: string;
|
|
13
|
+
properties: {
|
|
14
|
+
layout: {
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
name: {
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
type: {
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
theme: {
|
|
24
|
+
type: string;
|
|
25
|
+
properties: {
|
|
26
|
+
security: {
|
|
27
|
+
type: string;
|
|
28
|
+
};
|
|
29
|
+
fatal: {
|
|
30
|
+
type: string;
|
|
31
|
+
};
|
|
32
|
+
error: {
|
|
33
|
+
type: string;
|
|
34
|
+
};
|
|
35
|
+
warn: {
|
|
36
|
+
type: string;
|
|
37
|
+
};
|
|
38
|
+
success: {
|
|
39
|
+
type: string;
|
|
40
|
+
};
|
|
41
|
+
info: {
|
|
42
|
+
type: string;
|
|
43
|
+
};
|
|
44
|
+
debug: {
|
|
45
|
+
type: string;
|
|
46
|
+
};
|
|
47
|
+
trace: {
|
|
48
|
+
type: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
enabled: {
|
|
53
|
+
type: string;
|
|
54
|
+
};
|
|
55
|
+
path: {
|
|
56
|
+
type: string;
|
|
57
|
+
};
|
|
58
|
+
archivePath: {
|
|
59
|
+
type: string;
|
|
60
|
+
};
|
|
61
|
+
maxSize: {
|
|
62
|
+
type: string;
|
|
63
|
+
minimum: number;
|
|
64
|
+
};
|
|
65
|
+
compress: {
|
|
66
|
+
type: string;
|
|
67
|
+
};
|
|
68
|
+
rotate: {
|
|
69
|
+
type: string;
|
|
70
|
+
};
|
|
71
|
+
maxArchiveFiles: {
|
|
72
|
+
type: string;
|
|
73
|
+
minimum: number;
|
|
74
|
+
};
|
|
75
|
+
bufferSize: {
|
|
76
|
+
type: string;
|
|
77
|
+
minimum: number;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
required: string[];
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
rules: {
|
|
84
|
+
description: string;
|
|
85
|
+
type: string;
|
|
86
|
+
minItems: number;
|
|
87
|
+
uniqueItems: boolean;
|
|
88
|
+
items: {
|
|
89
|
+
type: string;
|
|
90
|
+
properties: {
|
|
91
|
+
name: {
|
|
92
|
+
type: string;
|
|
93
|
+
};
|
|
94
|
+
level: {
|
|
95
|
+
type: string;
|
|
96
|
+
enum: string[];
|
|
97
|
+
};
|
|
98
|
+
target: {
|
|
99
|
+
oneOf: ({
|
|
100
|
+
type: string;
|
|
101
|
+
items?: undefined;
|
|
102
|
+
} | {
|
|
103
|
+
type: string;
|
|
104
|
+
items: {
|
|
105
|
+
type: string;
|
|
106
|
+
};
|
|
107
|
+
})[];
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
required: string[];
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
export default CONFIGURATION_SCHEMA;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const CONFIGURATION_SCHEMA = {
|
|
4
|
+
"$id": "spinajs/log.configuration.schema.json",
|
|
5
|
+
"description": "Logger configuration option validation",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"targets": {
|
|
9
|
+
"description": "Log target, where log messages should be written to, and their options",
|
|
10
|
+
"type": "array",
|
|
11
|
+
"minItems": 1,
|
|
12
|
+
"uniqueItems": true,
|
|
13
|
+
"items": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"properties": {
|
|
16
|
+
"layout": {
|
|
17
|
+
"type": "string"
|
|
18
|
+
},
|
|
19
|
+
"name": {
|
|
20
|
+
"type": "string"
|
|
21
|
+
},
|
|
22
|
+
"type": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"theme": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"properties": {
|
|
28
|
+
"security": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"fatal": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
},
|
|
34
|
+
"error": {
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
"warn": {
|
|
38
|
+
"type": "string"
|
|
39
|
+
},
|
|
40
|
+
"success": {
|
|
41
|
+
"type": "string"
|
|
42
|
+
},
|
|
43
|
+
"info": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
},
|
|
46
|
+
"debug": {
|
|
47
|
+
"type": "string"
|
|
48
|
+
},
|
|
49
|
+
"trace": {
|
|
50
|
+
"type": "string"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"enabled": {
|
|
55
|
+
"type": "boolean"
|
|
56
|
+
},
|
|
57
|
+
"path": {
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"archivePath": {
|
|
61
|
+
"type": "string"
|
|
62
|
+
},
|
|
63
|
+
"maxSize": {
|
|
64
|
+
"type": "integer",
|
|
65
|
+
"minimum": 10000
|
|
66
|
+
},
|
|
67
|
+
"compress": {
|
|
68
|
+
"type": "boolean"
|
|
69
|
+
},
|
|
70
|
+
"rotate": {
|
|
71
|
+
"type": "string"
|
|
72
|
+
},
|
|
73
|
+
"maxArchiveFiles": {
|
|
74
|
+
"type": "integer",
|
|
75
|
+
"minimum": 1
|
|
76
|
+
},
|
|
77
|
+
"bufferSize": {
|
|
78
|
+
"type": "integer",
|
|
79
|
+
"minimum": 1000
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"required": [
|
|
83
|
+
"name",
|
|
84
|
+
"type"
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"rules": {
|
|
89
|
+
"description": "Log rules, what log should be write where",
|
|
90
|
+
"type": "array",
|
|
91
|
+
"minItems": 1,
|
|
92
|
+
"uniqueItems": true,
|
|
93
|
+
"items": {
|
|
94
|
+
"type": "object",
|
|
95
|
+
"properties": {
|
|
96
|
+
"name": {
|
|
97
|
+
"type": "string"
|
|
98
|
+
},
|
|
99
|
+
"level": {
|
|
100
|
+
"type": "string",
|
|
101
|
+
"enum": [
|
|
102
|
+
"trace",
|
|
103
|
+
"debug",
|
|
104
|
+
"warn",
|
|
105
|
+
"info",
|
|
106
|
+
"error",
|
|
107
|
+
"fatal",
|
|
108
|
+
"security",
|
|
109
|
+
"success"
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"target": {
|
|
113
|
+
"oneOf": [
|
|
114
|
+
{
|
|
115
|
+
"type": "string"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"type": "array",
|
|
119
|
+
"items": {
|
|
120
|
+
"type": "string"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"required": [
|
|
127
|
+
"name",
|
|
128
|
+
"level",
|
|
129
|
+
"target"
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
exports.default = CONFIGURATION_SCHEMA;
|
|
136
|
+
//# sourceMappingURL=log.configuration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.configuration.js","sourceRoot":"","sources":["../../src/schemas/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qBACpB;oBACD,QAAQ,EAAE;wBACN,MAAM,EAAE,QAAQ;qBACnB;oBACD,iBAAiB,EAAE;wBACf,MAAM,EAAE,SAAS;wBACjB,SAAS,EAAE,CAAC;qBACf;oBACD,YAAY,EAAE;wBACV,MAAM,EAAE,SAAS;wBACjB,SAAS,EAAE,IAAI;qBAClB;iBACJ;gBACD,UAAU,EAAE;oBACR,MAAM;oBACN,MAAM;iBACT;aACJ;SACJ;QACD,OAAO,EAAE;YACL,aAAa,EAAE,2CAA2C;YAC1D,MAAM,EAAE,OAAO;YACf,UAAU,EAAE,CAAC;YACb,aAAa,EAAE,IAAI;YACnB,OAAO,EAAE;gBACL,MAAM,EAAE,QAAQ;gBAChB,YAAY,EAAE;oBACV,MAAM,EAAE;wBACJ,MAAM,EAAE,QAAQ;qBACnB;oBACD,OAAO,EAAE;wBACL,MAAM,EAAE,QAAQ;wBAChB,MAAM,EAAE;4BACJ,OAAO;4BACP,OAAO;4BACP,MAAM;4BACN,MAAM;4BACN,OAAO;4BACP,OAAO;4BACP,UAAU;4BACV,SAAS;yBACZ;qBACJ;oBACD,QAAQ,EAAE;wBACN,OAAO,EAAE;4BACL;gCACI,MAAM,EAAE,QAAQ;6BACnB;4BACD;gCACI,MAAM,EAAE,OAAO;gCACf,OAAO,EAAE;oCACL,MAAM,EAAE,QAAQ;iCACnB;6BACJ;yBACJ;qBACJ;iBACJ;gBACD,UAAU,EAAE;oBACR,MAAM;oBACN,OAAO;oBACP,QAAQ;iBACX;aACJ;SACJ;KACJ;CACJ,CAAA;AAED,kBAAe,oBAAoB,CAAC"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { IColoredConsoleTargetOptions, ILogTargetData } from './../types';
|
|
2
2
|
import { IContainer } from '@spinajs/di';
|
|
3
3
|
import { LogTarget } from './LogTarget';
|
|
4
|
+
export declare const DEFAULT_THEME: {
|
|
5
|
+
security: string[];
|
|
6
|
+
fatal: string;
|
|
7
|
+
error: string;
|
|
8
|
+
warn: string;
|
|
9
|
+
success: string;
|
|
10
|
+
info: string;
|
|
11
|
+
debug: string;
|
|
12
|
+
trace: string;
|
|
13
|
+
};
|
|
4
14
|
export declare class ColoredConsoleTarget extends LogTarget<IColoredConsoleTargetOptions> {
|
|
5
15
|
protected StdConsoleCallbackMap: {
|
|
6
16
|
5: {
|
|
@@ -6,13 +6,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.ColoredConsoleTarget = void 0;
|
|
9
|
+
exports.ColoredConsoleTarget = exports.DEFAULT_THEME = void 0;
|
|
10
10
|
const types_1 = require("./../types");
|
|
11
11
|
const di_1 = require("@spinajs/di");
|
|
12
12
|
const LogTarget_1 = require("./LogTarget");
|
|
13
13
|
const __1 = require("..");
|
|
14
14
|
// tslint:disable-next-line
|
|
15
15
|
const colors = require('colors/safe');
|
|
16
|
+
exports.DEFAULT_THEME = {
|
|
17
|
+
security: ['red', "bgBrightWhite"],
|
|
18
|
+
fatal: 'red',
|
|
19
|
+
error: 'brightRed',
|
|
20
|
+
warn: 'yellow',
|
|
21
|
+
success: 'green',
|
|
22
|
+
info: 'white',
|
|
23
|
+
debug: 'gray',
|
|
24
|
+
trace: 'gray',
|
|
25
|
+
};
|
|
16
26
|
let ColoredConsoleTarget = class ColoredConsoleTarget extends LogTarget_1.LogTarget {
|
|
17
27
|
constructor() {
|
|
18
28
|
super(...arguments);
|
|
@@ -28,8 +38,9 @@ let ColoredConsoleTarget = class ColoredConsoleTarget extends LogTarget_1.LogTar
|
|
|
28
38
|
};
|
|
29
39
|
}
|
|
30
40
|
resolve(_) {
|
|
31
|
-
|
|
32
|
-
this.
|
|
41
|
+
var _a;
|
|
42
|
+
colors.setTheme((_a = this.Options.theme) !== null && _a !== void 0 ? _a : exports.DEFAULT_THEME);
|
|
43
|
+
super.resolve(_);
|
|
33
44
|
}
|
|
34
45
|
async write(data) {
|
|
35
46
|
if (!this.Options.enabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColoredConsoleTarget.js","sourceRoot":"","sources":["../../src/targets/ColoredConsoleTarget.ts"],"names":[],"mappings":";;;;;;;;;AAAA,sCAA2F;AAC3F,oCAAgE;AAChE,2CAAwC;AACxC,0BAA8B;AAE9B,2BAA2B;AAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ColoredConsoleTarget.js","sourceRoot":"","sources":["../../src/targets/ColoredConsoleTarget.ts"],"names":[],"mappings":";;;;;;;;;AAAA,sCAA2F;AAC3F,oCAAgE;AAChE,2CAAwC;AACxC,0BAA8B;AAE9B,2BAA2B;AAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEzB,QAAA,aAAa,GAAG;IACzB,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;CAChB,CAAA;AAID,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,qBAAuC;IAAjF;;QAEc,0BAAqB,GAAG;YAC9B,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;SAChC,CAAA;IAeL,CAAC;IAbU,OAAO,CAAC,CAAa;;QACxB,MAAM,CAAC,QAAQ,CAAC,MAAA,IAAI,CAAC,OAAO,CAAC,KAAK,mCAAI,qBAAa,CAAC,CAAC;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,KAAK,CAAC,IAAoB;QAEnC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACvB,OAAO;SACV;QAED,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAE,MAAc,CAAC,uBAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3I,CAAC;CACJ,CAAA;AA7BY,oBAAoB;IAFhC,IAAA,cAAS,GAAE;IACX,IAAA,eAAU,EAAC,eAAe,CAAC;GACf,oBAAoB,CA6BhC;AA7BY,oDAAoB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spinajs/log",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"description": "Log lib for all spinejs related libs",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/spinajs/log#readme",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@spinajs/configuration": "^1.1.
|
|
28
|
+
"@spinajs/configuration": "^1.1.8",
|
|
29
29
|
"@spinajs/di": "^1.1.7",
|
|
30
30
|
"@spinajs/exceptions": "^1.0.5",
|
|
31
|
-
"@spinajs/validation": "^1.
|
|
31
|
+
"@spinajs/validation": "^1.1.8",
|
|
32
32
|
"colors": "^1.4.0",
|
|
33
33
|
"glob": "^7.2.0",
|
|
34
34
|
"glob-to-regexp": "^0.4.1",
|