Sha256: 3f74002e98b268f4c141e6eb18cc8bd7d89df6cae190ae0f89805d852df04cf5
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
module PerconaMigrator # 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. class Logger def initialize(sanitizers) @sanitizers = sanitizers end # 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 def say(message, subitem = false) write "#{subitem ? " ->" : "--"} #{message}" end # Outputs the text through the stdout adding a new line at the end # # @param text [String] def write(text = '') puts(sanitize(text)) end # Outputs the text through the stdout without adding a new line at the end # # @param text [String] def write_no_newline(text) print(sanitize(text)) end private attr_accessor :sanitizers def sanitize(text) sanitizers.inject(text) { |memo, sanitizer| sanitizer.execute(memo) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
percona_migrator-3.0.0 | lib/percona_migrator/logger.rb |
percona_migrator-1.1.0 | lib/percona_migrator/logger.rb |