Home Reference Source

Function

Static Public Summary
public

WinstonFormatter(objectPattern: {"message": *, "level": *, "meta": *, "timestamp": *}): *

public

attach(transports: Array, toStream: Writable, options: Object): {"detach": *}

Attaches a transport stream to a writeable stream.

public

expressMiddleware(options: object): *

The express middleware takes care of automatically logging each http event with the appropriate context events attached.

public

install(transport: Stream)

Installs the timber logger to route all stdout logs to the provided stream

public

log(args: ...*): *

public

stripMetadata(log: *)

Static Public

public WinstonFormatter(objectPattern: {"message": *, "level": *, "meta": *, "timestamp": *}): * source

import WinstonFormatter from 'timber/src/formatters/winston.js'

Params:

NameTypeAttributeDescription
objectPattern {"message": *, "level": *, "meta": *, "timestamp": *}
  • default: {"message":null,"level":null,"meta":null,"timestamp":null}

Return:

*

public attach(transports: Array, toStream: Writable, options: Object): {"detach": *} source

import attach from 'timber/src/utils/attach.js'

Attaches a transport stream to a writeable stream.

Params:

NameTypeAttributeDescription
transports Array

array of transports to attach to the stream

toStream Writable

the stream your transport will attach to

options Object

configuration options

options.applyBackPressure boolean

Return:

{"detach": *}

public expressMiddleware(options: object): * source

import expressMiddleware from 'timber/src/middlewares/express.js'

The express middleware takes care of automatically logging each http event with the appropriate context events attached.

This middleware is composed of three separate middlewares:

  • addRequestId automatically attaches a unique uuid to every request
  • bodyParser allows parsing of JSON encoded request bodies
  • expressMiddleware automatically logs http events to timber

Params:

NameTypeAttributeDescription
options object
  • optional

An object with configuration options

options.logger object
  • optional

A custom logger to log http events to (usually either: console, winston, or bunyan)

options.capture_request_body boolean
  • optional

Whether the http request body data will be captured (off by default)

options.combine_http_events boolean
  • optional

If true, HTTPRequest and HTTPResponse events will be combined in a single log message (off by defaut)

Return:

*

public install(transport: Stream) source

import install from 'timber/src/install.js'

Installs the timber logger to route all stdout logs to the provided stream

Params:

NameTypeAttributeDescription
transport Stream

the stream that all logs will go through

public log(args: ...*): * source

import log from 'timber/src/log.js'

Params:

NameTypeAttributeDescription
args ...*

Return:

*

public stripMetadata(log: *) source

import {stripMetadata} from 'timber/src/utils/metadata.js'

Params:

NameTypeAttributeDescription
log *