Sha256: 4d6da7b4aaf229b2b69f1d904e6fe8de7f670be52bde300e88b8332e797295d2

Contents?: true

Size: 482 Bytes

Versions: 6

Compression:

Stored size: 482 Bytes

Contents

class Logasm
  module Adapters
    class StdoutAdapter
      attr_reader :logger

      def initialize(level, *)
        @logger = Logger.new(STDOUT)
        @logger.level = level
      end

      def log(level, metadata = {})
        message = metadata[:message]
        data = metadata.select { |key, value| key != :message }
        log_data = [message, data.empty? ? nil : data.to_json].compact.join(' ')

        @logger.public_send level, log_data
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
logasm-0.2.5 lib/logasm/adapters/stdout_adapter.rb
logasm-0.2.4 lib/logasm/adapters/stdout_adapter.rb
logasm-0.2.3 lib/logasm/adapters/stdout_adapter.rb
logasm-0.2.2 lib/logasm/adapters/stdout_adapter.rb
logasm-0.2.1 lib/logasm/adapters/stdout_adapter.rb
logasm-0.2.0 lib/logasm/adapters/stdout_adapter.rb