Class: Webmate::Logger

Inherits:
Rack::CommonLogger
  • Object
show all
Defined in:
lib/webmate/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(app = nil) ⇒ Logger

Returns a new instance of Logger.



4
5
6
7
8
# File 'lib/webmate/logger.rb', line 4

def initialize(app = nil)
  @app = app
  Dir.mkdir(configatron.logger.path) unless File.exists?(configatron.logger.path)
  @@logger_file ||= File.new(File.join(configatron.logger.path, "#{Webmate.env}.log"), 'a')
end

Instance Method Details

#dump(text) ⇒ Object



14
15
16
17
18
# File 'lib/webmate/logger.rb', line 14

def dump(text)
  [@@logger_file, STDOUT].each do |out|
    out.write %Q{[#{Time.now.strftime("%D %H:%M:%S")}] #{text} \n\n}
  end
end

#log(env, status, header, began_at) ⇒ Object



10
11
12
# File 'lib/webmate/logger.rb', line 10

def log(env, status, header, began_at)
  dump(%Q{HTTP #{env["REQUEST_METHOD"]}: #{env["PATH_INFO"]} #{status} \nParams: #{env['rack.request.query_hash']}})
end