slf4r 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -5,15 +5,14 @@ class Slf4r::Log4jGenerator < Rails::Generators::Base
|
|
5
5
|
source = File.expand_path('../../templates', __FILE__)
|
6
6
|
initializer "log4j.rb", File.read(File.join(source, "log4j.rb"))
|
7
7
|
initializer "log4j.properties", File.read(File.join(source, "log4j.properties"))
|
8
|
+
gem 'slf4r', :require => 'slf4r/java_logger'
|
8
9
|
|
9
|
-
|
10
|
+
file_name = 'Mavenfile'
|
10
11
|
jar_line = "org.slf4j.slf4j-log4j12"
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
f.puts "
|
15
|
-
f.puts " jar '#{jar_line}', '1.6.1'"
|
16
|
-
f.puts "end"
|
12
|
+
mavenfile = File.exists?(file_name) ? File.read(file_name) : ''
|
13
|
+
unless mavenfile =~ /#{jar_line}/
|
14
|
+
File.open(file_name, 'a') do |f|
|
15
|
+
f.puts "jar '#{jar_line}', '1.6.1'"
|
17
16
|
end
|
18
17
|
end
|
19
18
|
end
|
@@ -4,6 +4,7 @@ class Slf4r::LoggingGenerator < Rails::Generators::Base
|
|
4
4
|
def setup
|
5
5
|
source = File.expand_path('../../templates', __FILE__)
|
6
6
|
initializer "logging.rb", File.read(File.join(source, "logging.rb"))
|
7
|
+
gem 'slf4r', :require => 'slf4r/logging_logger'
|
7
8
|
gem "logging"
|
8
9
|
end
|
9
10
|
end
|
data/lib/slf4r/slf4r_railtie.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
class Slf4rRailtie < Rails::Railtie
|
2
2
|
|
3
|
-
|
4
|
-
#if defined?(Slf4r)
|
5
|
-
# require 'slf4r/ruby_logger' unless defined?(::Slf4r::LoggerFacade)
|
6
|
-
#end
|
3
|
+
initializer "set_servlet_logger", :after => :initialize_logger do |app|
|
7
4
|
if defined?(Slf4r::LoggerFacade)
|
8
|
-
@logger =
|
9
|
-
|
5
|
+
@logger = Slf4r::LoggerFacade.new("Rails::Setup")
|
6
|
+
@logger.info {
|
7
|
+
l = @logger.instance_variable_get('@logger'.to_sym)
|
8
|
+
logger_name = l.respond_to?(:java_class) ? l.java_class : l.class
|
9
|
+
"setup slf4r logger #{logger_name}"
|
10
|
+
}
|
11
|
+
app.config.logger = Rails.logger = setup_logger(Rails)
|
10
12
|
app.config.action_controller.logger = setup_logger(ActionController)
|
11
13
|
app.config.active_record.logger = setup_logger(ActiveRecord)
|
12
14
|
app.config.action_view.logger = setup_logger(ActionView) if app.config.action_view.respond_to? :logger=
|
@@ -17,22 +19,17 @@ class Slf4rRailtie < Rails::Railtie
|
|
17
19
|
else
|
18
20
|
@logger.instance_variable_get(:@logger).class
|
19
21
|
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
config.after_initialize do |app|
|
25
|
-
unless defined?(Slf4r::LoggerFacade)
|
22
|
+
else
|
26
23
|
require 'slf4r/wrapped_logger'
|
27
|
-
Slf4r::LoggerFacade4WrappedLogger.logger = Rails.logger
|
28
|
-
|
24
|
+
l = Slf4r::LoggerFacade4WrappedLogger.logger = Rails.logger
|
25
|
+
l.info "setup slf4r logger wrapper"
|
29
26
|
end
|
30
27
|
end
|
31
28
|
|
32
29
|
private
|
33
30
|
def self.setup_logger(category)
|
34
31
|
l = Slf4r::LoggerFacade.new((category == Rails ? "" : "Rails::") + category.to_s)
|
35
|
-
|
32
|
+
@logger.info("setup logger for '#{l.name}'") if @logger
|
36
33
|
l
|
37
34
|
end
|
38
35
|
end
|
data/lib/slf4r/version.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
|
+
- 2
|
9
|
+
version: 0.4.2
|
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: 2011-03-
|
17
|
+
date: 2011-03-21 00:00:00 +05:30
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -87,6 +87,22 @@ dependencies:
|
|
87
87
|
version: 3.0.1
|
88
88
|
type: :development
|
89
89
|
version_requirements: *id005
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: ruby-maven
|
92
|
+
prerelease: false
|
93
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
- 8
|
100
|
+
- 3
|
101
|
+
- 0
|
102
|
+
- 2
|
103
|
+
version: 0.8.3.0.2
|
104
|
+
type: :development
|
105
|
+
version_requirements: *id006
|
90
106
|
description: Slf4r provides a uniform interface for instantiating und using of a logger
|
91
107
|
email:
|
92
108
|
- m.kristian@web.de
|
@@ -101,7 +117,6 @@ files:
|
|
101
117
|
- MIT-LICENSE
|
102
118
|
- History.txt
|
103
119
|
- README.rdoc
|
104
|
-
- Rakefile
|
105
120
|
- lib/slf4r.rb
|
106
121
|
- lib/logging_adapter.rb
|
107
122
|
- lib/ruby_logger_adapter.rb
|
data/Rakefile
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# -*- ruby -*-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
|
5
|
-
require 'spec'
|
6
|
-
require 'spec/rake/spectask'
|
7
|
-
|
8
|
-
BUILD_DIR = 'target'
|
9
|
-
|
10
|
-
desc 'clean up'
|
11
|
-
task :clean do
|
12
|
-
FileUtils.rm_rf(BUILD_DIR)
|
13
|
-
FileUtils.rm_rf('tmp')
|
14
|
-
end
|
15
|
-
|
16
|
-
desc 'package as a gem.'
|
17
|
-
task :package do
|
18
|
-
require 'fileutils'
|
19
|
-
gemspec = Dir['*.gemspec'].first
|
20
|
-
Kernel.system("#{RUBY} -S gem build #{gemspec}")
|
21
|
-
FileUtils.mkdir_p(BUILD_DIR)
|
22
|
-
gem = Dir['*.gem'].first
|
23
|
-
FileUtils.mv(gem, File.join(BUILD_DIR,"#{gem}"))
|
24
|
-
puts File.join(BUILD_DIR,"#{gem}")
|
25
|
-
end
|
26
|
-
|
27
|
-
desc 'Install the package as a gem.'
|
28
|
-
task :install => [:package] do
|
29
|
-
gem = Dir[File.join(BUILD_DIR, '*.gem')].first
|
30
|
-
extra = ENV['GEM_HOME'].nil? && ENV['GEM_PATH'].nil? ? "--user-install" : ""
|
31
|
-
Kernel.system("#{RUBY} -S gem install --local #{gem} --no-ri --no-rdoc #{extra}")
|
32
|
-
end
|
33
|
-
|
34
|
-
desc 'Run specifications'
|
35
|
-
Spec::Rake::SpecTask.new(:spec) do |t|
|
36
|
-
if File.exists?('spec/spec.opts')
|
37
|
-
t.spec_opts << '--options' << 'spec/spec.opts'
|
38
|
-
end
|
39
|
-
t.spec_files = Dir.glob('./spec/**/*_spec.rb')
|
40
|
-
end
|
41
|
-
|
42
|
-
# vim: syntax=Ruby
|