Sha256: c8ccd0f95d5517075d2e78b1ce56695271c89512b6f144ce510a47657a1c30e0

Contents?: true

Size: 546 Bytes

Versions: 9

Compression:

Stored size: 546 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.map { |h| h.values.join(" ") }.join(" -> ")
      when Hash
        args.values.join(" ")
      else
        raise args.inspect
      end
      logger.info "Zonesync: #{method.capitalize} #{operation}"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
zonesync-0.7.0 lib/zonesync/logger.rb
zonesync-0.6.1 lib/zonesync/logger.rb
zonesync-0.6.0 lib/zonesync/logger.rb
zonesync-0.5.2 lib/zonesync/logger.rb
zonesync-0.5.1 lib/zonesync/logger.rb
zonesync-0.5.0 lib/zonesync/logger.rb
zonesync-0.4.1 lib/zonesync/logger.rb
zonesync-0.4.0 lib/zonesync/logger.rb
zonesync-0.3.0 lib/zonesync/logger.rb