@@ -14,47 +14,30 @@ module JRuby::Rack
14
14
class Railtie < ::Rails ::Railtie
15
15
16
16
config . before_configuration do |app |
17
- paths = app . config . paths ; public = JRuby ::Rack . public_path
18
- if paths . respond_to? ( :'[]' ) && paths . respond_to? ( :keys )
19
- # Rails 3.1/3.2/4.x: paths["app/controllers"] style
17
+ public = JRuby ::Rack . public_path
18
+ if public # nil if /public does not exist
19
+ paths = app . config . paths
20
20
old_public = Pathname . new ( paths [ 'public' ] . to_a . first )
21
21
javascripts = Pathname . new ( paths [ 'public/javascripts' ] . to_a . first )
22
22
stylesheets = Pathname . new ( paths [ 'public/stylesheets' ] . to_a . first )
23
23
paths [ 'public' ] = public . to_s ; public = Pathname . new ( public )
24
24
paths [ 'public/javascripts' ] = public . join ( javascripts . relative_path_from ( old_public ) ) . to_s
25
25
paths [ 'public/stylesheets' ] = public . join ( stylesheets . relative_path_from ( old_public ) ) . to_s
26
- else
27
- # Rails 3.0: old paths.app.controllers style
28
- old_public = Pathname . new ( paths . public . to_a . first )
29
- javascripts = Pathname . new ( paths . public . javascripts . to_a . first )
30
- stylesheets = Pathname . new ( paths . public . stylesheets . to_a . first )
31
- paths . public = public . to_s ; public = Pathname . new ( public )
32
- paths . public . javascripts = public . join ( javascripts . relative_path_from ( old_public ) ) . to_s
33
- paths . public . stylesheets = public . join ( stylesheets . relative_path_from ( old_public ) ) . to_s
34
- end if public # nil if /public does not exist
26
+ end
35
27
end
36
28
37
29
# TODO prefix initializers with 'jruby_rack.' !?
38
30
39
31
initializer 'set_servlet_logger' , :before => :initialize_logger do |app |
40
32
app . config . logger ||= begin
41
- config = app . config ; logger = JRuby ::Rack . logger
33
+ logger = JRuby ::Rack . logger
34
+ config = app . config
42
35
log_level = config . log_level || :info
43
36
logger . level = logger . class . const_get ( log_level . to_s . upcase )
44
- log_formatter = config . log_formatter if config . respond_to? ( :log_formatter ) # >= 4.0
37
+ log_formatter = config . log_formatter if config . respond_to? ( :log_formatter )
45
38
logger . formatter = log_formatter if log_formatter && logger . respond_to? ( :formatter= )
46
- if defined? ( ActiveSupport ::TaggedLogging )
47
- if ActiveSupport ::TaggedLogging . is_a? ( Class ) # Rails 3.2
48
- logger = ActiveSupport ::TaggedLogging . new ( logger )
49
- else # Rails 4.0
50
- # extends the logger as well as it's logger.formatter instance :
51
- # NOTE: good idea to keep or should we use a clone as Rails.logger ?
52
- #dup_logger = logger.dup
53
- #dup_logger.formatter = logger.formatter.dup
54
- logger = ActiveSupport ::TaggedLogging . new ( logger )
55
- end
56
- end
57
- logger
39
+ require 'active_support/tagged_logging' unless defined? ( ActiveSupport ::TaggedLogging )
40
+ ActiveSupport ::TaggedLogging . new ( logger ) # returns a logger.clone
58
41
end
59
42
end
60
43
0 commit comments