Sha256: 7317e2cea9e0cbccb6d384a3f569a691ed4d85215688927954452da42322a68d

Contents?: true

Size: 823 Bytes

Versions: 41

Compression:

Stored size: 823 Bytes

Contents

module ActiveWrapper
  class Log
    
    attr_reader :base, :log, :logger, :stdout
    
    def initialize(options)
      @base = options[:base]
      @log = options[:log]
      @stdout = options[:stdout]
      
      return if @log == false
      
      FileUtils.mkdir_p("#{base}/log")
      file = File.open("#{base}/log/#{log}.log", 'a')
      file.sync = true
      
      if stdout
        @logger = Logger.new($stdout)
        $stdout.reopen(file)
        $stderr.reopen(file)
      else
        @logger = Logger.new(file)
      end
      
      ActiveRecord::Base.logger = @logger
    end
    
    def clear
      Dir["#{base}/log/*.log"].each do |file|
        f = File.open(file, "w")
        f.close
      end
    end
    
    def method_missing(method, *args)
      logger.send(method, *args)
    end
  end
end

Version data entries

41 entries across 41 versions & 4 rubygems

Version Path
active_wrapper-solo-0.4.9 lib/active_wrapper/log.rb
active_wrapper-ar2-0.4.9 lib/active_wrapper/log.rb
active_wrapper-0.4.9 lib/active_wrapper/log.rb
active_wrapper-0.4.7 lib/active_wrapper/log.rb
winton-active_wrapper-0.1.0 lib/active_wrapper/log.rb
winton-active_wrapper-0.1.1 lib/active_wrapper/log.rb
winton-active_wrapper-0.1.2 lib/active_wrapper/log.rb
winton-active_wrapper-0.1.3 lib/active_wrapper/log.rb
winton-active_wrapper-0.1.4 lib/active_wrapper/log.rb
winton-active_wrapper-0.1.5 lib/active_wrapper/log.rb
winton-active_wrapper-0.1.6 lib/active_wrapper/log.rb
winton-active_wrapper-0.1.7 lib/active_wrapper/log.rb
winton-active_wrapper-0.1.8 lib/active_wrapper/log.rb
winton-active_wrapper-0.1.9 lib/active_wrapper/log.rb
winton-active_wrapper-0.2.0 lib/active_wrapper/log.rb
active_wrapper-solo-0.4.6 lib/active_wrapper/log.rb
active_wrapper-ar2-0.4.6 lib/active_wrapper/log.rb
active_wrapper-0.4.6 lib/active_wrapper/log.rb
active_wrapper-solo-0.4.5 lib/active_wrapper/log.rb
active_wrapper-ar2-0.4.5 lib/active_wrapper/log.rb