@nestjs-labs/nestjs-pino-extra 1.0.0 → 1.0.1
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 +0 -1
- package/dist/formatters.d.ts +0 -4
- package/dist/formatters.js +1 -7
- package/dist/formatters.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +14 -16
- package/dist/index.js.map +1 -1
- package/dist/module-option.d.ts +14 -5
- package/dist/module-option.js +45 -17
- package/dist/module-option.js.map +1 -1
- package/dist/options.d.ts +0 -3
- package/dist/options.js +9 -14
- package/dist/options.js.map +1 -1
- package/dist/serializers.d.ts +1 -7
- package/dist/serializers.js +0 -4
- package/dist/serializers.js.map +1 -1
- package/dist/streams.d.ts +2 -17
- package/dist/streams.js +13 -25
- package/dist/streams.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -9
package/README.md
CHANGED
package/dist/formatters.d.ts
CHANGED
package/dist/formatters.js
CHANGED
|
@@ -2,22 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOtelFormatters = getOtelFormatters;
|
|
4
4
|
const api_1 = require("@opentelemetry/api");
|
|
5
|
-
/**
|
|
6
|
-
* add custom formatters
|
|
7
|
-
* https://github.com/pinojs/pino-http?tab=readme-ov-file#custom-formatters
|
|
8
|
-
*/
|
|
9
5
|
function getOtelFormatters(spanIdKey = 'spanId', traceIdKey = 'traceId') {
|
|
10
6
|
return {
|
|
11
7
|
level: (label) => {
|
|
12
8
|
return { level: label };
|
|
13
9
|
},
|
|
14
|
-
// Workaround for PinoInstrumentation (does not support latest version yet)
|
|
15
10
|
log(object) {
|
|
16
|
-
var _a;
|
|
17
11
|
const span = api_1.trace.getSpan(api_1.context.active());
|
|
18
12
|
if (!span)
|
|
19
13
|
return object;
|
|
20
|
-
const spanContext =
|
|
14
|
+
const spanContext = api_1.trace.getSpan(api_1.context.active())?.spanContext();
|
|
21
15
|
if (!spanContext)
|
|
22
16
|
return object;
|
|
23
17
|
const { spanId, traceId } = spanContext;
|
package/dist/formatters.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":";;AAMA,
|
|
1
|
+
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":";;AAMA,8CAsBC;AA5BD,4CAAoD;AAMpD,SAAgB,iBAAiB,CAC/B,SAAS,GAAG,QAAQ,EACpB,UAAU,GAAG,SAAS;IAEtB,OAAO;QACL,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE;YACvB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QAC1B,CAAC;QAED,GAAG,CAAC,MAA+B;YACjC,MAAM,IAAI,GAAG,WAAK,CAAC,OAAO,CAAC,aAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAE7C,IAAI,CAAC,IAAI;gBAAE,OAAO,MAAM,CAAC;YACzB,MAAM,WAAW,GAAG,WAAK,CAAC,OAAO,CAAC,aAAO,CAAC,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC;YAEnE,IAAI,CAAC,WAAW;gBAAE,OAAO,MAAM,CAAC;YAEhC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,WAAW,CAAC;YAExC,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;QACnE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from 'nestjs-pino';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
2
|
+
export { getOtelFormatters } from './formatters.js';
|
|
3
|
+
export { getNestjsPinoModuleOptions } from './module-option.js';
|
|
4
|
+
export { getPinoHttpOption } from './options.js';
|
|
5
|
+
export { getSerializers } from './serializers.js';
|
|
6
|
+
export { createFileStreamEntry, createLokiStreamEntry, createPrettyStreamEntry, getMultiDestinationStream, } from './streams.js';
|
package/dist/index.js
CHANGED
|
@@ -14,21 +14,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getMultiDestinationStream = exports.
|
|
18
|
-
// reexport nestjs-pino
|
|
17
|
+
exports.getMultiDestinationStream = exports.createPrettyStreamEntry = exports.createLokiStreamEntry = exports.createFileStreamEntry = exports.getSerializers = exports.getPinoHttpOption = exports.getNestjsPinoModuleOptions = exports.getOtelFormatters = void 0;
|
|
19
18
|
__exportStar(require("nestjs-pino"), exports);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Object.defineProperty(exports, "
|
|
31
|
-
Object.defineProperty(exports, "
|
|
32
|
-
Object.defineProperty(exports, "
|
|
33
|
-
Object.defineProperty(exports, "getMultiDestinationStream", { enumerable: true, get: function () { return streams_1.getMultiDestinationStream; } });
|
|
19
|
+
var formatters_js_1 = require("./formatters.js");
|
|
20
|
+
Object.defineProperty(exports, "getOtelFormatters", { enumerable: true, get: function () { return formatters_js_1.getOtelFormatters; } });
|
|
21
|
+
var module_option_js_1 = require("./module-option.js");
|
|
22
|
+
Object.defineProperty(exports, "getNestjsPinoModuleOptions", { enumerable: true, get: function () { return module_option_js_1.getNestjsPinoModuleOptions; } });
|
|
23
|
+
var options_js_1 = require("./options.js");
|
|
24
|
+
Object.defineProperty(exports, "getPinoHttpOption", { enumerable: true, get: function () { return options_js_1.getPinoHttpOption; } });
|
|
25
|
+
var serializers_js_1 = require("./serializers.js");
|
|
26
|
+
Object.defineProperty(exports, "getSerializers", { enumerable: true, get: function () { return serializers_js_1.getSerializers; } });
|
|
27
|
+
var streams_js_1 = require("./streams.js");
|
|
28
|
+
Object.defineProperty(exports, "createFileStreamEntry", { enumerable: true, get: function () { return streams_js_1.createFileStreamEntry; } });
|
|
29
|
+
Object.defineProperty(exports, "createLokiStreamEntry", { enumerable: true, get: function () { return streams_js_1.createLokiStreamEntry; } });
|
|
30
|
+
Object.defineProperty(exports, "createPrettyStreamEntry", { enumerable: true, get: function () { return streams_js_1.createPrettyStreamEntry; } });
|
|
31
|
+
Object.defineProperty(exports, "getMultiDestinationStream", { enumerable: true, get: function () { return streams_js_1.getMultiDestinationStream; } });
|
|
34
32
|
//# sourceMappingURL=index.js.map
|
package/dist/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":";;;;;;;;;;;;;;;;;AACA,8CAA4B;AAG5B,iDAAoD;AAA3C,kHAAA,iBAAiB,OAAA;AAC1B,uDAAgE;AAAvD,8HAAA,0BAA0B,OAAA;AACnC,2CAAiD;AAAxC,+GAAA,iBAAiB,OAAA;AAC1B,mDAAkD;AAAzC,gHAAA,cAAc,OAAA;AACvB,2CAKsB;AAJpB,mHAAA,qBAAqB,OAAA;AACrB,mHAAA,qBAAqB,OAAA;AACrB,qHAAA,uBAAuB,OAAA;AACvB,uHAAA,yBAAyB,OAAA"}
|
package/dist/module-option.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import type { MiddlewareConfigProxy } from '@nestjs/common/interfaces';
|
|
2
1
|
import type { ConfigService } from '@nestjs/config';
|
|
3
2
|
import type { Params } from 'nestjs-pino';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type pino from 'pino';
|
|
4
|
+
interface LogConfig {
|
|
5
|
+
app: string;
|
|
6
|
+
filename?: string;
|
|
7
|
+
level: pino.Level;
|
|
8
|
+
loki?: string;
|
|
9
|
+
spanIdKey: string;
|
|
10
|
+
traceIdKey: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function extractLogConfig(configService: ConfigService): LogConfig;
|
|
13
|
+
export declare function getPinoHttpFromConfig(config: LogConfig): Params['pinoHttp'];
|
|
14
|
+
export declare function getParamsFromConfig(config: LogConfig, overrides?: Params): Params;
|
|
15
|
+
export declare function getNestjsPinoModuleOptions(configService: ConfigService, overrides?: Params): Params;
|
|
16
|
+
export {};
|
package/dist/module-option.js
CHANGED
|
@@ -1,26 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractLogConfig = extractLogConfig;
|
|
4
|
+
exports.getPinoHttpFromConfig = getPinoHttpFromConfig;
|
|
5
|
+
exports.getParamsFromConfig = getParamsFromConfig;
|
|
3
6
|
exports.getNestjsPinoModuleOptions = getNestjsPinoModuleOptions;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function getNestjsPinoModuleOptions(configService, exclude) {
|
|
10
|
-
var _a, _b, _c, _d;
|
|
11
|
-
const app = (_a = configService.get('OTLP_SERVICE_NAME')) !== null && _a !== void 0 ? _a : 'app';
|
|
12
|
-
const level = (_b = configService.get('LOG_LEVEL')) !== null && _b !== void 0 ? _b : 'info';
|
|
7
|
+
const options_js_1 = require("./options.js");
|
|
8
|
+
const streams_js_1 = require("./streams.js");
|
|
9
|
+
function extractLogConfig(configService) {
|
|
10
|
+
const app = configService.get('OTLP_SERVICE_NAME') ?? 'app';
|
|
11
|
+
const level = configService.get('LOG_LEVEL') ?? 'info';
|
|
13
12
|
const filename = configService.get('LOG_FILE');
|
|
14
13
|
const loki = configService.get('LOG_LOKI');
|
|
15
|
-
const spanIdKey =
|
|
16
|
-
const traceIdKey =
|
|
14
|
+
const spanIdKey = configService.get('OTEL_SPAN_ID_KEY') ?? 'spanId';
|
|
15
|
+
const traceIdKey = configService.get('OTEL_TRACE_ID_KEY') ?? 'traceId';
|
|
16
|
+
const validLevels = [
|
|
17
|
+
'fatal',
|
|
18
|
+
'error',
|
|
19
|
+
'warn',
|
|
20
|
+
'info',
|
|
21
|
+
'debug',
|
|
22
|
+
'trace',
|
|
23
|
+
];
|
|
24
|
+
if (!validLevels.includes(level)) {
|
|
25
|
+
throw new Error(`Invalid LOG_LEVEL: ${level}. Must be one of: ${validLevels.join(', ')}`);
|
|
26
|
+
}
|
|
17
27
|
return {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
app,
|
|
29
|
+
filename,
|
|
30
|
+
level,
|
|
31
|
+
loki,
|
|
32
|
+
spanIdKey,
|
|
33
|
+
traceIdKey,
|
|
24
34
|
};
|
|
25
35
|
}
|
|
36
|
+
function getPinoHttpFromConfig(config) {
|
|
37
|
+
return [
|
|
38
|
+
(0, options_js_1.getPinoHttpOption)(config.level, config.spanIdKey, config.traceIdKey),
|
|
39
|
+
(0, streams_js_1.getMultiDestinationStream)(config.app, config.level, config.filename, config.loki),
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
function getParamsFromConfig(config, overrides) {
|
|
43
|
+
const pinoHttp = getPinoHttpFromConfig(config);
|
|
44
|
+
const params = {
|
|
45
|
+
pinoHttp,
|
|
46
|
+
exclude: [{ method: 0, path: '/health' }],
|
|
47
|
+
};
|
|
48
|
+
return Object.assign(params, overrides);
|
|
49
|
+
}
|
|
50
|
+
function getNestjsPinoModuleOptions(configService, overrides = {}) {
|
|
51
|
+
const config = extractLogConfig(configService);
|
|
52
|
+
return getParamsFromConfig(config, overrides);
|
|
53
|
+
}
|
|
26
54
|
//# sourceMappingURL=module-option.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-option.js","sourceRoot":"","sources":["../src/module-option.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"module-option.js","sourceRoot":"","sources":["../src/module-option.ts"],"names":[],"mappings":";;AAuBA,4CAiCC;AAED,sDAUC;AAQD,kDAWC;AAmBD,gEAOC;AA5GD,6CAAiD;AACjD,6CAAyD;AAiBzD,SAAgB,gBAAgB,CAAC,aAA4B;IAC3D,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAS,mBAAmB,CAAC,IAAI,KAAK,CAAC;IACpE,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAa,WAAW,CAAC,IAAI,MAAM,CAAC;IACnE,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAS,UAAU,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAS,UAAU,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAS,kBAAkB,CAAC,IAAI,QAAQ,CAAC;IAC5E,MAAM,UAAU,GACd,aAAa,CAAC,GAAG,CAAS,mBAAmB,CAAC,IAAI,SAAS,CAAC;IAG9D,MAAM,WAAW,GAAiB;QAChC,OAAO;QACP,OAAO;QACP,MAAM;QACN,MAAM;QACN,OAAO;QACP,OAAO;KACR,CAAC;IAEF,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,sBAAsB,KAAK,qBAAqB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACzE,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG;QACH,QAAQ;QACR,KAAK;QACL,IAAI;QACJ,SAAS;QACT,UAAU;KACX,CAAC;AACJ,CAAC;AAED,SAAgB,qBAAqB,CAAC,MAAiB;IACrD,OAAO;QACL,IAAA,8BAAiB,EAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,UAAU,CAAC;QACpE,IAAA,sCAAyB,EACvB,MAAM,CAAC,GAAG,EACV,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,IAAI,CACZ;KACF,CAAC;AACJ,CAAC;AAQD,SAAgB,mBAAmB,CACjC,MAAiB,EACjB,SAAkB;IAElB,MAAM,QAAQ,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAW;QACrB,QAAQ;QACR,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KAC1C,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAC1C,CAAC;AAmBD,SAAgB,0BAA0B,CACxC,aAA4B,EAC5B,YAAoB,EAAE;IAEtB,MAAM,MAAM,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAE/C,OAAO,mBAAmB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC"}
|
package/dist/options.d.ts
CHANGED
package/dist/options.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.getPinoHttpOption = getPinoHttpOption;
|
|
4
7
|
const node_crypto_1 = require("node:crypto");
|
|
5
|
-
const pino_1 = require("pino");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
/**
|
|
9
|
-
* get pino http option
|
|
10
|
-
*/
|
|
8
|
+
const pino_1 = __importDefault(require("pino"));
|
|
9
|
+
const formatters_js_1 = require("./formatters.js");
|
|
10
|
+
const serializers_js_1 = require("./serializers.js");
|
|
11
11
|
function getPinoHttpOption(level = 'info', spanIdKey = 'spanId', traceIdKey = 'traceId') {
|
|
12
12
|
return {
|
|
13
|
-
// https://getpino.io/#/docs/api?id=timestamp-boolean-function
|
|
14
|
-
// Change time value in production log.
|
|
15
|
-
// timestamp: stdTimeFunctions.isoTime,
|
|
16
13
|
level,
|
|
17
14
|
quietReqLogger: false,
|
|
18
15
|
timestamp: pino_1.default.stdTimeFunctions.isoTime,
|
|
@@ -22,8 +19,8 @@ function getPinoHttpOption(level = 'info', spanIdKey = 'spanId', traceIdKey = 't
|
|
|
22
19
|
err: 'err',
|
|
23
20
|
responseTime: 'taken(ms)',
|
|
24
21
|
},
|
|
25
|
-
formatters: (0,
|
|
26
|
-
serializers: (0,
|
|
22
|
+
formatters: (0, formatters_js_1.getOtelFormatters)(spanIdKey, traceIdKey),
|
|
23
|
+
serializers: (0, serializers_js_1.getSerializers)(),
|
|
27
24
|
redact: {
|
|
28
25
|
paths: [
|
|
29
26
|
'password',
|
|
@@ -33,15 +30,13 @@ function getPinoHttpOption(level = 'info', spanIdKey = 'spanId', traceIdKey = 't
|
|
|
33
30
|
],
|
|
34
31
|
},
|
|
35
32
|
genReqId: function (req, res) {
|
|
36
|
-
|
|
37
|
-
const reqId = (_a = req.id) !== null && _a !== void 0 ? _a : req.headers['x-request-id'];
|
|
33
|
+
const reqId = req.id ?? req.headers['x-request-id'];
|
|
38
34
|
if (reqId)
|
|
39
35
|
return reqId;
|
|
40
36
|
const id = (0, node_crypto_1.randomUUID)();
|
|
41
37
|
res.setHeader('X-Request-Id', id);
|
|
42
38
|
return id;
|
|
43
39
|
},
|
|
44
|
-
// Define a custom logger level
|
|
45
40
|
customLogLevel(_, res, err) {
|
|
46
41
|
if (res.statusCode >= 400 && res.statusCode < 500) {
|
|
47
42
|
return 'warn';
|
package/dist/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":";;;;;AAcA,8CAuDC;AApED,6CAAyC;AAKzC,gDAAwB;AAExB,mDAAoD;AACpD,qDAAkD;AAKlD,SAAgB,iBAAiB,CAC/B,KAAK,GAAG,MAAM,EACd,SAAS,GAAG,QAAQ,EACpB,UAAU,GAAG,SAAS;IAEtB,OAAO;QAIL,KAAK;QACL,cAAc,EAAE,KAAK;QACrB,SAAS,EAAE,cAAI,CAAC,gBAAgB,CAAC,OAAO;QACxC,mBAAmB,EAAE;YACnB,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,KAAK;YACV,YAAY,EAAE,WAAW;SAC1B;QACD,UAAU,EAAE,IAAA,iCAAiB,EAAC,SAAS,EAAE,UAAU,CAAC;QACpD,WAAW,EAAE,IAAA,+BAAc,GAAE;QAC7B,MAAM,EAAE;YACN,KAAK,EAAE;gBACL,UAAU;gBACV,kBAAkB;gBAClB,eAAe;gBACf,uBAAuB;aACxB;SACF;QACD,QAAQ,EAAE,UAAU,GAAG,EAAE,GAAG;YAC1B,MAAM,KAAK,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YAEpD,IAAI,KAAK;gBAAE,OAAO,KAAK,CAAC;YACxB,MAAM,EAAE,GAAG,IAAA,wBAAU,GAAE,CAAC;YAExB,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;YAElC,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,cAAc,CACZ,CAAkB,EAClB,GAAoC,EACpC,GAAW;YAEX,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC;gBAClD,OAAO,MAAM,CAAC;YAChB,CAAC;iBAAM,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;gBACxC,OAAO,OAAO,CAAC;YACjB,CAAC;iBAAM,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC;gBACzD,OAAO,QAAQ,CAAC;YAClB,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/serializers.d.ts
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
import type { SerializerFn } from 'pino';
|
|
2
|
-
|
|
3
|
-
* get serializers
|
|
4
|
-
* https://github.com/pinojs/pino-http?tab=readme-ov-file#custom-serializers--custom-log-attribute-keys
|
|
5
|
-
*/
|
|
6
|
-
export declare function getSerializers(): {
|
|
7
|
-
[key: string]: SerializerFn;
|
|
8
|
-
};
|
|
2
|
+
export declare function getSerializers(): Record<string, SerializerFn>;
|
package/dist/serializers.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSerializers = getSerializers;
|
|
4
|
-
/**
|
|
5
|
-
* get serializers
|
|
6
|
-
* https://github.com/pinojs/pino-http?tab=readme-ov-file#custom-serializers--custom-log-attribute-keys
|
|
7
|
-
*/
|
|
8
4
|
function getSerializers() {
|
|
9
5
|
return {
|
|
10
6
|
req(req) {
|
package/dist/serializers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializers.js","sourceRoot":"","sources":["../src/serializers.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"serializers.js","sourceRoot":"","sources":["../src/serializers.ts"],"names":[],"mappings":";;AAYA,wCAyBC;AAzBD,SAAgB,cAAc;IAC5B,OAAO;QACL,GAAG,CAAC,GAAsB;YACxB,MAAM,OAAO,GAAG,GAAG,CAAC,GAEnB,CAAC;YAEF,OAAO;gBACL,EAAE,EAAE,GAAG,CAAC,EAAE;gBACV,MAAM,EAAE,GAAG,CAAC,MAAM;gBAClB,GAAG,EAAE,GAAG,CAAC,GAAG;gBACZ,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB,CAAC;QACJ,CAAC;QACD,GAAG,CAAC,QAA4B;YAC9B,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,GAAG,QAAQ,CAAC;YAEvD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,UAAU,CAAC,CAAC;QAC/C,CAAC;QACD,GAAG,CAAC,GAAoB;YACtB,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/streams.d.ts
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
import pino from 'pino';
|
|
2
|
-
|
|
3
|
-
* create pretty stream entry
|
|
4
|
-
*/
|
|
5
|
-
export declare function createPrettyStreamEntry(app: string, level: pino.Level): pino.StreamEntry;
|
|
6
|
-
/**
|
|
7
|
-
* create loki stream entry
|
|
8
|
-
* https://github.com/pinojs/pino/blob/master/docs/transports.md#pino-loki
|
|
9
|
-
*/
|
|
2
|
+
export declare function createPrettyStreamEntry(_app: string, level: pino.Level): pino.StreamEntry;
|
|
10
3
|
export declare function createLokiStreamEntry(app: string, level: pino.Level, host: string): pino.StreamEntry;
|
|
11
|
-
|
|
12
|
-
* create file stream entry
|
|
13
|
-
* https://github.com/iccicci/rotating-file-stream?tab=readme-ov-file#initialrotation
|
|
14
|
-
*/
|
|
15
|
-
export declare function createFileStreamEntry(app: string, level: pino.Level, filepath: string): pino.StreamEntry;
|
|
16
|
-
/**
|
|
17
|
-
* add multi destination stream
|
|
18
|
-
* support pretty, file, loki
|
|
19
|
-
*/
|
|
4
|
+
export declare function createFileStreamEntry(_app: string, level: pino.Level, filepath: string): pino.StreamEntry;
|
|
20
5
|
export declare function getMultiDestinationStream(app: string, level?: pino.Level, filepath?: string, loki?: string): pino.MultiStreamRes;
|
package/dist/streams.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.createPrettyStreamEntry = createPrettyStreamEntry;
|
|
4
7
|
exports.createLokiStreamEntry = createLokiStreamEntry;
|
|
5
8
|
exports.createFileStreamEntry = createFileStreamEntry;
|
|
6
9
|
exports.getMultiDestinationStream = getMultiDestinationStream;
|
|
7
|
-
const node_path_1 = require("node:path");
|
|
8
|
-
const pino_1 = require("pino");
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const pino_1 = __importDefault(require("pino"));
|
|
9
12
|
const pino_loki_1 = require("pino-loki");
|
|
10
|
-
const pino_pretty_1 = require("pino-pretty");
|
|
13
|
+
const pino_pretty_1 = __importDefault(require("pino-pretty"));
|
|
11
14
|
const rotating_file_stream_1 = require("rotating-file-stream");
|
|
12
|
-
|
|
13
|
-
* create pretty stream entry
|
|
14
|
-
*/
|
|
15
|
-
function createPrettyStreamEntry(app, level) {
|
|
15
|
+
function createPrettyStreamEntry(_app, level) {
|
|
16
16
|
const stream = (0, pino_pretty_1.default)({
|
|
17
17
|
translateTime: false,
|
|
18
18
|
hideObject: false,
|
|
@@ -20,38 +20,26 @@ function createPrettyStreamEntry(app, level) {
|
|
|
20
20
|
});
|
|
21
21
|
return { level, stream };
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* create loki stream entry
|
|
25
|
-
* https://github.com/pinojs/pino/blob/master/docs/transports.md#pino-loki
|
|
26
|
-
*/
|
|
27
23
|
function createLokiStreamEntry(app, level, host) {
|
|
28
24
|
const stream = (0, pino_loki_1.pinoLoki)({
|
|
29
25
|
replaceTimestamp: true,
|
|
30
26
|
batching: true,
|
|
31
27
|
interval: 5,
|
|
32
|
-
host,
|
|
28
|
+
host,
|
|
33
29
|
labels: { app },
|
|
34
30
|
});
|
|
35
31
|
return { level, stream };
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* https://github.com/iccicci/rotating-file-stream?tab=readme-ov-file#initialrotation
|
|
40
|
-
*/
|
|
41
|
-
function createFileStreamEntry(app, level, filepath) {
|
|
42
|
-
const { dir, base } = node_path_1.default.parse(filepath);
|
|
33
|
+
function createFileStreamEntry(_app, level, filepath) {
|
|
34
|
+
const { base, dir } = node_path_1.default.parse(filepath);
|
|
43
35
|
const stream = (0, rotating_file_stream_1.createStream)(base, {
|
|
44
|
-
size: '1G',
|
|
45
|
-
interval: '1d',
|
|
46
|
-
compress: 'gzip',
|
|
36
|
+
size: '1G',
|
|
37
|
+
interval: '1d',
|
|
38
|
+
compress: 'gzip',
|
|
47
39
|
path: dir,
|
|
48
40
|
});
|
|
49
41
|
return { level, stream };
|
|
50
42
|
}
|
|
51
|
-
/**
|
|
52
|
-
* add multi destination stream
|
|
53
|
-
* support pretty, file, loki
|
|
54
|
-
*/
|
|
55
43
|
function getMultiDestinationStream(app, level = 'info', filepath, loki) {
|
|
56
44
|
const entries = [createPrettyStreamEntry(app, level)];
|
|
57
45
|
if (filepath)
|
package/dist/streams.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streams.js","sourceRoot":"","sources":["../src/streams.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"streams.js","sourceRoot":"","sources":["../src/streams.ts"],"names":[],"mappings":";;;;;AAWA,0DAWC;AAMD,sDAcC;AAMD,sDAeC;AAMD,8DAYC;AAhFD,0DAA6B;AAE7B,gDAAwB;AACxB,yCAAqC;AACrC,8DAAqC;AACrC,+DAAoD;AAKpD,SAAgB,uBAAuB,CACrC,IAAY,EACZ,KAAiB;IAEjB,MAAM,MAAM,GAAG,IAAA,qBAAU,EAAC;QACxB,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC;AAMD,SAAgB,qBAAqB,CACnC,GAAW,EACX,KAAiB,EACjB,IAAY;IAEZ,MAAM,MAAM,GAAG,IAAA,oBAAQ,EAAC;QACtB,gBAAgB,EAAE,IAAI;QACtB,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,CAAC;QACX,IAAI;QACJ,MAAM,EAAE,EAAE,GAAG,EAAE;KAChB,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC;AAMD,SAAgB,qBAAqB,CACnC,IAAY,EACZ,KAAiB,EACjB,QAAgB;IAEhB,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,mBAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAG,IAAA,mCAAY,EAAC,IAAI,EAAE;QAChC,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,GAAG;KACV,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC3B,CAAC;AAMD,SAAgB,yBAAyB,CACvC,GAAW,EACX,QAAoB,MAAM,EAC1B,QAAiB,EACjB,IAAa;IAEb,MAAM,OAAO,GAAuB,CAAC,uBAAuB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;IAE1E,IAAI,QAAQ;QAAE,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IACxE,IAAI,IAAI;QAAE,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;IAEhE,OAAO,cAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC"}
|