@foam-ai/node-cliengo 0.1.0-alpha.15 → 0.1.0-alpha.16
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.
|
@@ -106,6 +106,7 @@ function createInertInstance(serviceName) {
|
|
|
106
106
|
}),
|
|
107
107
|
createPinoLogger: () => console,
|
|
108
108
|
createPinoHttpConfig: (opts) => (opts?.logger ? { logger: opts.logger } : {}),
|
|
109
|
+
createFastifyLoggerConfig: (opts) => ({ level: opts?.level ?? 'info' }),
|
|
109
110
|
buildTraceparent: trace_bridge_1.buildTraceparent,
|
|
110
111
|
injectSnsAttributes: sns_1.injectSnsAttributes,
|
|
111
112
|
injectJobData: job_1.injectJobData,
|
|
@@ -363,6 +364,20 @@ function init(serviceName, options = {}) {
|
|
|
363
364
|
const pinoHttpOpts = (0, express_1.createPinoHttpOptions)();
|
|
364
365
|
return { ...pinoHttpOpts, ...(opts?.logger && { logger: opts.logger }) };
|
|
365
366
|
},
|
|
367
|
+
createFastifyLoggerConfig: (opts = {}) => {
|
|
368
|
+
const pino = require('pino');
|
|
369
|
+
const mixin = (0, pino_mixin_1.createPinoMixin)();
|
|
370
|
+
const dest = (0, pino_destination_1.createPinoDestination)(loggerProvider, serviceName);
|
|
371
|
+
const { streams: userStreams, ...pinoOpts } = opts;
|
|
372
|
+
const outputStreams = userStreams ?? [
|
|
373
|
+
{ stream: process.stdout },
|
|
374
|
+
];
|
|
375
|
+
return {
|
|
376
|
+
...pinoOpts,
|
|
377
|
+
mixin,
|
|
378
|
+
stream: pino.multistream([...outputStreams, { stream: dest }]),
|
|
379
|
+
};
|
|
380
|
+
},
|
|
366
381
|
buildTraceparent: trace_bridge_1.buildTraceparent,
|
|
367
382
|
injectSnsAttributes: sns_1.injectSnsAttributes,
|
|
368
383
|
injectJobData: job_1.injectJobData,
|
|
@@ -76,6 +76,21 @@ export interface FoamInstance {
|
|
|
76
76
|
createPinoHttpConfig(opts?: {
|
|
77
77
|
logger?: any;
|
|
78
78
|
}): Record<string, any>;
|
|
79
|
+
/**
|
|
80
|
+
* Returns a Pino config object for Fastify's `logger` constructor option.
|
|
81
|
+
* Fastify constructs its own Pino instance from this, so request.log gets
|
|
82
|
+
* child loggers with request context automatically.
|
|
83
|
+
*
|
|
84
|
+
* Fastify({ logger: foam.createFastifyLoggerConfig({ level: 'info' }) })
|
|
85
|
+
*
|
|
86
|
+
* Pass `streams` to replace stdout (e.g., pino-pretty in dev):
|
|
87
|
+
*
|
|
88
|
+
* foam.createFastifyLoggerConfig({
|
|
89
|
+
* level: 'debug',
|
|
90
|
+
* streams: [{ stream: pinoPretty() }],
|
|
91
|
+
* })
|
|
92
|
+
*/
|
|
93
|
+
createFastifyLoggerConfig(opts?: Record<string, any>): Record<string, any>;
|
|
79
94
|
buildTraceparent(): string;
|
|
80
95
|
injectSnsAttributes(attrs: Record<string, SnsMessageAttributeValue>): Record<string, SnsMessageAttributeValue>;
|
|
81
96
|
injectJobData<T extends Record<string, unknown>>(data: T): T & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foam-ai/node-cliengo",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.16",
|
|
4
4
|
"description": "Unified observability (traces, logs, metrics) for Cliengo Node.js services, connecting New Relic APM with Foam's OTel collector.",
|
|
5
5
|
"main": "dist/node-cliengo/src/index.js",
|
|
6
6
|
"types": "dist/node-cliengo/src/index.d.ts",
|