# Interface LoggerOptions<CustomLevels, UseOnlyCustomLevels>

interface LoggerOptions<CustomLevels, UseOnlyCustomLevels> {
transport?: TransportSingleOptions<Record<string, any>> | TransportMultiOptions<Record<string, any>> | TransportPipelineOptions<Record<string, any>>;
safe?: boolean;
name?: string;
serializers?: {
[key: string]: SerializerFn;
};
timestamp?: boolean | TimeFn;
level?: LevelWithSilentOrString;
customLevels?: {
[level in string]: number
};
useOnlyCustomLevels?: UseOnlyCustomLevels;
levelComparison?: "ASC" | "DESC" | ((current: number, expected: number) => boolean);
mixin?: MixinFn<CustomLevels>;
mixinMergeStrategy?: MixinMergeStrategyFn;
redact?: string[] | redactOptions;
levelVal?: number;
messageKey?: string;
errorKey?: string;
nestedKey?: string;
enabled?: boolean;
browser?: {
asObject?: boolean;
formatters?: {
level?: ((label: string, number: number) => object);
log?: ((object: Record<string, unknown>) => Record<string, unknown>);
};
write?: WriteFn | {
fatal?: WriteFn;
error?: WriteFn;
warn?: WriteFn;
info?: WriteFn;
debug?: WriteFn;
trace?: WriteFn;
} & {
[logLevel: string]: WriteFn;
};
serialize?: boolean | string[];
transmit?: {
level?: LevelOrString;
send: ((level: Level, logEvent: LogEvent) => void);
};
disabled?: boolean;
};
base?: {
[key: string]: any;
};
formatters?: {
level?: ((label: string, number: number) => object);
bindings?: ((bindings: Bindings) => object);
log?: ((object: Record<string, unknown>) => Record<string, unknown>);
};
msgPrefix?: string;
hooks?: {
logMethod?: ((this: Logger<never, boolean>, args: [msg: string, ...args: any[]], method: LogFn, level: number) => void);
};
depthLimit?: number;
edgeLimit?: number;
onChild?: OnChildCallback<CustomLevels>;
crlf?: boolean;
}

#### Type Parameters

- CustomLevels extends string = never
- UseOnlyCustomLevels extends boolean = boolean

#### Hierarchy (view full)

- LoggerOptions<CustomLevels, UseOnlyCustomLevels>
  - LoggerOptions

- Defined in node_modules/pino/pino.d.ts:865

#####
Index

### Properties

transport?
safe?
name?
serializers?
timestamp?
level?
customLevels?
useOnlyCustomLevels?
levelComparison?
mixin?
mixinMergeStrategy?
redact?
levelVal?
messageKey?
errorKey?
nestedKey?
enabled?
browser?
base?
formatters?
msgPrefix?
hooks?
depthLimit?
edgeLimit?
onChild?
crlf?

##
Properties

### `Optional` transport

transport?: TransportSingleOptions<Record<string, any>> | TransportMultiOptions<Record<string, any>> | TransportPipelineOptions<Record<string, any>>

Inherited from LoggerOptions.transport

- Defined in node_modules/pino/pino.d.ts:331

### `Optional` safe

safe?: boolean

Avoid error causes by circular references in the object tree. Default: `true`.

Inherited from LoggerOptions.safe

- Defined in node_modules/pino/pino.d.ts:335

### `Optional` name

name?: string

The name of the logger. Default: `undefined`.

Inherited from LoggerOptions.name

- Defined in node_modules/pino/pino.d.ts:339

### `Optional` serializers

serializers?: {
[key: string]: SerializerFn;
}

an object containing functions for custom serialization of objects. These functions should return an JSONifiable object and they should never throw. When logging an object, each top-level property matching the exact key of a serializer will be serialized using the defined serializer.

Inherited from LoggerOptions.serializers

- Defined in node_modules/pino/pino.d.ts:345

### `Optional` timestamp

timestamp?: boolean | TimeFn

Enables or disables the inclusion of a timestamp in the log message. If a function is supplied, it must synchronously return a JSON string representation of the time. If set to `false`, no timestamp will be included in the output. See stdTimeFunctions for a set of available functions for passing in as a value for this option. Caution: any sort of formatted time will significantly slow down Pino's performance.

Inherited from LoggerOptions.timestamp

- Defined in node_modules/pino/pino.d.ts:352

### `Optional` level

level?: LevelWithSilentOrString

One of the supported levels or `silent` to disable logging. Any other value defines a custom level and requires supplying a level value via `levelVal`. Default: 'info'.

Inherited from LoggerOptions.level

- Defined in node_modules/pino/pino.d.ts:357

### `Optional` customLevels

customLevels?: {
[level in string]: number
}

Use this option to define additional logging levels. The keys of the object correspond the namespace of the log level, and the values should be the numerical value of the level.

Inherited from LoggerOptions.customLevels

- Defined in node_modules/pino/pino.d.ts:363

### `Optional` useOnlyCustomLevels

useOnlyCustomLevels?: UseOnlyCustomLevels

Use this option to only use defined `customLevels` and omit Pino's levels. Logger's default `level` must be changed to a value in `customLevels` in order to use `useOnlyCustomLevels` Warning: this option may not be supported by downstream transports.

Inherited from LoggerOptions.useOnlyCustomLevels

- Defined in node_modules/pino/pino.d.ts:370

### `Optional` levelComparison

levelComparison?: "ASC" | "DESC" | ((current: number, expected: number) => boolean)

Use this option to define custom comparison of log levels. Useful to compare custom log levels or non-standard level values. Default: "ASC"

Inherited from LoggerOptions.levelComparison

- Defined in node_modules/pino/pino.d.ts:377

### `Optional` mixin

mixin?: MixinFn<CustomLevels>

If provided, the `mixin` function is called each time one of the active logging methods is called. The function must synchronously return an object. The properties of the returned object will be added to the logged JSON.

Inherited from LoggerOptions.mixin

- Defined in node_modules/pino/pino.d.ts:384

### `Optional` mixinMergeStrategy

mixinMergeStrategy?: MixinMergeStrategyFn

If provided, the `mixinMergeStrategy` function is called each time one of the active logging methods is called. The first parameter is the value `mergeObject` or an empty object, the second parameter is the value resulting from `mixin()` or an empty object. The function must synchronously return an object.

Inherited from LoggerOptions.mixinMergeStrategy

- Defined in node_modules/pino/pino.d.ts:392

### `Optional` redact

redact?: string[] | redactOptions

As an array, the redact option specifies paths that should have their values redacted from any log output.

Each path must be a string using a syntax which corresponds to JavaScript dot and bracket notation.

If an object is supplied, three options can be specified:

     paths (String[]): Required. An array of paths
     censor (String): Optional. A value to overwrite key which are to be redacted. Default: '[Redacted]'
     remove (Boolean): Optional. Instead of censoring the value, remove both the key and the value. Default: false

Inherited from LoggerOptions.redact

- Defined in node_modules/pino/pino.d.ts:405

### `Optional` levelVal

levelVal?: number

When defining a custom log level via level, set to an integer value to define the new level. Default: `undefined`.

Inherited from LoggerOptions.levelVal

- Defined in node_modules/pino/pino.d.ts:410

### `Optional` messageKey

messageKey?: string

The string key for the 'message' in the JSON object. Default: "msg".

Inherited from LoggerOptions.messageKey

- Defined in node_modules/pino/pino.d.ts:414

### `Optional` errorKey

errorKey?: string

The string key for the 'error' in the JSON object. Default: "err".

Inherited from LoggerOptions.errorKey

- Defined in node_modules/pino/pino.d.ts:418

### `Optional` nestedKey

nestedKey?: string

The string key to place any logged object under.

Inherited from LoggerOptions.nestedKey

- Defined in node_modules/pino/pino.d.ts:422

### `Optional` enabled

enabled?: boolean

Enables logging. Default: `true`.

Inherited from LoggerOptions.enabled

- Defined in node_modules/pino/pino.d.ts:426

### `Optional` browser

browser?: {
asObject?: boolean;
formatters?: {
level?: ((label: string, number: number) => object);
log?: ((object: Record<string, unknown>) => Record<string, unknown>);
};
write?: WriteFn | {
fatal?: WriteFn;
error?: WriteFn;
warn?: WriteFn;
info?: WriteFn;
debug?: WriteFn;
trace?: WriteFn;
} & {
[logLevel: string]: WriteFn;
};
serialize?: boolean | string[];
transmit?: {
level?: LevelOrString;
send: ((level: Level, logEvent: LogEvent) => void);
};
disabled?: boolean;
}

Browser only, see http://getpino.io/#/docs/browser.

#### Type declaration

- ##### `Optional` asObject?: boolean

  The `asObject` option will create a pino-like log object instead of passing all arguments to a console method. When `write` is set, `asObject` will always be true.

  #### Example

      pino.info('hi') // creates and logs {msg: 'hi', level: 30, time: <ts>}

- ##### `Optional` formatters?: {
  level?: ((label: string, number: number) => object);
  log?: ((object: Record<string, unknown>) => Record<string, unknown>);
  }

  - ##### `Optional` level?: ((label: string, number: number) => object)

    Changes the shape of the log level. The default shape is { level: number }.

    - - (label, number): object

      - #### Parameters

        - label: string
        - number: number

        #### Returns object

  - ##### `Optional` log?: ((object: Record<string, unknown>) => Record<string, unknown>)

    Changes the shape of the log object.

    - - (object): Record<string, unknown>

      - #### Parameters

        - object: Record<string, unknown>

        #### Returns Record<string, unknown>

- ##### `Optional` write?: WriteFn | {
  fatal?: WriteFn;
  error?: WriteFn;
  warn?: WriteFn;
  info?: WriteFn;
  debug?: WriteFn;
  trace?: WriteFn;
  } & {
  [logLevel: string]: WriteFn;
  }

  Instead of passing log messages to `console.log` they can be passed to a supplied function. If `write` is set to a single function, all logging objects are passed to this function. If `write` is an object, it can have methods that correspond to the levels. When a message is logged at a given level, the corresponding method is called. If a method isn't present, the logging falls back to using the `console`.

  #### Example

      const pino = require('pino')({
        browser: {
          write: (o) => {
            // do something with o
          }
        }
      })

  #### Example

      const pino = require('pino')({
        browser: {
          write: {
            info: function (o) {
              //process info log object
            },
            error: function (o) {
              //process error log object
            }
          }
        }
      })

- ##### `Optional` serialize?: boolean | string[]

  The serializers provided to `pino` are ignored by default in the browser, including the standard serializers provided with Pino. Since the default destination for log messages is the console, values such as `Error` objects are enhanced for inspection, which they otherwise wouldn't be if the Error serializer was enabled. We can turn all serializers on or we can selectively enable them via an array.

  When `serialize` is `true` the standard error serializer is also enabled (see https://github.com/pinojs/pino/blob/master/docs/api.md#pino-stdserializers). This is a global serializer which will apply to any `Error` objects passed to the logger methods.

  If `serialize` is an array the standard error serializer is also automatically enabled, it can be explicitly disabled by including a string in the serialize array: `!stdSerializers.err` (see example).

  The `serialize` array also applies to any child logger serializers (see https://github.com/pinojs/pino/blob/master/docs/api.md#bindingsserializers-object for how to set child-bound serializers).

  Unlike server pino the serializers apply to every object passed to the logger method, if the `asObject` option is `true`, this results in the serializers applying to the first object (as in server pino).

  For more info on serializers see https://github.com/pinojs/pino/blob/master/docs/api.md#serializers-object.

  #### Example

      const pino = require('pino')({
        browser: {
          serialize: true
        }
      })

  #### Example

      const pino = require('pino')({
        serializers: {
          custom: myCustomSerializer,
          another: anotherSerializer
        },
        browser: {
          serialize: ['custom']
        }
      })
      // following will apply myCustomSerializer to the custom property,
      // but will not apply anotherSerializer to another key
      pino.info({custom: 'a', another: 'b'})

  #### Example

      const pino = require('pino')({
        serializers: {
          custom: myCustomSerializer,
          another: anotherSerializer
        },
        browser: {
          serialize: ['!stdSerializers.err', 'custom'] //will not serialize Errors, will serialize `custom` keys
        }
      })

- ##### `Optional` transmit?: {
  level?: LevelOrString;
  send: ((level: Level, logEvent: LogEvent) => void);
  }

  Options for transmission of logs.

  #### Example

      const pino = require('pino')({
        browser: {
          transmit: {
            level: 'warn',
            send: function (level, logEvent) {
              if (level === 'warn') {
                // maybe send the logEvent to a separate endpoint
                // or maybe analyse the messages further before sending
              }
              // we could also use the `logEvent.level.value` property to determine
              // numerical value
              if (logEvent.level.value >= 50) { // covers error and fatal

                // send the logEvent somewhere
              }
            }
          }
        }
      })

  - ##### `Optional` level?: LevelOrString

    Specifies the minimum level (inclusive) of when the `send` function should be called, if not supplied the `send` function will be called based on the main logging `level` (set via `options.level`, defaulting to `info`).

  - ##### send: ((level: Level, logEvent: LogEvent) => void)

    Remotely record log messages.

    #### Description

    Called after writing the log message.

    - - (level, logEvent): void

      - #### Parameters

        - level: Level
        - logEvent: LogEvent

        #### Returns void

- ##### `Optional` disabled?: boolean

  The disabled option will disable logging in browser if set to true, by default it is set to false.

  #### Example

      const pino = require('pino')({browser: {disabled: true}})

Inherited from LoggerOptions.browser

- Defined in node_modules/pino/pino.d.ts:430

### `Optional` base

base?: {
[key: string]: any;
}

key-value object added as child logger to each log line. If set to null the base child logger is not added

Inherited from LoggerOptions.base

- Defined in node_modules/pino/pino.d.ts:596

### `Optional` formatters

formatters?: {
level?: ((label: string, number: number) => object);
bindings?: ((bindings: Bindings) => object);
log?: ((object: Record<string, unknown>) => Record<string, unknown>);
}

An object containing functions for formatting the shape of the log lines. These functions should return a JSONifiable object and should never throw. These functions allow for full customization of the resulting log lines. For example, they can be used to change the level key name or to enrich the default metadata.

#### Type declaration

- ##### `Optional` level?: ((label: string, number: number) => object)

  Changes the shape of the log level. The default shape is { level: number }. The function takes two arguments, the label of the level (e.g. 'info') and the numeric value (e.g. 30).

  - - (label, number): object

    - #### Parameters

      - label: string
      - number: number

      #### Returns object

- ##### `Optional` bindings?: ((bindings: Bindings) => object)

  Changes the shape of the bindings. The default shape is { pid, hostname }. The function takes a single argument, the bindings object. It will be called every time a child logger is created.

  - - (bindings): object

    - #### Parameters

      - bindings: Bindings

      #### Returns object

- ##### `Optional` log?: ((object: Record<string, unknown>) => Record<string, unknown>)

  Changes the shape of the log object. This function will be called every time one of the log methods (such as .info) is called. All arguments passed to the log method, except the message, will be pass to this function. By default it does not change the shape of the log object.

  - - (object): Record<string, unknown>

    - #### Parameters

      - object: Record<string, unknown>

      #### Returns Record<string, unknown>

Inherited from LoggerOptions.formatters

- Defined in node_modules/pino/pino.d.ts:604

### `Optional` msgPrefix

msgPrefix?: string

A string that would be prefixed to every message (and child message)

Inherited from LoggerOptions.msgPrefix

- Defined in node_modules/pino/pino.d.ts:630

### `Optional` hooks

hooks?: {
logMethod?: ((this: Logger<never, boolean>, args: [msg: string, ...args: any[]], method: LogFn, level: number) => void);
}

An object mapping to hook functions. Hook functions allow for customizing internal logger operations. Hook functions must be synchronous functions.

#### Type declaration

- ##### `Optional` logMethod?: ((this: Logger<never, boolean>, args: [msg: string, ...args: any[]], method: LogFn, level: number) => void)

  Allows for manipulating the parameters passed to logger methods. The signature for this hook is logMethod (args, method, level) {}, where args is an array of the arguments that were passed to the log method and method is the log method itself, and level is the log level. This hook must invoke the method function by using apply, like so: method.apply(this, newArgumentsArray).

  - - (this, args, method, level): void

    - #### Parameters

      - this: Logger<never, boolean>
      - args: [msg: string, ...args: any[]]
      - method: LogFn
      - level: number

      #### Returns void

Inherited from LoggerOptions.hooks

- Defined in node_modules/pino/pino.d.ts:636

### `Optional` depthLimit

depthLimit?: number

Stringification limit at a specific nesting depth when logging circular object. Default: `5`.

Inherited from LoggerOptions.depthLimit

- Defined in node_modules/pino/pino.d.ts:649

### `Optional` edgeLimit

edgeLimit?: number

Stringification limit of properties/elements when logging a specific object/array with circular references. Default: `100`.

Inherited from LoggerOptions.edgeLimit

- Defined in node_modules/pino/pino.d.ts:654

### `Optional` onChild

onChild?: OnChildCallback<CustomLevels>

Optional child creation callback.

Inherited from LoggerOptions.onChild

- Defined in node_modules/pino/pino.d.ts:659

### `Optional` crlf

crlf?: boolean

logs newline delimited JSON with `\r\n` instead of `\n`. Default: `false`.

Inherited from LoggerOptions.crlf

- Defined in node_modules/pino/pino.d.ts:664