Module: GELF::LoggerCompatibility
- Included in:
- Logger
- Defined in:
- lib/gelf/logger.rb
Overview
Methods for compatibility with Ruby Logger.
Instance Attribute Summary collapse
-
#formatter ⇒ Object
Returns the value of attribute formatter.
Instance Method Summary collapse
- #<<(message) ⇒ Object
-
#add(level, message = nil, progname = nil, &block) ⇒ Object
Use it like Logger#add…
Instance Attribute Details
#formatter ⇒ Object
Returns the value of attribute formatter.
5 6 7 |
# File 'lib/gelf/logger.rb', line 5 def formatter @formatter end |
Instance Method Details
#<<(message) ⇒ Object
52 53 54 |
# File 'lib/gelf/logger.rb', line 52 def <<() notify_with_level(GELF::UNKNOWN, 'short_message' => ) end |
#add(level, message = nil, progname = nil, &block) ⇒ Object
Use it like Logger#add… or better not to use at all.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gelf/logger.rb', line 8 def add(level, = nil, progname = nil, &block) progname ||= ['facility'] ||= block.call unless block.nil? if .nil? = progname progname = ['facility'] end = {} ['facility'] = progname if progname if .is_a?(Hash) .each do |key, value| [key.to_s] = value.to_s end else ['short_message'] = .to_s end if .is_a?(Exception) .merge!(self.class.extract_hash_from_exception()) end if .key?('short_message') && !['short_message'].empty? notify_with_level(level, ) end end |