Module: CleanSweep::PurgeRunner::Logging
- Included in:
- CleanSweep::PurgeRunner
- Defined in:
- lib/clean_sweep/purge_runner/logging.rb
Instance Method Summary collapse
Instance Method Details
#log(level, msg) ⇒ Object
13 14 15 16 17 |
# File 'lib/clean_sweep/purge_runner/logging.rb', line 13 def log level, msg prefix = level == :debug ? " *** " : " ** " out = msg.split("\n").map {|line| prefix + line}.join("\n") @logger.send level, out end |
#print_queries ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/clean_sweep/purge_runner/logging.rb', line 19 def print_queries io = StringIO.new io.puts 'Initial Query:' io.puts format_query(' ', @query.to_sql) io.puts "Chunk Query:" io.puts format_query(' ', @table_schema.scope_to_next_chunk(@query, sample_rows.first).to_sql) if copy_mode? io.puts "Insert Statement:" io.puts format_query(' ', @table_schema.insert_statement(sample_rows)) else io.puts "Delete Statement:" io.puts format_query(' ', @table_schema.delete_statement(sample_rows)) end io.string end |
#report(force = false) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/clean_sweep/purge_runner/logging.rb', line 3 def report(force=false) report_duration = Time.now - @report_interval_start if (force || report_duration >= @report_interval) while (@report_interval > 0 && @report_interval_start < Time.now - @report_interval) do @report_interval_start += @report_interval end print_report end end |