class Qwik::Logger
Constants
- ACCESS_LOG
- IGNORE_ACTION
- WEB_ACCESS_LOG
- WEB_ERROR_LOG
Attributes
verbose[W]
Public Class Methods
format_log_line(req, wres, diff)
click to toggle source
# File vendor/qwik/lib/qwik/logger.rb, line 51 def self.format_log_line(req, wres, diff) time = req.start_time.rfc_date fromhost = req.fromhost user = req.user || '-' request_line = req.request_line status = wres.status len = '-' len = wres.body.length if wres.body.is_a? String diff = "%0.2f" % diff str = "#{time} #{fromhost} #{user} \"#{request_line}\" #{status} #{len} #{diff}\n" return str end
new(log_file)
click to toggle source
# File vendor/qwik/lib/qwik/logger.rb, line 16 def initialize(log_file) @log = open(log_file, 'ab+') @log.sync = true @verbose = false end
Public Instance Methods
close()
click to toggle source
# File vendor/qwik/lib/qwik/logger.rb, line 23 def close @log.close @log = nil end
log(wreq, wres, req, res, diff)
click to toggle source
# File vendor/qwik/lib/qwik/logger.rb, line 29 def log(wreq, wres, req, res, diff) return if IGNORE_ACTION.include?(req.plugin) format = Logger.format_log_line(req, wres, diff) @log << format $stdout << format if @verbose end
reopen()
click to toggle source
FIXME: Ad hoc reopen support.
# File vendor/qwik/lib/qwik/logger.rb, line 44 def reopen @log.close log_file = @log.path @log = open(log_file, 'ab+') @log.sync = true end
take_log(format)
click to toggle source
# File vendor/qwik/lib/qwik/logger.rb, line 36 def take_log(format) #return if IGNORE_ACTION.include?(req.plugin) #format = Logger.format_log_line(req, wres, diff) @log << format $stdout << format if @verbose end
Private Instance Methods
nu_resolve(ip)
click to toggle source
# File vendor/qwik/lib/qwik/logger.rb, line 66 def nu_resolve(ip) begin return Resolv.getname(ip).to_s rescue return ip end end