Sha256: bea83a7fe5bd9a788a50bad7445f902a89b8b713891032857512c780e6f0ae6f

Contents?: true

Size: 584 Bytes

Versions: 13

Compression:

Stored size: 584 Bytes

Contents

require 'logger'

module Guignol::Logger
  def logger
    @logger ||= ::Logger.new(logger_file).tap do |logger|
      logger.progname = 'guignol'
      logger.formatter = Formatter.new
    end
  end


  private

  class Formatter < ::Logger::Formatter
    Format = "[%s] %s: %s\n"

    def call(severity, time, progname, msg)
      Format % [time.strftime('%F %T'), severity, msg2str(msg)]
    end
  end


  def logger_file
    return File.open(ENV['GUIGNOL_LOG'] ,'a') if ENV['GUIGNOL_LOG'] 
    $stdout.tty? ? $stdout : File.open('/dev/null','w')  
  end

  Guignol.extend(self)
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
guignol-0.3.9 lib/guignol/logger.rb
guignol-0.3.8 lib/guignol/logger.rb
guignol-0.3.7 lib/guignol/logger.rb
guignol-0.3.6.2 lib/guignol/logger.rb
guignol-0.3.6.1 lib/guignol/logger.rb
guignol-0.3.6 lib/guignol/logger.rb
guignol-0.3.5.1 lib/guignol/logger.rb
guignol-0.3.5 lib/guignol/logger.rb
guignol-0.3.4 lib/guignol/logger.rb
guignol-0.3.3 lib/guignol/logger.rb
guignol-0.3.2 lib/guignol/logger.rb
guignol-0.3.1 lib/guignol/logger.rb
guignol-0.3.0 lib/guignol/logger.rb