Sha256: e308c0b52fa16900c1bfa991165bde3f8cd73d9a636a8de83a2a1917521597b5

Contents?: true

Size: 511 Bytes

Versions: 1

Compression:

Stored size: 511 Bytes

Contents

require 'logger'
require 'date'

module Yarn
  module Logging

    def log(msg)
      if msg.respond_to?(:each)
        msg.each do |line|
          output.puts "#{timestamp} #{line}"
        end
      else
        output.puts "#{timestamp} #{msg}"
      end
    end

    def debug(msg=nil)
      log "DEBUG: #{msg}" if $debug
    end

    def output
      $output || $stdout
    end

    def timestamp
      current_time = DateTime.now
      "#{current_time.strftime("%d/%m/%y %H:%M:%S")} -"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yarn-0.0.2 lib/yarn/logging.rb