Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 89 lines (75 sloc) 2.32 kb
5321f722 »
2011-09-15 initial commit
1
2 require 'logging'
3
d6986f36 »
2011-09-19 Remove the LogTail middleware if present
4 require 'rails' if !defined? Rails or Rails.version
5
6 if Rails.version < '3'
7 abort("The Logging Railtie only works with Rails 3 or higher - you are running Rails #{Rails.version}")
8 end
9
5321f722 »
2011-09-15 initial commit
10 module Logging::Rails
11
12 # :stopdoc:
13 LIBPATH = ::File.expand_path('../..', __FILE__) + ::File::SEPARATOR
14 PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
15 # :startdoc:
16
17 class << self
18 # Returns the version string for the library.
19 #
20 def version
21 @version ||= File.read(path('version.txt')).strip
22 end
23
1076c5c2 »
2011-09-16 Updating the documentation
24 # Stores the given Logging configuration block for later evalution by the
25 # Railtie. This method is used in the 'config/logging.rb' configuration
26 # file.
5321f722 »
2011-09-15 initial commit
27 #
28 def configure( &block )
29 @configuration = block
30 end
31
32 attr_reader :configuration
33
34 # Returns the path for Mr Bones. If any arguments are given,
35 # they will be joined to the end of the path using <tt>File.join</tt>.
36 #
37 def path( *args )
38 rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
39 if block_given?
40 begin
41 $LOAD_PATH.unshift PATH
42 rv = yield
43 ensure
44 $LOAD_PATH.shift
45 end
46 end
47 return rv
48 end
49
50 # Returns the lib path for Mr Bones. If any arguments are given,
51 # they will be joined to the end of the path using <tt>File.join</tt>.
52 #
53 def libpath( *args )
54 rv = args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
55 if block_given?
56 begin
57 $LOAD_PATH.unshift LIBPATH
58 rv = yield
59 ensure
60 $LOAD_PATH.shift
61 end
62 end
63 return rv
64 end
65 end
66
67 libpath {
68 require 'logging/rails/railtie'
5601683f »
2011-09-16 Updating the require statement to reflect the new name.
69 require 'logging/rails/mixin'
5321f722 »
2011-09-15 initial commit
70 }
71
72 end # Logging::Rails
73
d6986f36 »
2011-09-19 Remove the LogTail middleware if present
74
75 # Here we need to remove the Rails LogTailer from the list of middlewares. The
76 # Logging framework is fully capable of sending log events to multiple logging
77 # destinations.
78 #
79 module Rails
80 class Server < ::Rack::Server
81 def middleware_without_log_tailer
82 middlewares = middleware_with_log_tailer['anything']
83 middlewares.delete_if { |middleware| Rails::Rack::LogTailer == middleware.first }
84 Hash.new(middlewares)
85 end
86 alias :middleware_with_log_tailer :middleware
87 alias :middleware :middleware_without_log_tailer
88 end
89 end
90
Something went wrong with that request. Please try again.