lib/envoy/utils.rb in envoy-proxy-1.0.0 vs lib/envoy/utils.rb in envoy-proxy-1.0.1
- old
+ new
@@ -7,19 +7,24 @@
ERROR = 1
FATAL = 0
VERBOSITIES = "FEWIDT"
- class << self
- attr_accessor :verbosity
+ def self.verbosity
+ @verbosity
end
+ def self.verbosity= (num)
+ @verbosity = [0, [5, num].min].max
+ end
+
def self.log (level, text, io = STDERR)
return unless io
+ level = Envoy.const_get(level.upcase) unless level.is_a?(Numeric)
return unless level <= verbosity
message = [
Time.now.strftime("%F %T"),
- VERBOSITIES[level][0],
+ VERBOSITIES[level],
text
].compact.join(" ")
io.puts message
io.flush
end