Sha256: f428f4b5923d78bd5b82e7e56ce57c97c89c1587e741ac68ccb7276659fa3131

Contents?: true

Size: 556 Bytes

Versions: 2

Compression:

Stored size: 556 Bytes

Contents

require "logger"
require "fileutils"

class Logger
  def self.log method, args, dry_run: false
    loggers = [::Logger.new(STDOUT)]

    if !dry_run
      FileUtils.mkdir_p("log")
      loggers << ::Logger.new("log/zonesync.log")
    end

    loggers.each do |logger|
      operation = case args
      when Array
        (args.length == 2 ? "\n" : "") +
          args.map { |r| r.to_h.values.join(" ") }.join("->\n")
      else
        args.to_h.values.join(" ")
      end
      logger.info "Zonesync: #{method.capitalize} #{operation}"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zonesync-0.9.0 lib/zonesync/logger.rb
zonesync-0.8.0 lib/zonesync/logger.rb