@decohere/scribe-pino 0.0.1-dev.7 → 0.0.1-dev.71
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/commonjs/src/index.js +2 -1
- package/commonjs/src/pino.adapater.js +123 -1
- package/commonjs/src/pino.recipe.js +67 -0
- package/commonjs/src/pino.transport-guard.js +70 -0
- package/commonjs/src/scribe-pino.js +130 -26
- package/es6/src/index.js +2 -1
- package/es6/src/pino.adapater.js +124 -2
- package/es6/src/pino.recipe.js +57 -0
- package/es6/src/pino.transport-guard.js +63 -0
- package/es6/src/scribe-pino.js +113 -24
- package/package.json +16 -4
- package/types/src/index.d.ts +1 -0
- package/types/src/pino.adapater.d.ts +8 -0
- package/types/src/pino.recipe.d.ts +31 -0
- package/types/src/pino.transport-guard.d.ts +10 -0
- package/types/src/scribe-pino.d.ts +54 -9
|
@@ -1,24 +1,69 @@
|
|
|
1
1
|
import { type Environment } from "@decohere/nexus/system";
|
|
2
2
|
import { type DefaultLevels, type Logger, type ScribeOptions, scribe } from "@decohere/scribe";
|
|
3
|
-
import type
|
|
3
|
+
import { type DestinationStream, type TransportMultiOptions, type TransportPipelineOptions, type TransportSingleOptions } from "pino";
|
|
4
|
+
import { type PinoPrettyRecipeOptions, type PinoRollRecipeOptions } from "./pino.recipe.js";
|
|
5
|
+
import { type GuardedTransport, guardTransport } from "./pino.transport-guard.js";
|
|
6
|
+
export type { GuardedTransport } from "./pino.transport-guard.js";
|
|
7
|
+
export { guardTransport } from "./pino.transport-guard.js";
|
|
8
|
+
type TransportOptions = TransportSingleOptions | TransportMultiOptions | TransportPipelineOptions;
|
|
4
9
|
type TransportConfig = {
|
|
5
10
|
environment?: Environment;
|
|
6
|
-
transports:
|
|
11
|
+
transports: TransportOptions;
|
|
7
12
|
};
|
|
8
13
|
type CustomLevelOptions<T extends string = never, CustomOnly extends true = undefined> = {
|
|
9
14
|
scribe?: ScribeOptions<T, CustomOnly>;
|
|
10
15
|
transports?: TransportConfig | TransportConfig[];
|
|
11
16
|
};
|
|
17
|
+
export type PinoLoggerFactory = (name?: string) => Logger;
|
|
18
|
+
export type PinoRecipeChain = {
|
|
19
|
+
withPinoPretty(logLevelOrOptions?: DefaultLevels | string | PinoPrettyRecipeOptions): PinoRecipe;
|
|
20
|
+
withPinoRoll(options: PinoRollRecipeOptions): PinoRecipe;
|
|
21
|
+
};
|
|
22
|
+
export type PinoRecipe = PinoLoggerFactory & PinoRecipeChain & {
|
|
23
|
+
readonly and: PinoRecipeChain;
|
|
24
|
+
};
|
|
12
25
|
declare module "@decohere/scribe" {
|
|
13
26
|
interface scribe {
|
|
14
|
-
withPino(transports: TransportConfig | TransportConfig[], loglevel?: DefaultLevels | string):
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
withPino(transports: TransportConfig | TransportConfig[], loglevel?: DefaultLevels | string): PinoLoggerFactory;
|
|
28
|
+
/**
|
|
29
|
+
* Colorized pretty transport. Development only unless `{ when: "always" }`.
|
|
30
|
+
* Chain with `.and.withPinoRoll({ file })`. Production writes JSON to stdout
|
|
31
|
+
* so log shipping stays outside the process.
|
|
32
|
+
*/
|
|
33
|
+
withPinoPretty(logLevelOrOptions?: DefaultLevels | string | PinoPrettyRecipeOptions): PinoRecipe;
|
|
34
|
+
/**
|
|
35
|
+
* Rolling log files. Development only unless `{ when: "always" }`.
|
|
36
|
+
* Do not enable in production — ship stdout from a sidecar or platform agent.
|
|
37
|
+
* `symlink` defaults off; enabling it can race under multi-worker / HMR.
|
|
38
|
+
*/
|
|
39
|
+
withPinoRoll(options: PinoRollRecipeOptions): PinoRecipe;
|
|
40
|
+
withPinoCustom<T extends string = never, CustomOnly extends true = undefined>(options?: CustomLevelOptions<T, CustomOnly>): PinoLoggerFactory;
|
|
41
|
+
}
|
|
42
|
+
namespace scribe {
|
|
43
|
+
function withPino(transports: TransportConfig | TransportConfig[], loglevel?: DefaultLevels | string): PinoLoggerFactory;
|
|
44
|
+
function withPinoPretty(logLevelOrOptions?: DefaultLevels | string | PinoPrettyRecipeOptions): PinoRecipe;
|
|
45
|
+
function withPinoRoll(options: PinoRollRecipeOptions): PinoRecipe;
|
|
46
|
+
function withPinoCustom<T extends string = never, CustomOnly extends true = undefined>(options?: CustomLevelOptions<T, CustomOnly>): PinoLoggerFactory;
|
|
17
47
|
}
|
|
18
48
|
}
|
|
19
49
|
export declare class PinoExtensions {
|
|
20
|
-
static withPino(factory: scribe, config: TransportConfig | TransportConfig[], logLevel?: DefaultLevels | string):
|
|
21
|
-
static withPinoPretty(factory: scribe,
|
|
22
|
-
static
|
|
50
|
+
static withPino(factory: scribe, config: TransportConfig | TransportConfig[], logLevel?: DefaultLevels | string): (name?: string) => Logger<never, false>;
|
|
51
|
+
static withPinoPretty(factory: scribe, logLevelOrOptions?: DefaultLevels | string | PinoPrettyRecipeOptions): PinoRecipe;
|
|
52
|
+
static withPinoRoll(factory: scribe, options: PinoRollRecipeOptions): PinoRecipe;
|
|
53
|
+
static withPinoCustom<T extends string = never, CustomOnly extends true = undefined>(factory: scribe, options?: CustomLevelOptions<T, CustomOnly>): (name?: string) => Logger<T, CustomOnly>;
|
|
23
54
|
}
|
|
24
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Guard a worker transport so failures (roll EEXIST, worker exit) neither
|
|
57
|
+
* crash the process nor spam stderr on every subsequent log write.
|
|
58
|
+
*/
|
|
59
|
+
declare function createSafeTransport(options: TransportOptions): DestinationStream;
|
|
60
|
+
/** @deprecated Use {@link guardTransport} — kept for callers/tests from the silence-only era. */
|
|
61
|
+
declare function silenceErrors(transport: {
|
|
62
|
+
on(event: "error", listener: (err: Error) => void): unknown;
|
|
63
|
+
write?: (...args: never[]) => unknown;
|
|
64
|
+
}): GuardedTransport;
|
|
65
|
+
export declare const pinoTransport: {
|
|
66
|
+
createSafeTransport: typeof createSafeTransport;
|
|
67
|
+
guardTransport: typeof guardTransport;
|
|
68
|
+
silenceErrors: typeof silenceErrors;
|
|
69
|
+
};
|