Sha256: 5854267c25c52560287ab7d8da620d57fc2603f49baed4dc1ccf9b3d64df01e0

Contents?: true

Size: 949 Bytes

Versions: 2

Compression:

Stored size: 949 Bytes

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

    # 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(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(text)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
percona_migrator-0.1.1 lib/percona_migrator/logger.rb
percona_migrator-1.0.0 lib/percona_migrator/logger.rb