UNPKG

3.03 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<never>;
36/**
37 * Create a new logger instance. The provided `ctx` will shallowly overwrite the global
38 * context that is set via {@see loggerExtendGlobalContext}.
39 *
40 * The logger uses the transport or destination set via
41 *
42 * @param {{ ctx?: Record<string, any> }} [options]
43 * @returns {Logger}
44 */
45export function newLogger(options?: {
46 ctx?: Record<string, any> | undefined;
47} | undefined): Logger;
48/**
49 * Infer the default printer that we should use based on the currently set environment
50 * variables.
51 *
52 * Can be overwritten by `process.env.COMPAS_LOG_PRINTER`. Accepted values are `pretty',
53 * 'ndjson', 'github-actions'.
54 */
55export function loggerDetermineDefaultDestination(): void;
56/**
57 *
58 * @param {{
59 * addGitHubActionsAnnotations: boolean,
60 * }} options
61 * @returns {import("pino").DestinationStream}
62 */
63export function loggerGetPrettyPrinter(options: {
64 addGitHubActionsAnnotations: boolean;
65}): import("pino").DestinationStream;
66/**
67 * The logger only has two severities:
68 * - info
69 * - error
70 *
71 * Either a log line is innocent enough and only provides debug information if needed, or
72 * someone should be paged because something goes wrong. For example, handled 400 errors
73 * probably do not require anyones attention, but unhandled 500 errors do.
74 *
75 * The log functions only accept a single parameter. This prevents magic
76 * outputs like automatic concatenating strings in to a single message, or always having
77 * a top-level array as a message.
78 */
79export type Logger = {
80 info: (arg0: any) => void;
81 error: (arg0: any) => void;
82};