Class: Timmy::Logger
- Inherits:
-
Object
- Object
- Timmy::Logger
- Defined in:
- lib/timmy/logger.rb
Class Method Summary collapse
- .finalize ⇒ Object
- .put_output(output) ⇒ Object
- .put_stopped_profiles ⇒ Object
- .put_timer(timer) ⇒ Object
- .set_output_directory(dir) ⇒ Object
- .set_precision(precision) ⇒ Object
Class Method Details
.finalize ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/timmy/logger.rb', line 41 def finalize suffix = "#{MasterTimer.start.to_i}+#{MasterTimer.get.to_i}" filename = File.join(output_directory, "timmy-#{suffix}.log") File.write(filename, @output) puts feint("Log written to #{filename}") puts end |
.put_output(output) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/timmy/logger.rb', line 12 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_stopped_profiles ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/timmy/logger.rb', line 26 def put_stopped_profiles puts "Slowest targeted timers:" slowest_timers = TargetedTimerManager .stopped .sort_by { |timer| -timer.duration } .slice(0, 10) slowest_timers.each do |timer| put_timer(timer) end puts end |
.put_timer(timer) ⇒ Object
22 23 24 |
# File 'lib/timmy/logger.rb', line 22 def put_timer(timer) puts format_timer(timer) end |
.set_output_directory(dir) ⇒ Object
4 5 6 |
# File 'lib/timmy/logger.rb', line 4 def set_output_directory(dir) @output_directory = dir end |
.set_precision(precision) ⇒ Object
8 9 10 |
# File 'lib/timmy/logger.rb', line 8 def set_precision(precision) @precision = precision end |