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.1.3.1 lib/riemann/babbler/logging.rb
riemann-babbler-2.1.3 lib/riemann/babbler/logging.rb
riemann-babbler-2.1.2 lib/riemann/babbler/logging.rb
riemann-babbler-2.1.1 lib/riemann/babbler/logging.rb
riemann-babbler-2.1.0 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.9 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.8 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.7 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.6.1 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.6 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.5 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.4 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.3.2 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.3.1 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.3 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.2 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.1 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.0 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.0pre15 lib/riemann/babbler/logging.rb
riemann-babbler-2.0.0pre13 lib/riemann/babbler/logging.rb