Module: Ark::Log

Defined in:
lib/ark/utility.rb

Overview

Logging/messaging facilities intended for STDOUT

Constant Summary collapse

Conf =

Configuration details for Ark::Log. Settings:

:quiet

Suppress all messages of any verbosity

:verbose

Allow high-verbosity messages to be printed

:timed

Include the time since Timer#reset was called in all messages

{}

Instance Method Summary collapse

Instance Method Details

#dbg(str, indent = 0) ⇒ Object

Write high-verbosity debugging information to STDOUT



77
78
79
# File 'lib/ark/utility.rb', line 77

def dbg(str, indent=0)
  say(str, '...', true, indent)
end

#msg(str, indent = 0) ⇒ Object

Write a low-verbosity message to STDOUT



73
74
75
# File 'lib/ark/utility.rb', line 73

def msg(str, indent=0)
  say(str, '>>>', false, indent)
end

#pulse(str, time, &block) ⇒ Object

Pulse a message for the duration of the execution of a block



86
87
88
# File 'lib/ark/utility.rb', line 86

def pulse(str, time, &block)
  # TODO
end

#say(msg, sym = '...', loud = false, indent = 0) ⇒ Object

Write msg to standard output according to verbosity settings. Not meant to be used directly



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ark/utility.rb', line 56

def say(msg, sym='...', loud=false, indent=0)
  return false if Conf[:quiet]
  return false if loud && !Conf[:verbose]
  unless msg == ''
    time = ""
    if Conf[:timed]
      time = Timer.time.to_s.ljust(4, '0')
      time = time + " "
    end
    indent = "    " * indent
    indent = " " if indent == ""
    puts "#{time}#{sym}#{indent}#{msg}"
  else
    puts
  end
end

#wrn(str, indent = 0) ⇒ Object

Write a high-verbosity warning to STDOUT



81
82
83
# File 'lib/ark/utility.rb', line 81

def wrn(str, indent=0)
  say(str, '???', true, indent)
end