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

38 lines
1.0 KiB
Ruby
Raw Normal View History

2010-05-05 14:44:20 +00:00
module Apache
module Logging
def error_log(*opts)
2010-05-05 16:25:07 +00:00
handle_log 'ErrorLog', opts.first, opts.first, opts[1..-1]
2010-05-05 14:44:20 +00:00
end
def custom_log(*opts)
2010-05-05 16:25:07 +00:00
handle_log 'CustomLog', opts.first, opts.first, opts[1..-1]
end
def rotate_custom_log(*opts)
handle_log 'CustomLog', opts.first, quoteize(rotatelogs(*opts[0..1])), opts[2..-1]
end
def rotate_error_log(*opts)
handle_log 'ErrorLog', opts.first, quoteize(rotatelogs(*opts[0..1])), opts[2..-1]
end
def rotate_script_log(*opts)
handle_log 'ScriptLog', opts.first, quoteize(rotatelogs(*opts[0..1])), opts[2..-1]
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