Module: SK::Trace

Extended by:
Trace
Included in:
Trace
Defined in:
lib/trace.rb

Constant Summary collapse

DEBUG =
3
WARN =
2
ERROR =
1
QUIET =
0

Instance Method Summary collapse

Instance Method Details

#debug(s) ⇒ Object



37
38
39
# File 'lib/trace.rb', line 37

def debug(s)
  write "SK::Debug : #{s}".cyan, DEBUG
end

#error(s) ⇒ Object



40
41
42
# File 'lib/trace.rb', line 40

def error(s)
  write "SK::Error: #{s}".red, ERROR
end

#levelObject



30
31
32
# File 'lib/trace.rb', line 30

def level
  @level
end

#level=(value) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/trace.rb', line 14

def level=(value)
  case value
  when :debug
    n = DEBUG
  when :warn
    n = WARN
  when :error
    n = ERROR
  when :quiet
    n = QUIET
  else
    n = value.to_i
  end
  @level = n
end

#notice(s) ⇒ Object



43
44
45
# File 'lib/trace.rb', line 43

def notice(s)
  write "SK::Notice: #{s}".yellow, WARN
end

#trace(s) ⇒ Object



34
35
36
# File 'lib/trace.rb', line 34

def trace(s)
  write "SK::Trace : #{s}".cyan, DEBUG
end

#warn(s) ⇒ Object



46
47
48
# File 'lib/trace.rb', line 46

def warn(s)
  write "SK::Warn  : #{s}".yellow, WARN
end

#write(text, lev) ⇒ Object



50
51
52
# File 'lib/trace.rb', line 50

def write(text,lev)
  puts text if level >= lev
end