Module: Mammoth::Logging

Defined in:
lib/mammoth/logging.rb

Overview

Container-friendly structured application logging.

Defined Under Namespace

Classes: Logger, NullLogger

Constant Summary collapse

LEVELS =

Supported severity names mapped to their filtering priority.

{ "debug" => 0, "info" => 1, "warn" => 2, "error" => 3 }.freeze

Class Method Summary collapse

Class Method Details

.build(config, output: $stdout, clock: -> { Time.now.utc }) ⇒ Mammoth::Logging::Logger

Build the configured structured logger.

Parameters:

  • config (Mammoth::Configuration, Hash)

    loaded Mammoth configuration

  • output (IO) (defaults to: $stdout)

    destination for newline-delimited JSON

  • clock (#call) (defaults to: -> { Time.now.utc })

    UTC-compatible time source

Returns:



103
104
105
# File 'lib/mammoth/logging.rb', line 103

def build(config, output: $stdout, clock: -> { Time.now.utc })
  Logger.new(level: config.dig("logging", "level") || "info", output:, clock:)
end