Class: ArtDecomp::Logging

Inherits:
Object
  • Object
show all
Defined in:
lib/art-decomp/logging.rb

Class Method Summary collapse

Class Method Details

.levelObject



10
11
12
# File 'lib/art-decomp/logging.rb', line 10

def level
  @log.level
end

.level=(level) ⇒ Object



14
15
16
# File 'lib/art-decomp/logging.rb', line 14

def level= level
  @log.level = level
end

.log=(log) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/art-decomp/logging.rb', line 18

def log= log
  @start = Time.now
  @log = Logger.new log
  @log.level = Logger::INFO
  @log.formatter = proc do |sev, date, name, msg|
    secs = (Time.now - @start).ceil
    time = "#{secs / 60 / 60}h#{(secs / 60 % 60).to_s.rjust 2}m#{(secs % 60).to_s.rjust 2}s"
    best = @best.nil? ? '' : @best.to_s + 'c'
    path = @path.nil? ? '' : '/' + @path
    "#{time.rjust 10} #{best.rjust 4}  ยท#{path.ljust 10} #{msg}\n"
  end
  add_logging
end

.offObject



32
33
34
35
# File 'lib/art-decomp/logging.rb', line 32

def off
  # FIXME: if methods can be uncaptured, do that and close @log
  @log = Logger.new '/dev/null'
end