Sha256: b3ad4245a4f67fd91f3eb2db842a5e545b64c33b593daebad1756bf22b6a80d3

Contents?: true

Size: 776 Bytes

Versions: 1

Compression:

Stored size: 776 Bytes

Contents

require "fix_tsv_conflict/refinements/colored_string"

module FixTSVConflict
  module Logging
    using Refinements::ColoredString

    def log(message, **options)
      if options[:no_newline]
        stderr.print message.chomp
      else
        stderr.puts message
      end
    end

    def info(message, **options)
      log message, options
    end

    def error(message, **options)
      log message.to_s.red
    end

    def warn(message, **options)
      log message.to_s.yellow
    end

    def notice(message, **options)
      log message.to_s.green
    end

    def dump(lines, **options)
      Array(lines).each do |line|
        log line.gsub(/^/, "  ").gsub("\t") { |m| m.bg_cyan }, options
      end
    end

    def blank
      stderr.puts
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fix_tsv_conflict-0.3.0 lib/fix_tsv_conflict/logging.rb