$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) module Bastard LogRoot = nil end Clarity::GrepRenderer.module_eval do require 'bastard/renderers/mail_file_log_renderer' def renderer @renderer ||= MailFileLogRenderer.new end end Clarity::Server.module_eval do def sanitize_file_location(path) parts = path.split('/') file = parts.pop parts.map! { |part| part.gsub('.', '') } parts << file parts.join('/') end def process_http_request_with_fetch return process_http_request_without_fetch unless path == '/fetch' return respond_with(404, "

Not Found

") if params.empty? || (params['path'] || '').empty? log_files.each do |base| file = File.join(Bastard::LogRoot, base.split('/').first, sanitize_file_location(params['path'])) STDERR.puts "Checking file: #{file}\n" if File.exists?(file) STDERR.puts "Transmitting file: #{file}\n" return respond_with(200, File.read(file), :content_type => "text/plain") end end return respond_with(404, "

Not Found

") end alias :process_http_request_without_fetch :process_http_request alias :process_http_request :process_http_request_with_fetch end