Sha256: 7789ea21545aa856eaa47b0e681a6ae01e15be39c9164002668b4aaed2bb2666

Contents?: true

Size: 845 Bytes

Versions: 37

Compression:

Stored size: 845 Bytes

Contents

module Consul
  module Async
    class Debug
      def self.level
        @level || 2
      end

      def self.levels
        %w[none error info debug]
      end

      def self.level=(log_level)
        lvl = levels.index(log_level)
        raise "Log level #{log_level} unsupported, must be one of #{levels.inspect}" if lvl.nil?
        @level = lvl
      end

      def self.puts_error(msg)
        STDERR.puts "[ERROR] #{msg}" if level.positive?
      end

      def self.puts_info(msg)
        STDERR.puts "[INFO] #{msg}" if level > 1
      end

      def self.print_info(msg)
        STDERR.print "[INFO] #{msg}" if level > 1
      end

      def self.puts_debug(msg)
        STDERR.puts "[DEBG] #{msg}" if level > 2
      end

      def self.print_debug(msg)
        STDERR.print "[DEBG] #{msg}" if level > 2
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
consul-templaterb-1.23.0 lib/consul/async/debug.rb
consul-templaterb-1.22.0 lib/consul/async/debug.rb
consul-templaterb-1.21.8 lib/consul/async/debug.rb
consul-templaterb-1.21.7 lib/consul/async/debug.rb
consul-templaterb-1.21.6 lib/consul/async/debug.rb
consul-templaterb-1.21.5 lib/consul/async/debug.rb
consul-templaterb-1.21.4 lib/consul/async/debug.rb
consul-templaterb-1.21.3 lib/consul/async/debug.rb
consul-templaterb-1.21.2 lib/consul/async/debug.rb
consul-templaterb-1.21.1 lib/consul/async/debug.rb
consul-templaterb-1.21.0 lib/consul/async/debug.rb
consul-templaterb-1.20.0 lib/consul/async/debug.rb
consul-templaterb-1.19.0 lib/consul/async/debug.rb
consul-templaterb-1.18.5 lib/consul/async/debug.rb
consul-templaterb-1.18.4 lib/consul/async/debug.rb
consul-templaterb-1.18.3 lib/consul/async/debug.rb
consul-templaterb-1.18.2 lib/consul/async/debug.rb
consul-templaterb-1.18.1 lib/consul/async/debug.rb
consul-templaterb-1.18.0 lib/consul/async/debug.rb
consul-templaterb-1.17.4 lib/consul/async/debug.rb