apache-config-generator/lib/apache/logging.rb

30 lines
847 B
Ruby
Raw Normal View History

2010-05-05 14:44:20 +00:00
module Apache
module Logging
2010-05-07 02:26:12 +00:00
[ :custom, :error, :script, :rewrite ].each do |type|
class_eval <<-EOT
def #{type}_log(*opts)
handle_log '#{type.to_s.capitalize}Log', opts.first, opts.first, opts[1..-1]
end
2010-05-05 16:25:07 +00:00
2010-05-07 02:26:12 +00:00
def rotate_#{type}_log(*opts)
handle_log '#{type.to_s.capitalize}Log', opts.first, quoteize(rotatelogs(*opts[0..1])), opts[2..-1]
end
EOT
2010-05-05 14:44:20 +00:00
end
def combined_log_format(name = 'combined')
log_format '%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"', name.to_sym
end
def common_log_format(name = 'common')
log_format '%h %l %u %t \"%r\" %>s %b', name.to_sym
end
2010-05-05 16:25:07 +00:00
private
def handle_log(tag, path, real_path, *opts)
writable? path
self << "#{tag} #{[real_path, opts].flatten * " "}"
end
2010-05-05 14:44:20 +00:00
end
end