class LittleMonster::Core::TaggedLogger
Constants
- LEVELS
Attributes
parent_logger[RW]
Public Class Methods
new()
click to toggle source
# File lib/little_monster/core/tagged_logger.rb, line 12 def initialize @tags = Hash.new({}) @parent_logger = nil end
Public Instance Methods
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/little_monster/core/tagged_logger.rb, line 17 def method_missing(method, *args, &block) if method.to_s.ends_with? 'tags=' tag_key = method.to_s.split('_').first.to_sym return public_send('tags_for', tag_key, *args) if LEVELS.include? tag_key end if method.to_s.ends_with? 'tags' tag_key = method.to_s.split('_').first.to_sym return @tags[tag_key] if LEVELS.include? tag_key end if LEVELS.include? method.to_sym return LittleMonster.logger.public_send method, tag_message(method.to_sym, *args) end super method, *args, &block end
tag_message(level, message = '')
click to toggle source
# File lib/little_monster/core/tagged_logger.rb, line 47 def tag_message(level, message = '') prefix_string = tags_to_string @tags[:default].merge(@tags[level]) prefix_string << ' -- ' unless prefix_string.blank? unless @parent_logger.nil? prefix_string = @parent_logger.tag_message level, prefix_string end [prefix_string, message].join end