Sha256: 46ebaac4eb11b2a23a27fc9fd9d5db5f0e3ae6addf5e76b42470883a81947374

Contents?: true

Size: 409 Bytes

Versions: 13

Compression:

Stored size: 409 Bytes

Contents

# Wraps another logger and tags output.
class LogTagger
  LOGGER_METHODS = [:debug, :error, :fatal, :info, :unknown, :warn]
  
  attr_accessor :tag, :logger
  
  def initialize(tag, logger)
    self.tag = tag
    self.logger = logger
  end
  
  def method_missing(method, *args)
    if LOGGER_METHODS.include?(method)
      logger.send(method, "[#{tag}] #{args.first}")
    else
      super
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ucb_rails-0.0.14 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.13 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.12 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.11 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.10 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.9 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.8 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.7 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.6 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.5 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.4 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.3 lib/ucb_rails/log_tagger.rb
ucb_rails-0.0.2 lib/ucb_rails/log_tagger.rb