Class: Timmy::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/timmy/logger.rb

Class Method Summary collapse

Class Method Details

.finalizeObject



52
53
54
55
# File 'lib/timmy/logger.rb', line 52

def finalize
  save
  put_profile if profile?
end

.match_replay_header(line) ⇒ Object



20
21
22
# File 'lib/timmy/logger.rb', line 20

def match_replay_header(line)
  line.match(/^TIMMY-SESSION:v1:(?<s>\d+\.\d{9})$/)
end

.match_replay_line(line) ⇒ Object



24
25
26
# File 'lib/timmy/logger.rb', line 24

def match_replay_line(line)
  line.match(/^(?<s>\d+(\.\d+)?)(?<t>e)? (?<content>.*)/)
end

.put_eofObject



44
45
46
# File 'lib/timmy/logger.rb', line 44

def put_eof
  put_output(feint("EOF")) unless @quiet
end

.put_output(output, error = false) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/timmy/logger.rb', line 28

def put_output(output, error = false)
  duration = MasterTimer.get

  if @quiet
    puts output
  else
    formatted_duration = format_duration(duration)
    formatted_duration = red(formatted_duration) if error
    puts "\e[0m" + feint(formatted_duration) + " " + output
  end
  $stdout.flush

  @output ||= ''
  @output += sprintf("%.9f%s %s\n", duration, error ? 'e' : '', output)
end

.put_timer(timer) ⇒ Object



48
49
50
# File 'lib/timmy/logger.rb', line 48

def put_timer(timer)
  do_put_timer(timer) unless @quiet
end

.set_output_dir(dir) ⇒ Object



4
5
6
# File 'lib/timmy/logger.rb', line 4

def set_output_dir(dir)
  @output_dir = File.expand_path(dir)
end

.set_precision(precision) ⇒ Object



12
13
14
# File 'lib/timmy/logger.rb', line 12

def set_precision(precision)
  @precision = precision
end

.set_profile(profile) ⇒ Object



16
17
18
# File 'lib/timmy/logger.rb', line 16

def set_profile(profile)
  @profile = profile
end

.set_quiet(quiet) ⇒ Object



8
9
10
# File 'lib/timmy/logger.rb', line 8

def set_quiet(quiet)
  @quiet = quiet
end