Module: GELF::LoggerCompatibility
- Included in:
- Logger
- Defined in:
- lib/gelf/logger.rb
Overview
Methods for compatibility with Ruby Logger.
Instance Attribute Summary (collapse)
-
- (Object) formatter
Returns the value of attribute formatter.
Instance Method Summary (collapse)
- - (Object) <<(message)
-
- (Object) add(level, *args)
Use it like Logger#add...
-
- (Object) close
Does nothing.
Instance Attribute Details
- (Object) formatter
Returns the value of attribute formatter
5 6 7 |
# File 'lib/gelf/logger.rb', line 5 def formatter @formatter end |
Instance Method Details
- (Object) <<(message)
57 58 59 |
# File 'lib/gelf/logger.rb', line 57 def <<() notify_with_level(GELF::UNKNOWN, 'short_message' => ) end |
- (Object) add(level, *args)
Use it like Logger#add... or better not to use at all.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gelf/logger.rb', line 12 def add(level, *args) raise ArgumentError.new('Wrong arguments.') unless (0..2).include?(args.count) # Ruby Logger's author is a maniac. , progname = if args.count == 2 [args[0], args[1]] elsif args.count == 0 [yield, ['facility']] elsif block_given? [yield, args[0]] else [args[0], ['facility']] end if .is_a?(Hash) # Stringify keys. hash = {} .each do |k,v| hash[k.to_s] = [k] end hash['facility'] = progname else hash = {'short_message' => , 'facility' => progname} end hash.merge!(self.class.extract_hash_from_exception()) if .is_a?(Exception) notify_with_level(level, hash) end |
- (Object) close
Does nothing.
8 9 |
# File 'lib/gelf/logger.rb', line 8 def close end |