@mainsail/logger-pino 0.0.1-alpha.2 → 0.0.1-alpha.20
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/README.md +19 -0
- package/distribution/defaults.js +5 -8
- package/distribution/defaults.js.map +1 -1
- package/distribution/driver.d.ts.map +1 -1
- package/distribution/driver.js +46 -50
- package/distribution/driver.js.map +1 -1
- package/distribution/index.d.ts +1 -1
- package/distribution/index.d.ts.map +1 -1
- package/distribution/index.js +1 -17
- package/distribution/index.js.map +1 -1
- package/distribution/service-provider.d.ts +0 -1
- package/distribution/service-provider.d.ts.map +1 -1
- package/distribution/service-provider.js +14 -24
- package/distribution/service-provider.js.map +1 -1
- package/package.json +17 -17
package/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Mainsail - Logger - Pino
|
2
|
+
|
3
|
+

|
4
|
+
|
5
|
+
## Documentation
|
6
|
+
|
7
|
+
You can find installation instructions and detailed instructions on how to use this package at the [dedicated documentation site](https://ark.dev/docs/mainsail).
|
8
|
+
|
9
|
+
## Security
|
10
|
+
|
11
|
+
If you discover a security vulnerability within this package, please send an e-mail to [security@ark.io](mailto:security@ark.io). All security vulnerabilities will be promptly addressed.
|
12
|
+
|
13
|
+
## Credits
|
14
|
+
|
15
|
+
This project exists thanks to all the people who [contribute](https://github.com/ArkEcosystem/mainsail/graphs/contributors).
|
16
|
+
|
17
|
+
## License
|
18
|
+
|
19
|
+
[GPL-3.0-only](https://github.com/ArkEcosystem/mainsail/blob/main/LICENSE) © [ARK Ecosystem](https://ark.io)
|
package/distribution/defaults.js
CHANGED
@@ -1,15 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
const contracts_1 = require("@mainsail/contracts");
|
5
|
-
const kernel_1 = require("@mainsail/kernel");
|
6
|
-
exports.defaults = {
|
1
|
+
import { Constants } from "@mainsail/contracts";
|
2
|
+
import { Environment } from "@mainsail/kernel";
|
3
|
+
export const defaults = {
|
7
4
|
fileRotator: {
|
8
5
|
interval: "1d",
|
9
6
|
},
|
10
7
|
levels: {
|
11
|
-
console:
|
12
|
-
file:
|
8
|
+
console: Environment.get(Constants.EnvironmentVariables.CORE_LOG_LEVEL, "info"),
|
9
|
+
file: Environment.get(Constants.EnvironmentVariables.CORE_LOG_LEVEL_FILE, "debug"),
|
13
10
|
},
|
14
11
|
};
|
15
12
|
//# sourceMappingURL=defaults.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../source/defaults.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"defaults.js","sourceRoot":"","sources":["../source/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,CAAC,MAAM,QAAQ,GAAG;IACvB,WAAW,EAAE;QACZ,QAAQ,EAAE,IAAI;KACd;IACD,MAAM,EAAE;QACP,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,cAAc,EAAE,MAAM,CAAC;QAC/E,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,mBAAmB,EAAE,OAAO,CAAC;KAClF;CACD,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../source/driver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAc7D,qBACa,UAAW,YAAW,SAAS,CAAC,MAAM,CAAC,MAAM;;IAEzD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgC;IAqBvC,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"driver.d.ts","sourceRoot":"","sources":["../source/driver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAc7D,qBACa,UAAW,YAAW,SAAS,CAAC,MAAM,CAAC,MAAM;;IAEzD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgC;IAqBvC,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;IAyD3D,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIhC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI/B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI9B,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI7B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAIxC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAsGrC"}
|
package/distribution/driver.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
"use strict";
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
@@ -19,38 +18,33 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
19
18
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
20
19
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
21
20
|
};
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
24
|
-
};
|
25
21
|
var _PinoLogger_instances, _PinoLogger_levelStyles, _PinoLogger_stream, _PinoLogger_combinedFileStream, _PinoLogger_logger, _PinoLogger_silentConsole, _PinoLogger_log, _PinoLogger_createPrettyTransport, _PinoLogger_getFileStream, _PinoLogger_isValidLevel;
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
const stream_1 = require("stream");
|
41
|
-
const util_1 = require("util");
|
22
|
+
import { inject, injectable } from "@mainsail/container";
|
23
|
+
import { Contracts, Identifiers } from "@mainsail/contracts";
|
24
|
+
import { Utils } from "@mainsail/kernel";
|
25
|
+
import chalk from "chalk";
|
26
|
+
import { error as console_error } from "console";
|
27
|
+
import pino from "pino";
|
28
|
+
import { prettyFactory } from "pino-pretty";
|
29
|
+
import pump from "pump";
|
30
|
+
import pumpify from "pumpify";
|
31
|
+
import { Transform } from "readable-stream";
|
32
|
+
import { createStream } from "rotating-file-stream";
|
33
|
+
import split from "split2";
|
34
|
+
import { PassThrough } from "stream";
|
35
|
+
import { inspect } from "util";
|
42
36
|
let PinoLogger = class PinoLogger {
|
43
37
|
constructor() {
|
44
38
|
_PinoLogger_instances.add(this);
|
45
39
|
_PinoLogger_levelStyles.set(this, {
|
46
|
-
alert:
|
47
|
-
critical:
|
48
|
-
debug:
|
49
|
-
emergency:
|
50
|
-
error:
|
51
|
-
info:
|
52
|
-
notice:
|
53
|
-
warning:
|
40
|
+
alert: chalk.red,
|
41
|
+
critical: chalk.red,
|
42
|
+
debug: chalk.magenta,
|
43
|
+
emergency: chalk.bgRed,
|
44
|
+
error: chalk.red,
|
45
|
+
info: chalk.blue,
|
46
|
+
notice: chalk.green,
|
47
|
+
warning: chalk.yellow,
|
54
48
|
});
|
55
49
|
_PinoLogger_stream.set(this, void 0);
|
56
50
|
_PinoLogger_combinedFileStream.set(this, void 0);
|
@@ -58,8 +52,8 @@ let PinoLogger = class PinoLogger {
|
|
58
52
|
_PinoLogger_silentConsole.set(this, false);
|
59
53
|
}
|
60
54
|
async make(options) {
|
61
|
-
__classPrivateFieldSet(this, _PinoLogger_stream, new
|
62
|
-
__classPrivateFieldSet(this, _PinoLogger_logger,
|
55
|
+
__classPrivateFieldSet(this, _PinoLogger_stream, new PassThrough(), "f");
|
56
|
+
__classPrivateFieldSet(this, _PinoLogger_logger, pino.default({
|
63
57
|
base: null,
|
64
58
|
customLevels: {
|
65
59
|
alert: 1,
|
@@ -81,18 +75,14 @@ let PinoLogger = class PinoLogger {
|
|
81
75
|
useOnlyCustomLevels: true,
|
82
76
|
}, __classPrivateFieldGet(this, _PinoLogger_stream, "f")), "f");
|
83
77
|
if (__classPrivateFieldGet(this, _PinoLogger_instances, "m", _PinoLogger_isValidLevel).call(this, options.levels.console)) {
|
84
|
-
(
|
85
|
-
|
86
|
-
__classPrivateFieldGet(this, _PinoLogger_instances, "m", _PinoLogger_createPrettyTransport).call(this, options.levels.console, { colorize: true }), process.stdout, (error) => {
|
87
|
-
(0, console_1.error)("Stdout stream closed due to an error:", error);
|
78
|
+
pump(__classPrivateFieldGet(this, _PinoLogger_stream, "f"), split(), __classPrivateFieldGet(this, _PinoLogger_instances, "m", _PinoLogger_createPrettyTransport).call(this, options.levels.console, { colorize: true }), process.stdout, (error) => {
|
79
|
+
console_error("Stdout stream closed due to an error:", error);
|
88
80
|
});
|
89
81
|
}
|
90
82
|
if (__classPrivateFieldGet(this, _PinoLogger_instances, "m", _PinoLogger_isValidLevel).call(this, options.levels.file)) {
|
91
|
-
__classPrivateFieldSet(this, _PinoLogger_combinedFileStream, new
|
92
|
-
// @ts-ignore
|
93
|
-
__classPrivateFieldGet(this, _PinoLogger_instances, "m", _PinoLogger_createPrettyTransport).call(this, options.levels.file, { colorize: false }), __classPrivateFieldGet(this, _PinoLogger_instances, "m", _PinoLogger_getFileStream).call(this, options.fileRotator)), "f");
|
83
|
+
__classPrivateFieldSet(this, _PinoLogger_combinedFileStream, new pumpify(split(), __classPrivateFieldGet(this, _PinoLogger_instances, "m", _PinoLogger_createPrettyTransport).call(this, options.levels.file, { colorize: false }), __classPrivateFieldGet(this, _PinoLogger_instances, "m", _PinoLogger_getFileStream).call(this, options.fileRotator)), "f");
|
94
84
|
__classPrivateFieldGet(this, _PinoLogger_combinedFileStream, "f").on("error", (error) => {
|
95
|
-
(
|
85
|
+
console_error("File stream closed due to an error:", error);
|
96
86
|
});
|
97
87
|
__classPrivateFieldGet(this, _PinoLogger_stream, "f").pipe(__classPrivateFieldGet(this, _PinoLogger_combinedFileStream, "f"));
|
98
88
|
}
|
@@ -131,7 +121,7 @@ let PinoLogger = class PinoLogger {
|
|
131
121
|
if (!__classPrivateFieldGet(this, _PinoLogger_combinedFileStream, "f").destroyed) {
|
132
122
|
__classPrivateFieldGet(this, _PinoLogger_combinedFileStream, "f").end();
|
133
123
|
return new Promise((resolve) => {
|
134
|
-
|
124
|
+
Utils.assert.defined(__classPrivateFieldGet(this, _PinoLogger_combinedFileStream, "f"));
|
135
125
|
__classPrivateFieldGet(this, _PinoLogger_combinedFileStream, "f").on("finish", () => {
|
136
126
|
resolve();
|
137
127
|
});
|
@@ -140,7 +130,6 @@ let PinoLogger = class PinoLogger {
|
|
140
130
|
}
|
141
131
|
}
|
142
132
|
};
|
143
|
-
exports.PinoLogger = PinoLogger;
|
144
133
|
_PinoLogger_levelStyles = new WeakMap();
|
145
134
|
_PinoLogger_stream = new WeakMap();
|
146
135
|
_PinoLogger_combinedFileStream = new WeakMap();
|
@@ -151,23 +140,29 @@ _PinoLogger_log = function _PinoLogger_log(level, message) {
|
|
151
140
|
if (__classPrivateFieldGet(this, _PinoLogger_silentConsole, "f")) {
|
152
141
|
return;
|
153
142
|
}
|
154
|
-
if (
|
143
|
+
if (Utils.isEmpty(message)) {
|
155
144
|
return;
|
156
145
|
}
|
157
146
|
if (typeof message !== "string") {
|
158
|
-
message =
|
147
|
+
message = inspect(message, { depth: 1 });
|
159
148
|
}
|
160
149
|
__classPrivateFieldGet(this, _PinoLogger_logger, "f")[level](message);
|
161
150
|
};
|
162
151
|
_PinoLogger_createPrettyTransport = function _PinoLogger_createPrettyTransport(level, prettyOptions) {
|
163
|
-
const
|
152
|
+
const thread = this.app.thread();
|
153
|
+
const ignore = this.app.isWorker() ? `` : `pid`;
|
154
|
+
const pinoPretty = prettyFactory({
|
155
|
+
customPrettifiers: {
|
156
|
+
pid: () => thread,
|
157
|
+
},
|
158
|
+
ignore,
|
164
159
|
levelFirst: false,
|
165
160
|
translateTime: "yyyy-mm-dd HH:MM:ss.l",
|
166
161
|
...prettyOptions,
|
167
162
|
});
|
168
163
|
const getLevel = (level) => __classPrivateFieldGet(this, _PinoLogger_logger, "f").levels.values[level];
|
169
164
|
const formatLevel = (level) => __classPrivateFieldGet(this, _PinoLogger_levelStyles, "f")[level](level.toUpperCase());
|
170
|
-
return new
|
165
|
+
return new Transform({
|
171
166
|
transform(chunk, enc, callback) {
|
172
167
|
try {
|
173
168
|
const json = JSON.parse(chunk);
|
@@ -184,9 +179,9 @@ _PinoLogger_createPrettyTransport = function _PinoLogger_createPrettyTransport(l
|
|
184
179
|
});
|
185
180
|
};
|
186
181
|
_PinoLogger_getFileStream = function _PinoLogger_getFileStream(options) {
|
187
|
-
return
|
182
|
+
return createStream((time, index) => {
|
188
183
|
if (!time) {
|
189
|
-
return `${this.app.
|
184
|
+
return `${this.app.name()}-current.log`;
|
190
185
|
}
|
191
186
|
if (typeof time === "number") {
|
192
187
|
time = new Date(time);
|
@@ -195,7 +190,7 @@ _PinoLogger_getFileStream = function _PinoLogger_getFileStream(options) {
|
|
195
190
|
if (index && index > 1) {
|
196
191
|
filename += `.${index}`;
|
197
192
|
}
|
198
|
-
return `${this.app.
|
193
|
+
return `${this.app.name()}-${filename}.log.gz`;
|
199
194
|
}, {
|
200
195
|
compress: "gzip",
|
201
196
|
initialRotation: true,
|
@@ -209,10 +204,11 @@ _PinoLogger_isValidLevel = function _PinoLogger_isValidLevel(level) {
|
|
209
204
|
return ["emergency", "alert", "critical", "error", "warning", "notice", "info", "debug"].includes(level);
|
210
205
|
};
|
211
206
|
__decorate([
|
212
|
-
|
207
|
+
inject(Identifiers.Application.Instance),
|
213
208
|
__metadata("design:type", Object)
|
214
209
|
], PinoLogger.prototype, "app", void 0);
|
215
|
-
|
216
|
-
|
210
|
+
PinoLogger = __decorate([
|
211
|
+
injectable()
|
217
212
|
], PinoLogger);
|
213
|
+
export { PinoLogger };
|
218
214
|
//# sourceMappingURL=driver.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../source/driver.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../source/driver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,KAAK,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAiB,MAAM,aAAa,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,MAAM,QAA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,EAAE,IAAI,QAAQ,SAAS,CAAC;IAChD,CAAC,EACD;QACC,QAAQ,EAAE,MAAM;QAChB,eAAe,EAAE,IAAI;QACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;KACxB,CACD,CAAC;AACH,CAAC;6DAEa,KAAa;IAC1B,OAAO,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1G,CAAC;AAvNgB;IADhB,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,QAAQ,CAAC;;uCACW;AAFxC,UAAU;IADtB,UAAU,EAAE;GACA,UAAU,CA0NtB"}
|
package/distribution/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export * from "./service-provider";
|
1
|
+
export * from "./service-provider.js";
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
package/distribution/index.js
CHANGED
@@ -1,18 +1,2 @@
|
|
1
|
-
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
__exportStar(require("./service-provider"), exports);
|
1
|
+
export * from "./service-provider.js";
|
18
2
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"service-provider.d.ts","sourceRoot":"","sources":["../source/service-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAY,MAAM,kBAAkB,CAAC;AAKvD,qBAAa,eAAgB,SAAQ,SAAS,CAAC,eAAe;IAChD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;
|
1
|
+
{"version":3,"file":"service-provider.d.ts","sourceRoot":"","sources":["../source/service-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAY,MAAM,kBAAkB,CAAC;AAKvD,qBAAa,eAAgB,SAAQ,SAAS,CAAC,eAAe;IAChD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAUzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,YAAY,IAAI,MAAM;CAW7B"}
|
@@ -1,36 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
};
|
5
|
-
|
6
|
-
exports.ServiceProvider = void 0;
|
7
|
-
const contracts_1 = require("@mainsail/contracts");
|
8
|
-
const kernel_1 = require("@mainsail/kernel");
|
9
|
-
const joi_1 = __importDefault(require("joi"));
|
10
|
-
const driver_1 = require("./driver");
|
11
|
-
class ServiceProvider extends kernel_1.Providers.ServiceProvider {
|
1
|
+
import { Identifiers } from "@mainsail/contracts";
|
2
|
+
import { Providers } from "@mainsail/kernel";
|
3
|
+
import Joi from "joi";
|
4
|
+
import { PinoLogger } from "./driver.js";
|
5
|
+
export class ServiceProvider extends Providers.ServiceProvider {
|
12
6
|
async register() {
|
13
|
-
const logManager = this.app.get(
|
14
|
-
await logManager.extend("pino", async () => this.app.resolve(
|
7
|
+
const logManager = this.app.get(Identifiers.Services.Log.Manager);
|
8
|
+
await logManager.extend("pino", async () => this.app.resolve(PinoLogger).make(this.config().all()));
|
15
9
|
logManager.setDefaultDriver("pino");
|
16
10
|
}
|
17
|
-
requiredByWorker() {
|
18
|
-
return true;
|
19
|
-
}
|
20
11
|
async dispose() {
|
21
|
-
await this.app.get(
|
12
|
+
await this.app.get(Identifiers.Services.Log.Service).dispose();
|
22
13
|
}
|
23
14
|
configSchema() {
|
24
|
-
return
|
25
|
-
fileRotator:
|
26
|
-
interval:
|
15
|
+
return Joi.object({
|
16
|
+
fileRotator: Joi.object({
|
17
|
+
interval: Joi.string().required(),
|
27
18
|
}).required(),
|
28
|
-
levels:
|
29
|
-
console:
|
30
|
-
file:
|
19
|
+
levels: Joi.object({
|
20
|
+
console: Joi.string().required(),
|
21
|
+
file: Joi.string().required(),
|
31
22
|
}).required(),
|
32
23
|
}).unknown(true);
|
33
24
|
}
|
34
25
|
}
|
35
|
-
exports.ServiceProvider = ServiceProvider;
|
36
26
|
//# sourceMappingURL=service-provider.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"service-provider.js","sourceRoot":"","sources":["../source/service-provider.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"service-provider.js","sourceRoot":"","sources":["../source/service-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7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
|
|
1
1
|
{
|
2
2
|
"name": "@mainsail/logger-pino",
|
3
|
-
"version": "0.0.1-alpha.
|
3
|
+
"version": "0.0.1-alpha.20",
|
4
4
|
"description": "Pino logger implementation for the Mainsail blockchain",
|
5
5
|
"license": "GPL-3.0-only",
|
6
6
|
"contributors": [],
|
7
|
+
"type": "module",
|
7
8
|
"main": "distribution/index.js",
|
8
9
|
"files": [
|
9
10
|
"/distribution"
|
10
11
|
],
|
11
12
|
"dependencies": {
|
12
|
-
"chalk": "^
|
13
|
-
"
|
14
|
-
"
|
15
|
-
"pino": "
|
16
|
-
"pino-pretty": "10.2.3",
|
13
|
+
"chalk": "^5.3.0",
|
14
|
+
"joi": "17.12.2",
|
15
|
+
"pino": "9.2.0",
|
16
|
+
"pino-pretty": "11.2.1",
|
17
17
|
"pump": "3.0.0",
|
18
18
|
"pumpify": "2.0.1",
|
19
|
-
"readable-stream": "4.
|
20
|
-
"rotating-file-stream": "3.
|
19
|
+
"readable-stream": "4.5.2",
|
20
|
+
"rotating-file-stream": "3.2.3",
|
21
21
|
"split2": "4.2.0",
|
22
|
-
"@mainsail/container": "0.0.1-alpha.
|
23
|
-
"@mainsail/
|
24
|
-
"@mainsail/
|
22
|
+
"@mainsail/container": "0.0.1-alpha.20",
|
23
|
+
"@mainsail/kernel": "0.0.1-alpha.20",
|
24
|
+
"@mainsail/contracts": "0.0.1-alpha.20"
|
25
25
|
},
|
26
26
|
"devDependencies": {
|
27
27
|
"@types/capture-console": "1.0.5",
|
@@ -31,14 +31,13 @@
|
|
31
31
|
"@types/pino-pretty": "5.0.0",
|
32
32
|
"@types/pump": "1.1.3",
|
33
33
|
"@types/pumpify": "1.4.4",
|
34
|
-
"@types/readable-stream": "4.0.
|
34
|
+
"@types/readable-stream": "4.0.14",
|
35
35
|
"@types/split2": "4.2.3",
|
36
36
|
"@types/tmp": "0.2.6",
|
37
37
|
"capture-console": "1.0.2",
|
38
|
-
"
|
39
|
-
"tmp": "0.2.1",
|
38
|
+
"tmp": "0.2.3",
|
40
39
|
"uvu": "^0.5.6",
|
41
|
-
"@mainsail/utils": "0.0.1-alpha.
|
40
|
+
"@mainsail/utils": "0.0.1-alpha.20"
|
42
41
|
},
|
43
42
|
"engines": {
|
44
43
|
"node": ">=20.x"
|
@@ -48,9 +47,10 @@
|
|
48
47
|
"build:watch": "pnpm run clean && tsc -w",
|
49
48
|
"clean": "del distribution",
|
50
49
|
"release": "pnpm publish --access public",
|
51
|
-
"test": "
|
50
|
+
"test": "pnpm run uvu source .test.ts",
|
52
51
|
"test:coverage": "c8 pnpm run test",
|
53
52
|
"test:coverage:html": "c8 -r html --all pnpm run test",
|
54
|
-
"test:file": "
|
53
|
+
"test:file": "pnpm run uvu source",
|
54
|
+
"uvu": "tsx --tsconfig ../../tsconfig.test.json ./node_modules/uvu/bin.js"
|
55
55
|
}
|
56
56
|
}
|