Sha256: cfdad1841a78a690786b879e55e952fc813141d52a60ef75b74be2d5dfa339e2
Contents?: true
Size: 1.76 KB
Versions: 1
Compression:
Stored size: 1.76 KB
Contents
module GELF # Methods for compatibility with Ruby Logger. module LoggerCompatibility # Does nothing. def close end # Use it like Logger#add… or better not to use at all. def add(level, *args) raise ArgumentError.new('Wrong arguments.') unless (0..2).include?(args.count) # Ruby Logger's author is a maniac. message, facility = if args.count == 2 [args[0], args[1]] elsif args.count == 0 [yield, nil] elsif block_given? [yield, args[0]] else [args[0], nil] end hash = {'_short_message' => message, '_facility' => facility} hash.merge!(self.class.extract_hash_from_exception(message)) if message.is_a?(Exception) notify_with_level(level, hash) end GELF::Levels.constants.each do |const| class_eval <<-EOT, __FILE__, __LINE__ + 1 def #{const.downcase}(*args) # def debug(*args) args.unshift(yield) if block_given? # args.unshift(yield) if block_given? add(GELF::#{const}, *args) # add(GELF::DEBUG, *args) end # end def #{const.downcase}? # def debug? GELF::#{const} >= level # GELF::DEBUG >= level end # end EOT end def <<(message) notify('_short_message' => message, '_level' => GELF::UNKNOWN) end end # Graylog2 notifier, compatible with Ruby Logger. class Logger < Notifier include LoggerCompatibility @last_chunk_id = 0 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gelf-1.1.0.beta6 | lib/gelf/logger.rb |