Sha256: 2892af11e8d6f0d88bb250de2194bfd718f2a929f2f030ffbbd53f51a5272ad6

Contents?: true

Size: 799 Bytes

Versions: 51

Compression:

Stored size: 799 Bytes

Contents

require 'logger'

module Riemann
  module Babbler

    module Logging

      @levels  = { 'DEBUG' => 0, 'INFO' => 1, 'WARN' => 2, 'ERROR' => 3, 'FATAL' => 4 }
      @@logger = Logger.new(STDOUT) #todo: opts

      def log(log_level, message, method = nil)
        speaker = get_logger_speaker
        speaker = speaker + "##{method}" unless method.nil?
        @@logger.send(log_level.to_sym, " [#{speaker}] #{message}")
      end

      def set_logger_speaker(speaker)
        @logger_speaker = speaker
      end

      def get_logger_speaker
        if @logger_speaker.nil?
          self.class == Class ? "C: #{self.to_s}" : "I: #{self.class.to_s}"
        else
          @logger_speaker
        end
      end

      def self.included(base)
        base.extend(self)
      end

    end

  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
riemann-babbler-2.8.5 lib/riemann/babbler/logging.rb
riemann-babbler-2.8.4 lib/riemann/babbler/logging.rb
riemann-babbler-2.8.3 lib/riemann/babbler/logging.rb
riemann-babbler-2.8.2 lib/riemann/babbler/logging.rb
riemann-babbler-2.8.1 lib/riemann/babbler/logging.rb
riemann-babbler-2.8.0 lib/riemann/babbler/logging.rb
riemann-babbler-2.6.0 lib/riemann/babbler/logging.rb
riemann-babbler-2.5.9 lib/riemann/babbler/logging.rb
riemann-babbler-2.5.8 lib/riemann/babbler/logging.rb
riemann-babbler-2.5.7 lib/riemann/babbler/logging.rb
riemann-babbler-2.5.6 lib/riemann/babbler/logging.rb
riemann-babbler-2.5.5 lib/riemann/babbler/logging.rb
riemann-babbler-2.5.4 lib/riemann/babbler/logging.rb
riemann-babbler-2.5.3 lib/riemann/babbler/logging.rb
riemann-babbler-2.5.2 lib/riemann/babbler/logging.rb
riemann-babbler-2.5.1 lib/riemann/babbler/logging.rb
riemann-babbler-2.5.0 lib/riemann/babbler/logging.rb
riemann-babbler-2.1.5 lib/riemann/babbler/logging.rb
riemann-babbler-2.1.4 lib/riemann/babbler/logging.rb
riemann-babbler-2.1.3.2 lib/riemann/babbler/logging.rb