summaryrefslogtreecommitdiff
path: root/lib/leap_cli/log.rb
blob: a9676deef493d0090daccd18df5eda6249d30f02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
module LeapCli
  extend self

  def log_level
    @log_level
  end

  def log_level=(value)
    @log_level = value
  end
end

##
## LOGGING
##

def log0(message=nil, &block)
  if message
    puts message
  elsif block
    puts yield(block)
  end
end

def log1(message=nil, &block)
  if LeapCli.log_level > 0
    if message
      puts message
    elsif block
      puts yield(block)
    end
  end
end

def log2(message=nil, &block)
  if LeapCli.log_level > 1
    if message
      puts message
    elsif block
      puts yield(block)
    end
  end
end

def progress(message)
  log1("  = " + message)
end

def progress2(message)
  log2("  = " + message)
end