Sha256: 72b8ea987faff79af8d3ab59abb98ff6457c47c24c8e18a16b138bf7eb14a38f

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

# frozen_string_literal: true

module Trifle
  module Logs
    module Operations
      class Dump
        attr_reader :namespace, :payload, :scope

        def initialize(**keywords)
          @namespace = keywords.fetch(:namespace)
          @payload = keywords.fetch(:payload)
          @scope = keywords.fetch(:scope)
          @config = keywords[:config]
        end

        def config
          @config || Trifle::Logs.default
        end

        def formatted
          [
            config.timestamp_formatter.format(Time.now),
            config.content_formatter.format(scope, payload)
          ].join(' ')
        end

        def perform
          config.driver.dump(
            formatted, namespace: namespace
          )
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trifle-logs-0.2.1 lib/trifle/logs/operations/dump.rb
trifle-logs-0.2.0 lib/trifle/logs/operations/dump.rb
trifle-logs-0.1.0 lib/trifle/logs/operations/dump.rb