Module: Envoy

Defined in:
lib/envoy/utils.rb,
lib/envoy/version.rb,
lib/envoy/protocol.rb,
lib/envoy/server/web.rb,
lib/envoy/client/trunk.rb,
lib/envoy/server/trunk.rb,
lib/envoy/client/channel.rb,
lib/envoy/server/channel.rb

Defined Under Namespace

Modules: Client, Protocol, Server

Constant Summary collapse

TRACE =
5
DEBUG =
4
INFO =
3
WARN =
2
ERROR =
1
FATAL =
0
VERBOSITIES =
"FEWIDT"
VERSION =
'1.0.1'

Class Method Summary collapse

Class Method Details

.find_file(name) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/envoy/utils.rb', line 33

def self.find_file (name)
  dirs = Dir.pwd.split("/")
  r = dirs.reduce([]) do |m, x|
    [[*m[0], x], *m]
  end.map do |p|
    p.join("/") + "/#{name}"
  end.each do |p|
    return p if File.exist?(p)
  end
  false
end

.log(level, text, io = STDERR) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/envoy/utils.rb', line 20

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],
    text
  ].compact.join(" ")
  io.puts message
  io.flush
end

.verbosityObject



12
13
14
# File 'lib/envoy/utils.rb', line 12

def self.verbosity
  @verbosity
end

.verbosity=(num) ⇒ Object



16
17
18
# File 'lib/envoy/utils.rb', line 16

def self.verbosity= (num)
  @verbosity = [0, [5, num].min].max
end