Skip to content

Latest commit

 

History

History
297 lines (180 loc) · 13.5 KB

API.md

File metadata and controls

297 lines (180 loc) · 13.5 KB

Table of Contents

ClientLogger

src/client.js:80-86

A logger than can be used in browsers

Parameters

  • config Object we-js-logger config (optional, default {})
  • logger Object? an instance of a bunyan logger to use internally. this is meant to be used by the child method.

ClientConsoleLogger

src/util/client/consoleLogger.js:9-9

Pretty logging to console for client applications

write

src/util/client/consoleLogger.js:16-48

Transport to console

Parameters

  • data Object (optional, default {})

Returns undefined

ClientLogentriesLogger

src/util/client/logentriesLogger.js:10-23

Custom bunyan stream that transports to Logentries from client applications

Parameters

write

src/util/client/logentriesLogger.js:30-37

Transport logs to Logentries

Parameters

  • data Object (optional, default {})

Returns undefined

ClientRollbarLogger

src/util/client/rollbarLogger.js:21-37

Custom rollbar stream that transports to logentries from a browser Wortks with a global Rollbar instance that is already initialized. Note this expects rollbar to be loaded in the head, not via an npm module. See https://rollbar.com/docs/notifier/rollbar.js/#quick-start for details on integrating Rollbar in client apps

Parameters

  • $0 Object
    • $0.token
    • $0.environment
    • $0.codeVersion

write

src/util/client/rollbarLogger.js:44-56

Transport logs to Rollbar

Parameters

  • data Object (optional, default {})

Returns undefined

NodeLogger

src/node.js:68-82

A logger than can be used in node processes

Parameters

  • config Object we-js-logger config (optional, default {})
  • logger Object? an instance of a bunyan logger to use internally. this is meant to be used by the child method.

BUNYAN_CONFIG_FIELDS

src/util/common/config.js:9-14

Config keys that should always be passed to bunyan.createLogger

DEFAULT_ROOT_FIELDS

src/util/common/config.js:22-26

Whitelist of extra config keys that should be passed to bunyan.createLogger to form root logger fields.

BUNYAN_LOGGER_LEVELS

src/util/common/config.js:33-33

Array of bunyan's different log levels. https://github.com/trentm/node-bunyan#levels

DEFAULT_CONFIG

src/util/common/config.js:36-48

assembleConfig

src/util/common/config.js:61-68

Merges config with DEFAULT_CONFIG, and appends passed in streams with pre-configured streams for the runtime.

This is used to configure this library, not bunyan as it has a lot of extra information. See toBunyanConfig below.

Parameters

  • config Object
  • getStreamsForRuntime Function returns appended config.streams

Returns Object runtimeConfig

toBunyanConfig

src/util/common/config.js:79-81

Create a config objct for bunyan from a full we-js-logger config object. Extra keys passed to bunyan.createLogger become root logger fields, pass a custom config.rootFields to control this behavior

Parameters

Returns Object config for bunyan.createLogger

logForLevel

src/util/common/logForLevel.js:10-22

Creates a log method for a particular level

Parameters

Returns Function

logIt

src/util/common/logForLevel.js:19-21

Log at a level. Must be bound to a logger instance.

Parameters

  • args any

Returns undefined

ServerRollbarLogger

src/util/server/rollbarLogger.js:12-21

Custom bunyan stream that transports to Rollbar from a node process. See https://rollbar.com/docs/notifier/node_rollbar/ for integration details

Parameters

  • token Object , codeVersion, and environment
    • token.token
    • token.codeVersion
    • token.environment

write

src/util/server/rollbarLogger.js:31-44

handles err and req properties, attaches any custom data, and calls the appropriate Rollbar method.

Parameters

  • data Object (optional, default {})

Returns undefined

bunyanToRollbarLevelMap

src/util/common/rollbar.js:11-18

Map of bunyan log levels to Rollbar levels https://github.com/trentm/node-bunyan#levels https://rollbar.com/docs/notifier/rollbar.js/api/#rollbardebuginfowarnwarningerrorcritical

bunyanLevelToRollbarLevelName

src/util/common/rollbar.js:25-28

Convert bunyan log level to rollbar level. Defaults to 'error'.

Parameters

  • level String bunyan log level (optional, default bunyan.ERROR)

Returns String Rollbar log level

ServerLogentriesLogger

src/util/server/logentriesLogger.js:10-20

Custom bunyan stream that transports to logentries from a node process

Parameters

Returns Object bunyan stream config

createRequestLogger

src/util/server/requestLogger.js:12-48

Create a request loging express middleware

Parameters

  • logger Object a logger instance
  • options Object (optional, default {})
    • options.reqIdHeader String? (optional, default DEFAULT_HEADER_NAME)

Returns Function

requestLoggerMiddleware

src/util/server/requestLogger.js:24-47

Request Logger Middleware Adds base logging to every request Attaches a log child to each request object

Parameters

Returns undefined