Class: Timmy::Logger

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

Class Method Summary collapse

Class Method Details

.finalizeObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/timmy/logger.rb', line 34

def finalize
  suffix = "#{MasterTimer.start.to_i}+#{MasterTimer.get.to_i}"
  filename = File.join(output_dir, "timmy-#{suffix}.log")
  header = sprintf("TIMMY-SESSION:v1:%.9f\n", MasterTimer.start)

  File.write(filename, header + @output)

  puts feint("Log written to #{filename}")
  puts

  put_profile if profile?
end

.put_eofObject



26
27
28
# File 'lib/timmy/logger.rb', line 26

def put_eof
  put_output(feint("EOF"))
end

.put_output(output) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/timmy/logger.rb', line 16

def put_output(output)
  duration = MasterTimer.get
  formatted_duration = format_duration(duration)

  puts feint(formatted_duration) + " " + output

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

.put_timer(timer) ⇒ Object



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

def put_timer(timer)
  puts format_timer(timer)
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



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

def set_precision(precision)
  @precision = precision
end

.set_profile(profile) ⇒ Object



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

def set_profile(profile)
  @profile = profile
end