Class: PerconaMigrator::Logger
- Inherits:
-
Object
- Object
- PerconaMigrator::Logger
- Defined in:
- lib/percona_migrator/logger.rb
Overview
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.
Instance Method Summary collapse
-
#initialize(sanitizers) ⇒ Logger
constructor
A new instance of Logger.
-
#say(message, subitem = false) ⇒ Object
Outputs the message through the stdout, following the ActiveRecord::Migration log format.
-
#write(text = '') ⇒ Object
Outputs the text through the stdout adding a new line at the end.
-
#write_no_newline(text) ⇒ Object
Outputs the text through the stdout without adding a new line at the end.
Constructor Details
#initialize(sanitizers) ⇒ Logger
Returns a new instance of Logger.
8 9 10 |
# File 'lib/percona_migrator/logger.rb', line 8 def initialize(sanitizers) @sanitizers = sanitizers end |
Instance Method Details
#say(message, subitem = false) ⇒ Object
Outputs the message through the stdout, following the ActiveRecord::Migration log format
17 18 19 |
# File 'lib/percona_migrator/logger.rb', line 17 def say(, subitem = false) write "#{subitem ? " ->" : "--"} #{}" end |
#write(text = '') ⇒ Object
Outputs the text through the stdout adding a new line at the end
24 25 26 |
# File 'lib/percona_migrator/logger.rb', line 24 def write(text = '') puts(sanitize(text)) end |
#write_no_newline(text) ⇒ Object
Outputs the text through the stdout without adding a new line at the end
31 32 33 |
# File 'lib/percona_migrator/logger.rb', line 31 def write_no_newline(text) print(sanitize(text)) end |