slf4r 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.txt → README.rdoc} +0 -0
- data/lib/slf4r/abstract_logger_facade.rb +1 -0
- data/lib/slf4r/logger.rb +1 -1
- data/lib/slf4r/ruby_logger.rb +2 -2
- data/lib/slf4r/slf4r_railtie.rb +26 -29
- data/lib/slf4r/version.rb +1 -1
- data/lib/slf4r.rb +2 -1
- metadata +6 -6
data/{README.txt → README.rdoc}
RENAMED
File without changes
|
data/lib/slf4r/logger.rb
CHANGED
data/lib/slf4r/ruby_logger.rb
CHANGED
@@ -10,7 +10,7 @@ module Slf4r
|
|
10
10
|
def self.new_logger_facade(name)
|
11
11
|
@name = name
|
12
12
|
@logger = ::Logger.new(@@file)
|
13
|
-
@@level = ::Logger::
|
13
|
+
@@level = ::Logger::DEBUG unless self.class_variable_defined?(:@@level)
|
14
14
|
@logger.level = @@level
|
15
15
|
@logger.datetime_format = @@datetime_format
|
16
16
|
@logger
|
@@ -40,7 +40,7 @@ module Slf4r
|
|
40
40
|
private
|
41
41
|
|
42
42
|
def log(type, msg)
|
43
|
-
@logger.add(type, msg, @name)
|
43
|
+
@logger.add(type, "(#{@name}) " + msg, @name)
|
44
44
|
end
|
45
45
|
|
46
46
|
protected
|
data/lib/slf4r/slf4r_railtie.rb
CHANGED
@@ -1,41 +1,38 @@
|
|
1
1
|
class Slf4rRailtie < Rails::Railtie
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
app.config.logger = setup_logger(app.config.logger
|
13
|
-
app.config.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
ActiveSupport::Cache::Store.logger = Slf4r::LoggerFacade.new(ActiveSupport::Cache::Store)
|
18
|
-
clazz = if logger.instance_variable_get(:@logger).respond_to?(:java_class)
|
19
|
-
logger.instance_variable_get(:@logger).java_class
|
3
|
+
config.before_configuration do |app|
|
4
|
+
#if defined?(Slf4r)
|
5
|
+
# require 'slf4r/ruby_logger' unless defined?(::Slf4r::LoggerFacade)
|
6
|
+
#end
|
7
|
+
if defined?(Slf4r::LoggerFacade)
|
8
|
+
@logger = (Rails.logger = setup_logger(Rails))
|
9
|
+
app.config.logger = @logger
|
10
|
+
app.config.action_controller.logger = setup_logger(ActionController)
|
11
|
+
app.config.active_record.logger = setup_logger(ActiveRecord)
|
12
|
+
app.config.action_view.logger = setup_logger(ActionView) if app.config.action_view.respond_to? :logger=
|
13
|
+
app.config.action_mailer.logger = setup_logger(ActionMailer)
|
14
|
+
ActiveSupport::Cache::Store.logger = setup_logger(ActiveSupport::Cache::Store)
|
15
|
+
clazz = if @logger.instance_variable_get(:@logger).respond_to?(:java_class)
|
16
|
+
@logger.instance_variable_get(:@logger).java_class
|
20
17
|
else
|
21
|
-
logger.instance_variable_get(:@logger).class
|
18
|
+
@logger.instance_variable_get(:@logger).class
|
22
19
|
end
|
23
|
-
|
24
|
-
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
config.after_initialize do |app|
|
25
|
+
unless defined?(Slf4r::LoggerFacade)
|
25
26
|
require 'slf4r/wrapped_logger'
|
26
|
-
|
27
|
-
|
27
|
+
Slf4r::LoggerFacade4WrappedLogger.logger = Rails.logger
|
28
|
+
puts "setup slf4r logger wrapper"
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
32
|
private
|
32
|
-
def self.setup_logger(
|
33
|
-
l = Slf4r::LoggerFacade.new(category)
|
34
|
-
|
35
|
-
# adjust log level it the logger implementation allows it
|
36
|
-
if logger && real_logger.respond_to?(:level)
|
37
|
-
real_logger.level = logger.level
|
38
|
-
end
|
33
|
+
def self.setup_logger(category)
|
34
|
+
l = Slf4r::LoggerFacade.new((category == Rails ? "" : "Rails::") + category.to_s)
|
35
|
+
(@logger || l).info("setup logger for '#{l.name}")
|
39
36
|
l
|
40
37
|
end
|
41
38
|
end
|
data/lib/slf4r/version.rb
CHANGED
data/lib/slf4r.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 1
|
9
|
+
version: 0.4.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kristian Meier
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-03-01 00:00:00 +05:30
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -96,11 +96,11 @@ extensions: []
|
|
96
96
|
|
97
97
|
extra_rdoc_files:
|
98
98
|
- History.txt
|
99
|
-
- README.
|
99
|
+
- README.rdoc
|
100
100
|
files:
|
101
101
|
- MIT-LICENSE
|
102
102
|
- History.txt
|
103
|
-
- README.
|
103
|
+
- README.rdoc
|
104
104
|
- Rakefile
|
105
105
|
- lib/slf4r.rb
|
106
106
|
- lib/logging_adapter.rb
|
@@ -138,7 +138,7 @@ licenses:
|
|
138
138
|
post_install_message:
|
139
139
|
rdoc_options:
|
140
140
|
- --main
|
141
|
-
- README.
|
141
|
+
- README.rdoc
|
142
142
|
require_paths:
|
143
143
|
- lib
|
144
144
|
required_ruby_version: !ruby/object:Gem::Requirement
|