widelogger 0.6.0 → 0.7.0
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/dist/index.d.ts +3 -1
- package/dist/index.js +18 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TransportMultiOptions, TransportSingleOptions } from "pino";
|
|
1
2
|
import type { DottedKey, ErrorParser, FieldValue } from "./types";
|
|
2
3
|
export interface WideloggerOptions {
|
|
3
4
|
service: string;
|
|
@@ -7,6 +8,7 @@ export interface WideloggerOptions {
|
|
|
7
8
|
instanceId?: string;
|
|
8
9
|
environment?: string;
|
|
9
10
|
level?: string;
|
|
11
|
+
transport?: TransportSingleOptions | TransportMultiOptions;
|
|
10
12
|
}
|
|
11
13
|
export interface ErrorFieldsOptions {
|
|
12
14
|
prefix?: string;
|
|
@@ -45,4 +47,4 @@ export declare const widelogger: (options: WideloggerOptions) => {
|
|
|
45
47
|
destroy: () => Promise<void>;
|
|
46
48
|
};
|
|
47
49
|
export type Widelog = typeof widelog;
|
|
48
|
-
export {};
|
|
50
|
+
export type { TransportMultiOptions, TransportSingleOptions } from "pino";
|
package/dist/index.js
CHANGED
|
@@ -350,19 +350,28 @@ var widelog = {
|
|
|
350
350
|
store.transport(event);
|
|
351
351
|
}
|
|
352
352
|
};
|
|
353
|
+
function resolveTransport(custom, isDevelopment) {
|
|
354
|
+
if (custom) {
|
|
355
|
+
return pino.transport(custom);
|
|
356
|
+
}
|
|
357
|
+
if (isDevelopment) {
|
|
358
|
+
return pino.transport({
|
|
359
|
+
target: "pino-pretty",
|
|
360
|
+
options: {
|
|
361
|
+
colorize: true,
|
|
362
|
+
singleLine: true,
|
|
363
|
+
translateTime: "SYS:standard",
|
|
364
|
+
ignore: "pid,hostname"
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
353
370
|
var widelogger = (options) => {
|
|
354
371
|
const nodeEnvironment = typeof process.env === "object" ? "development" : undefined;
|
|
355
372
|
const environment = options.environment ?? nodeEnvironment ?? "development";
|
|
356
373
|
const isDevelopment = environment !== "production";
|
|
357
|
-
const pinoTransport =
|
|
358
|
-
target: "pino-pretty",
|
|
359
|
-
options: {
|
|
360
|
-
colorize: true,
|
|
361
|
-
singleLine: true,
|
|
362
|
-
translateTime: "SYS:standard",
|
|
363
|
-
ignore: "pid,hostname"
|
|
364
|
-
}
|
|
365
|
-
}) : undefined;
|
|
374
|
+
const pinoTransport = resolveTransport(options.transport, isDevelopment);
|
|
366
375
|
const logger = pino({
|
|
367
376
|
level: options.level ?? process.env.LOG_LEVEL ?? "info",
|
|
368
377
|
timestamp: pino.stdTimeFunctions.isoTime,
|