@modernlock/common 1.0.26 → 1.0.27
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/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -42,3 +42,5 @@ __exportStar(require("./middlewares/error-handler"), exports);
|
|
|
42
42
|
__exportStar(require("./middlewares/session"), exports);
|
|
43
43
|
__exportStar(require("./utils/jwtEncryption"), exports);
|
|
44
44
|
__exportStar(require("./utils/logger"), exports);
|
|
45
|
+
__exportStar(require("./logger/custom-logger"), exports);
|
|
46
|
+
__exportStar(require("./logger/transporterOptions"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CustomLogger = void 0;
|
|
7
|
+
const winston_1 = __importDefault(require("winston"));
|
|
8
|
+
class CustomLogger {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.level = "";
|
|
11
|
+
}
|
|
12
|
+
getLogger() {
|
|
13
|
+
if (!this.transporters || !this.serviceName)
|
|
14
|
+
throw new Error("Transporters, service name and level are required...");
|
|
15
|
+
if (!CustomLogger.instance) {
|
|
16
|
+
CustomLogger.instance = winston_1.default.createLogger({
|
|
17
|
+
exitOnError: false,
|
|
18
|
+
defaultMeta: { service: this.serviceName },
|
|
19
|
+
format: winston_1.default.format.combine(winston_1.default.format.timestamp(), winston_1.default.format.errors({ stack: true }), winston_1.default.format.splat(), winston_1.default.format.json()),
|
|
20
|
+
transports: this.transporters
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return CustomLogger.instance;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.CustomLogger = CustomLogger;
|
|
27
|
+
;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import winston from "winston";
|
|
2
|
+
import { ElasticsearchTransport } from "winston-elasticsearch";
|
|
3
|
+
export declare const transporterChoose: {
|
|
4
|
+
console: winston.transports.ConsoleTransportInstance;
|
|
5
|
+
estransporter: (elasticsearchNode: string) => ElasticsearchTransport;
|
|
6
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.transporterChoose = void 0;
|
|
7
|
+
const winston_1 = __importDefault(require("winston"));
|
|
8
|
+
const winston_elasticsearch_1 = require("winston-elasticsearch");
|
|
9
|
+
const esTransformer = (logData) => {
|
|
10
|
+
return (0, winston_elasticsearch_1.ElasticsearchTransformer)(logData);
|
|
11
|
+
};
|
|
12
|
+
exports.transporterChoose = {
|
|
13
|
+
console: new winston_1.default.transports.Console({
|
|
14
|
+
handleExceptions: true
|
|
15
|
+
}),
|
|
16
|
+
estransporter: (elasticsearchNode) => {
|
|
17
|
+
return new winston_elasticsearch_1.ElasticsearchTransport({
|
|
18
|
+
transformer: esTransformer,
|
|
19
|
+
clientOpts: {
|
|
20
|
+
node: elasticsearchNode,
|
|
21
|
+
maxRetries: 2,
|
|
22
|
+
requestTimeout: 10000,
|
|
23
|
+
sniffOnStart: false
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
};
|