UNPKG

3.19 kBTypeScriptView Raw
1/**
2 * Deeply update the global logger context. This only affects newly created loggers
3 *
4 * @param {Record<string, any>} context
5 */
6export function loggerExtendGlobalContext(context: Record<string, any>): void;
7/**
8 * Set the global logger destination to use the provided pino destination. This only
9 * affects loggers created after this function call.
10 *
11 * You can use any form of support Pino destination here. Even
12 * {@link https://getpino.io/#/docs/transports Pino transports} via `pino.transport()`.
13 * It defaults to `pino.destination(1)` which writes to `process.stdout`.
14 *
15 * @see https://getpino.io/#/docs/api?id=pino-destination
16 *
17 * @param {import("pino").DestinationStream} destination
18 */
19export function loggerSetGlobalDestination(destination: import("pino").DestinationStream): void;
20/**
21 * Returns the current pino destination.
22 *
23 * This can be used to temporarily set a different destination for the newly created
24 * loggers and then reusing the destination for the rest of your application.
25 *
26 * @returns {import("pino").DestinationStream}
27 */
28export function loggerGetGlobalDestination(): import("pino").DestinationStream;
29/**
30 * Set the global root pino instance. We use a single instance, so the same destination
31 * will be used for all sub loggers.
32 *
33 * @param {import("pino").DestinationStream} destination
34 */
35export function loggerBuildRootInstance(destination: import("pino").DestinationStream): import("pino").Logger<{
36 formatters: {
37 level: (label: string) => {
38 level: string;
39 };
40 bindings: () => {};
41 };
42 serializers: {};
43 base: {};
44}>;
45/**
46 * Create a new logger instance. The provided `ctx` will shallowly overwrite the global
47 * context that is set via {@see loggerExtendGlobalContext}.
48 *
49 * The logger uses the transport or destination set via
50 *
51 * @param {{ ctx?: Record<string, any> }} [options]
52 * @returns {Logger}
53 */
54export function newLogger(options?: {
55 ctx?: Record<string, any> | undefined;
56} | undefined): Logger;
57/**
58 * Infer the default printer that we should use based on the currently set environment
59 * variables.
60 *
61 * Can be overwritten by `process.env.COMPAS_LOG_PRINTER`. Accepted values are `pretty',
62 * 'ndjson', 'github-actions'.
63 */
64export function loggerDetermineDefaultDestination(): void;
65/**
66 *
67 * @param {{
68 * addGitHubActionsAnnotations: boolean,
69 * }} options
70 * @returns {import("pino").DestinationStream}
71 */
72export function loggerGetPrettyPrinter(options: {
73 addGitHubActionsAnnotations: boolean;
74}): import("pino").DestinationStream;
75/**
76 * The logger only has two severities:
77 * - info
78 * - error
79 *
80 * Either a log line is innocent enough and only provides debug information if needed, or
81 * someone should be paged because something goes wrong. For example, handled 400 errors
82 * probably do not require anyones attention, but unhandled 500 errors do.
83 *
84 * The log functions only accept a single parameter. This prevents magic
85 * outputs like automatic concatenating strings in to a single message, or always having
86 * a top-level array as a message.
87 */
88export type Logger = {
89 info: (arg0: any) => void;
90 error: (arg0: any) => void;
91};