slf4r 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +27 -0
- data/MIT-LICENSE +20 -0
- data/README.txt +106 -0
- data/Rakefile +42 -0
- data/lib/slf4r/version.rb +1 -1
- data/lib/slf4r.rb +13 -1
- data/spec/spec_helper.rb +2 -0
- metadata +13 -7
data/History.txt
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
=== 0.3.3 / 2010-07-29
|
2
|
+
|
3
|
+
* reworked Rakefile, pom.xml
|
4
|
+
|
5
|
+
* better decision which default logger to use
|
6
|
+
|
7
|
+
=== 0.3.2 / 2010-06-20
|
8
|
+
|
9
|
+
* fixed non java case to fall back to rubylogger
|
10
|
+
|
11
|
+
=== 0.3.1 / 2010-05-12
|
12
|
+
|
13
|
+
* added fatal methods since they are just missing
|
14
|
+
|
15
|
+
* check before triggering the log event, i.e. have string operations only when logging takes place
|
16
|
+
|
17
|
+
=== 0.3.0 / 2010-05-09
|
18
|
+
|
19
|
+
* added pom.xml for maven build
|
20
|
+
|
21
|
+
* added facade for slf4j which will be default when running jruby and having the respective libraries in place
|
22
|
+
|
23
|
+
=== 0.1.1 / 2008-12-19
|
24
|
+
|
25
|
+
* fixed printoout of backtrace
|
26
|
+
|
27
|
+
* added log methods for ruby_logger_adapter
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Kristian Meier
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.txt
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
= SLF4R
|
2
|
+
|
3
|
+
the main idea is from www.slf4j.org which is to provide a uniform interface for instantiating und using of a logger. but the actual logging is done by some third party logging framework.
|
4
|
+
|
5
|
+
one idea is to have a logger per class or object (see also http://slf4j.org/). in ruby you would have something like
|
6
|
+
|
7
|
+
@logger = Slf4r::LoggerFacade.new(self.class)
|
8
|
+
|
9
|
+
or the convinience module
|
10
|
+
|
11
|
+
include Slf4r::Logger
|
12
|
+
|
13
|
+
if the underlying logging framework allows it (like logging or log4r) then you get a logger for each namespace of your class and create a hierachy of loggers. with this you can control the log level for each logger and/or namespace separately.
|
14
|
+
|
15
|
+
for example you have a framework A with namespace 'A' then you can set the log level for the logger with name 'A' to debug and get all the debug from the framework, etc.
|
16
|
+
|
17
|
+
in case you have a framework B which uses log4r internally you can use the 'log4r_adapter' to delegate the logger creation from log4r to slf4r. in this way you have only one place where logging gets configured and controlled.
|
18
|
+
|
19
|
+
== FEATURES:
|
20
|
+
|
21
|
+
* can replace other logging frameworks via adapters
|
22
|
+
|
23
|
+
* for the actual logging it depends on a third party logging framework and its configuration
|
24
|
+
|
25
|
+
== SYNOPSIS:
|
26
|
+
|
27
|
+
=== using with logging gem
|
28
|
+
|
29
|
+
require 'slf4r/logging_logger'
|
30
|
+
|
31
|
+
Logging.init :debug, :info, :warn, :error
|
32
|
+
|
33
|
+
appender = Logging::Appender.stdout
|
34
|
+
appender.layout = Logging::Layouts::Pattern.new(:pattern => "%d [%-l] (%c) %m\n")
|
35
|
+
logger = Logging::Logger.new(:root)
|
36
|
+
logger.add_appenders(appender)
|
37
|
+
logger.level = :debug
|
38
|
+
|
39
|
+
=== using with ruby logger
|
40
|
+
|
41
|
+
require 'slf4r/ruby_logger'
|
42
|
+
|
43
|
+
=== using the log4r adapter
|
44
|
+
|
45
|
+
require 'log4r_adapter'
|
46
|
+
|
47
|
+
=== using with rails/merb/datamapper logger
|
48
|
+
|
49
|
+
require 'slf4r/wrapped_logger'
|
50
|
+
|
51
|
+
Slf4r::LoggerFacade4WrappedLogger.logger = framwork_logger
|
52
|
+
|
53
|
+
=== using with slf4j with jruby
|
54
|
+
|
55
|
+
just get the needed jar files/ configuration files in the classpath
|
56
|
+
(see http://slf4j.org/) or if you use maven then have a look and the
|
57
|
+
pom.xml of that project.
|
58
|
+
|
59
|
+
=== getting an instance of a logger
|
60
|
+
|
61
|
+
Slf4r::LoggerFacade.new("Full::Qualified::Class::Name")
|
62
|
+
|
63
|
+
or
|
64
|
+
|
65
|
+
Slf4r::LoggerFacade.new(Full::Qualified::Class::Name)
|
66
|
+
|
67
|
+
== REQUIREMENTS:
|
68
|
+
|
69
|
+
* logging for slf4r/logging_logger
|
70
|
+
|
71
|
+
* log4r for slf4r/log4r_logger
|
72
|
+
|
73
|
+
* slf4j jars in the classpath for slf4j
|
74
|
+
|
75
|
+
== INSTALL:
|
76
|
+
|
77
|
+
* sudo gem install slf4r
|
78
|
+
|
79
|
+
* sudo gem install logging # optional
|
80
|
+
|
81
|
+
* sudo gem install log4r # optional
|
82
|
+
|
83
|
+
== LICENSE:
|
84
|
+
|
85
|
+
(The MIT License)
|
86
|
+
|
87
|
+
Copyright (c) 2010 kristian meier
|
88
|
+
|
89
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
90
|
+
a copy of this software and associated documentation files (the
|
91
|
+
'Software'), to deal in the Software without restriction, including
|
92
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
93
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
94
|
+
permit persons to whom the Software is furnished to do so, subject to
|
95
|
+
the following conditions:
|
96
|
+
|
97
|
+
The above copyright notice and this permission notice shall be
|
98
|
+
included in all copies or substantial portions of the Software.
|
99
|
+
|
100
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
101
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
102
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
103
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
104
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
105
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
106
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
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
|
data/lib/slf4r/version.rb
CHANGED
data/lib/slf4r.rb
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
require 'slf4r/logger'
|
2
2
|
begin
|
3
|
-
|
3
|
+
# make sure we have java
|
4
|
+
require 'java'
|
5
|
+
begin
|
6
|
+
# make sure we have SLF4J in the classloader
|
7
|
+
import 'org.slf4j.LoggerFactory'
|
8
|
+
|
9
|
+
require 'slf4r/java_logger'
|
10
|
+
puts "using slf4j logger"
|
11
|
+
rescue NameError
|
12
|
+
puts "no SLF4J found in classloader - using ruby logger"
|
13
|
+
require 'slf4r/ruby_logger'
|
14
|
+
end
|
4
15
|
rescue LoadError
|
16
|
+
puts "using ruby logger"
|
5
17
|
require 'slf4r/ruby_logger'
|
6
18
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 3
|
9
|
+
version: 0.3.3
|
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: 2010-
|
17
|
+
date: 2010-07-31 00:00:00 +05:30
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -66,9 +66,14 @@ executables: []
|
|
66
66
|
|
67
67
|
extensions: []
|
68
68
|
|
69
|
-
extra_rdoc_files:
|
70
|
-
|
69
|
+
extra_rdoc_files:
|
70
|
+
- History.txt
|
71
|
+
- README.txt
|
71
72
|
files:
|
73
|
+
- MIT-LICENSE
|
74
|
+
- History.txt
|
75
|
+
- README.txt
|
76
|
+
- Rakefile
|
72
77
|
- lib/logging_adapter.rb
|
73
78
|
- lib/slf4r.rb
|
74
79
|
- lib/log4r_adapter.rb
|
@@ -95,8 +100,9 @@ homepage: http://github.com/mkristian/slf4r
|
|
95
100
|
licenses:
|
96
101
|
- MIT-LICENSE
|
97
102
|
post_install_message:
|
98
|
-
rdoc_options:
|
99
|
-
|
103
|
+
rdoc_options:
|
104
|
+
- --main
|
105
|
+
- README.txt
|
100
106
|
require_paths:
|
101
107
|
- lib
|
102
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|