Sha256: 25a719b7db7690c4a9d75d4075e33b4633366498659c5060fa523f18cc3b8867
Contents?: true
Size: 951 Bytes
Versions: 21
Compression:
Stored size: 951 Bytes
Contents
require 'logger' module Madvertise module Logging ## # DocumentLogger is a Logger compliant class that keeps a structured # document per log message in memory. # class DocumentLogger < ::Logger attr_accessor :attrs attr_accessor :messages def initialize super(nil) @messages = [] @attrs = {} end def add(severity, message = nil, progname = nil, &block) severity ||= UNKNOWN if severity < @level return true end progname ||= @progname if message.nil? if block_given? message = yield else message = progname progname = @progname end end @messages << @attrs.merge({ severity: severity, time: Time.now.to_f, progname: progname, message: message, }) true end end end end
Version data entries
21 entries across 21 versions & 1 rubygems