src/logger.js
function Logger ({
  minimumLogLevel = null,
  formatter = JsonFormatter,
  useBearerRedactor = true,
  useGlobalErrorHandler = true,
  forceGlobalErrorHandler = false,
  redactors = []
} = {}) {
  const context = {
    minimumLogLevel,
    formatter,
    events: new EventEmitter(),
    contextPath: [],
    keys: new Map()
  }
  if (useBearerRedactor) {
    redactors.push(bearerRedactor(context))
  }
  if (useGlobalErrorHandler) {
    registerErrorHandlers(context, forceGlobalErrorHandler)
  }
  context.redact = wrapRedact(context, redactors)

  context.logger = {
    handler: wrapHandler(context),
    setMinimumLogLevel: wrapSetMinimumLogLevel(context),
    events: context.events,
    setKey: wrapSetKey(context),
    ...createLogger(context)
  }

  return context.logger
}
function Logger ({
  minimumLogLevel = null,
  formatter = JsonFormatter,
  useBearerRedactor = true,
  useGlobalErrorHandler = true,
  forceGlobalErrorHandler = false,
  redactors = []
} = {}) {
  const context = {
    minimumLogLevel,
    formatter,
    events: new EventEmitter(),
    contextPath: [],
    keys: new Map()
  }
  if (useBearerRedactor) {
    redactors.push(bearerRedactor(context))
  }
  if (useGlobalErrorHandler) {
    registerErrorHandlers(context, forceGlobalErrorHandler)
  }
  context.redact = wrapRedact(context, redactors)

  context.logger = {
    handler: wrapHandler(context),
    setMinimumLogLevel: wrapSetMinimumLogLevel(context),
    events: context.events,
    setKey: wrapSetKey(context),
    ...createLogger(context)
  }

  return context.logger
}
function Logger ( { minimumLogLevel = null , formatter = JsonFormatter , useBearerRedactor = true , useGlobalErrorHandler = true , forceGlobalErrorHandler = false , redactors = [ ] } = { } ) { const context = { minimumLogLevel , formatter , events : new EventEmitter ( ) , contextPath : [ ] , keys : new Map ( ) } if ( useBearerRedactor ) { redactors . push ( bearerRedactor ( context ) ) } if ( useGlobalErrorHandler ) { registerErrorHandlers ( context , forceGlobalErrorHandler ) } context . redact = wrapRedact ( context , redactors ) context . logger = { handler : wrapHandler ( context ) , setMinimumLogLevel : wrapSetMinimumLogLevel ( context ) , events : context . events , setKey : wrapSetKey ( context ) , ... createLogger ( context ) } return context . logger }
Construct a new logger. Does not require "new".

@param {Object} [{
minimumLogLevel = null,
formatter = JsonFormatter,
useBearerRedactor = true,
useGlobalErrorHandler = true,
redactors = []
}={}] options
@param {Boolean} [null] options.minimumLogLevel hide log entries of lower severity
@param {Formatter} [JsonFormatter] options.formatter thunk that receives the log context, must return a function to handler formatting log messages. Defaults to JsonFormatter
@param {Boolean} [true] options.useBearerRedactor add a Bearer token redactor
@param {Boolean} [true] options.useGlobalErrorHandler setup global handlers for uncaughtException and unhandledRejection. Only one logger per-lambda can use this option.
@param {(string|RegExp|RedactorFunction)[]} [[]] options.redactors array of redactors. A Redactor is a string or regex to globally replace, or a user=supplied function that is invoked during the redaction phase.
@returns {Logger}
Construct a new logger . Does not require new .