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-0.4.5 lib/active_wrapper/log.rb
active_wrapper-solo-0.4.4 lib/active_wrapper/log.rb
active_wrapper-ar2-0.4.4 lib/active_wrapper/log.rb
active_wrapper-0.4.4 lib/active_wrapper/log.rb
active_wrapper-solo-0.4.3 lib/active_wrapper/log.rb
active_wrapper-ar2-0.4.3 lib/active_wrapper/log.rb
active_wrapper-0.4.3 lib/active_wrapper/log.rb
active_wrapper-0.4.0 lib/active_wrapper/log.rb
active_wrapper-0.3.4 lib/active_wrapper/log.rb
active_wrapper-0.3.3 lib/active_wrapper/log.rb
active_wrapper-0.3.2 lib/active_wrapper/log.rb
active_wrapper-0.3.1 lib/active_wrapper/log.rb
active_wrapper-0.3.0 lib/active_wrapper/log.rb
active_wrapper-0.2.7 lib/active_wrapper/log.rb
active_wrapper-0.2.6 lib/active_wrapper/log.rb
active_wrapper-0.2.5 lib/active_wrapper/log.rb
active_wrapper-0.2.4 lib/active_wrapper/log.rb
active_wrapper-0.2.3 lib/active_wrapper/log.rb
active_wrapper-0.2.2 lib/active_wrapper/log.rb
active_wrapper-0.2.1 lib/active_wrapper/log.rb