class PerconaMigrator::Logger
Copies the ActiveRecord::Migration say
and write
plus a new write_no_newline
to log the migration's status. It's not possible to reuse the from ActiveRecord::Migration because the migration's instance can't be seen from the connection adapter.
Attributes
sanitizers[RW]
Public Class Methods
new(sanitizers)
click to toggle source
# File lib/percona_migrator/logger.rb, line 8 def initialize(sanitizers) @sanitizers = sanitizers end
Public Instance Methods
say(message, subitem = false)
click to toggle source
Outputs the message through the stdout, following the ActiveRecord::Migration log format
@param message [String] @param subitem [Boolean] whether to show message as a nested log item
# File lib/percona_migrator/logger.rb, line 17 def say(message, subitem = false) write "#{subitem ? " ->" : "--"} #{message}" end
write(text = '')
click to toggle source
Outputs the text through the stdout adding a new line at the end
@param text [String]
# File lib/percona_migrator/logger.rb, line 24 def write(text = '') puts(sanitize(text)) end
write_no_newline(text)
click to toggle source
Outputs the text through the stdout without adding a new line at the end
@param text [String]
# File lib/percona_migrator/logger.rb, line 31 def write_no_newline(text) print(sanitize(text)) end
Private Instance Methods
sanitize(text)
click to toggle source
# File lib/percona_migrator/logger.rb, line 39 def sanitize(text) sanitizers.inject(text) { |memo, sanitizer| sanitizer.execute(memo) } end