summaryrefslogtreecommitdiff
path: root/lib/leap_cli/log.rb
blob: ac35eaeebbefc3b970fa27237ac0bb4a47a757ee (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
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