slf4j 1.5.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +26 -0
- data/README.txt +71 -0
- data/Rakefile +103 -0
- data/assembly.xml +24 -0
- data/lib/slf4j.rb +203 -0
- data/lib/slf4j/base.rb +41 -0
- data/lib/slf4j/jcl-over-slf4j-1.5.3.jar +0 -0
- data/lib/slf4j/jcl-over-slf4j.rb +1 -0
- data/lib/slf4j/jcl.rb +1 -0
- data/lib/slf4j/jdk14.rb +1 -0
- data/lib/slf4j/jul-to-slf4j-1.5.3.jar +0 -0
- data/lib/slf4j/jul-to-slf4j.rb +1 -0
- data/lib/slf4j/log4j-over-slf4j-1.5.3.jar +0 -0
- data/lib/slf4j/log4j-over-slf4j.rb +1 -0
- data/lib/slf4j/log4j12.rb +1 -0
- data/lib/slf4j/nop.rb +1 -0
- data/lib/slf4j/simple.rb +1 -0
- data/lib/slf4j/slf4j-api-1.5.3.jar +0 -0
- data/lib/slf4j/slf4j-jcl-1.5.3.jar +0 -0
- data/lib/slf4j/slf4j-jdk14-1.5.3.jar +0 -0
- data/lib/slf4j/slf4j-log4j12-1.5.3.jar +0 -0
- data/lib/slf4j/slf4j-nop-1.5.3.jar +0 -0
- data/lib/slf4j/slf4j-simple-1.5.3.jar +0 -0
- data/pom.xml +104 -0
- data/test/test_slf4j.rb +96 -0
- metadata +97 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Manifest.txt
|
2
|
+
README.txt
|
3
|
+
History.txt
|
4
|
+
Rakefile
|
5
|
+
pom.xml
|
6
|
+
assembly.xml
|
7
|
+
lib/slf4j.rb
|
8
|
+
lib/slf4j/base.rb
|
9
|
+
test/test_slf4j.rb
|
10
|
+
lib/slf4j/jul-to-slf4j.rb
|
11
|
+
lib/slf4j/jdk14.rb
|
12
|
+
lib/slf4j/jcl-over-slf4j.rb
|
13
|
+
lib/slf4j/jcl.rb
|
14
|
+
lib/slf4j/log4j-over-slf4j.rb
|
15
|
+
lib/slf4j/log4j12.rb
|
16
|
+
lib/slf4j/nop.rb
|
17
|
+
lib/slf4j/simple.rb
|
18
|
+
lib/slf4j/slf4j-api-1.5.3.jar
|
19
|
+
lib/slf4j/jul-to-slf4j-1.5.3.jar
|
20
|
+
lib/slf4j/slf4j-jdk14-1.5.3.jar
|
21
|
+
lib/slf4j/jcl-over-slf4j-1.5.3.jar
|
22
|
+
lib/slf4j/slf4j-jcl-1.5.3.jar
|
23
|
+
lib/slf4j/log4j-over-slf4j-1.5.3.jar
|
24
|
+
lib/slf4j/slf4j-log4j12-1.5.3.jar
|
25
|
+
lib/slf4j/slf4j-nop-1.5.3.jar
|
26
|
+
lib/slf4j/slf4j-simple-1.5.3.jar
|
data/README.txt
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
= slf4j
|
2
|
+
|
3
|
+
* http://rjack.rubyforge.org
|
4
|
+
* http://rubyforge.org/projects/rjack
|
5
|
+
|
6
|
+
== Description
|
7
|
+
|
8
|
+
A JRuby adaption and gem packaging of the
|
9
|
+
{Simple Logging Facade for Java}[http://www.slf4j.org/].
|
10
|
+
Provides all jar dependencies and a Ruby Logger compatible
|
11
|
+
facade.
|
12
|
+
|
13
|
+
SLF4J is a java logging abstraction and set of adapters to various
|
14
|
+
concrete logging implementations and legacy logging APIs. The slf4j
|
15
|
+
gem adds a ruby core Logger compatible facade to SLF4J, and makes any
|
16
|
+
needed adapters available to JRuby applications. This makes it
|
17
|
+
possible to unify and control logging output of both java and ruby
|
18
|
+
components in a JRuby application.
|
19
|
+
|
20
|
+
== Features
|
21
|
+
|
22
|
+
* The complete set of SLF4J jars with ruby 'require' based selection
|
23
|
+
of input and output adapters.
|
24
|
+
* A Ruby core Logger compatible SLF4J::Logger, allowing ruby code to
|
25
|
+
log through SLF4J.
|
26
|
+
|
27
|
+
== Synopsis
|
28
|
+
|
29
|
+
require 'slf4j'
|
30
|
+
require 'slf4j/simple'
|
31
|
+
|
32
|
+
log = SLF4J[ "my.app.logger" ]
|
33
|
+
log.info "Hello World!"
|
34
|
+
|
35
|
+
== License
|
36
|
+
|
37
|
+
=== slf4j gem
|
38
|
+
|
39
|
+
Copyright (C) 2008 David Kellum
|
40
|
+
All rights reserved.
|
41
|
+
|
42
|
+
The SLF4J ruby wrapper and gem packaging is released under the same
|
43
|
+
license terms as the SLF4J java source code and binaries, see below. Note
|
44
|
+
that these license terms are identical to the
|
45
|
+
{MIT License}[http://en.wikipedia.org/wiki/MIT_License] and deemed
|
46
|
+
compatible with GPL and the Apache Software License.
|
47
|
+
|
48
|
+
=== SLF4J License
|
49
|
+
|
50
|
+
Copyright (c) 2004-2008 QOS.ch
|
51
|
+
All rights reserved.
|
52
|
+
|
53
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
54
|
+
a copy of this software and associated documentation files (the
|
55
|
+
"Software"), to deal in the Software without restriction, including
|
56
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
57
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
58
|
+
permit persons to whom the Software is furnished to do so, subject to
|
59
|
+
the following conditions:
|
60
|
+
|
61
|
+
The above copyright notice and this permission notice shall be
|
62
|
+
included in all copies or substantial portions of the Software.
|
63
|
+
|
64
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
65
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
66
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
67
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
68
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
69
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
70
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
71
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#--
|
3
|
+
# Copyright (C) 2008 David Kellum
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person
|
6
|
+
# obtaining a copy of this software and associated documentation files
|
7
|
+
# (the "Software"), to deal in the Software without restriction,
|
8
|
+
# including without limitation the rights to use, copy, modify, merge,
|
9
|
+
# publish, distribute, sublicense, and/or sell copies of the Software,
|
10
|
+
# and to permit persons to whom the Software is furnished to do so,
|
11
|
+
# subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
20
|
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
21
|
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
22
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
# SOFTWARE.
|
24
|
+
#++
|
25
|
+
|
26
|
+
require 'rubygems'
|
27
|
+
require 'hoe'
|
28
|
+
|
29
|
+
$LOAD_PATH << './lib'
|
30
|
+
|
31
|
+
ENV['NODOT'] = "no thank you"
|
32
|
+
|
33
|
+
# Instead of 'slf4j' to avoid loading slf4j-api in Rake parent loader
|
34
|
+
require 'slf4j/base'
|
35
|
+
SLF4J = SLF4JBase
|
36
|
+
|
37
|
+
loaders = SLF4J::ADAPTERS.flatten.compact
|
38
|
+
loader_files = loaders.map { |adp| "lib/slf4j/#{adp}.rb" }
|
39
|
+
|
40
|
+
jars = [ 'slf4j-api' ]
|
41
|
+
jars += SLF4J::ADAPTERS.map { |i,o| [ i, "slf4j-#{o}" ] }.flatten.compact
|
42
|
+
jars.map! { |n| "#{n}-#{SLF4J::SLF4J_VERSION}.jar" }
|
43
|
+
|
44
|
+
jar_files = jars.map { |jar| "lib/slf4j/#{jar}" }
|
45
|
+
|
46
|
+
desc "Update the Manifest with actual jars/loaders"
|
47
|
+
task :manifest do
|
48
|
+
out = File.new( 'Manifest.txt', 'w' )
|
49
|
+
begin
|
50
|
+
out.write <<END
|
51
|
+
Manifest.txt
|
52
|
+
README.txt
|
53
|
+
History.txt
|
54
|
+
Rakefile
|
55
|
+
pom.xml
|
56
|
+
assembly.xml
|
57
|
+
lib/slf4j.rb
|
58
|
+
lib/slf4j/base.rb
|
59
|
+
test/test_slf4j.rb
|
60
|
+
END
|
61
|
+
out.puts loader_files
|
62
|
+
out.puts jar_files
|
63
|
+
ensure
|
64
|
+
out.close
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
loaders.each do |adapter|
|
69
|
+
file "lib/slf4j/#{adapter}.rb" do
|
70
|
+
out = File.new( "lib/slf4j/#{adapter}.rb", 'w' )
|
71
|
+
begin
|
72
|
+
out.puts "SLF4J.require_adapter( '#{adapter}' )"
|
73
|
+
ensure
|
74
|
+
out.close
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
ASSEMBLY = "target/slf4j-assembly-1.0-bin.dir"
|
80
|
+
|
81
|
+
file ASSEMBLY => [ 'pom.xml', 'assembly.xml' ] do
|
82
|
+
sh( 'mvn package' )
|
83
|
+
end
|
84
|
+
|
85
|
+
jars.each do |jar|
|
86
|
+
file "lib/slf4j/#{jar}" => [ ASSEMBLY ] do
|
87
|
+
cp_r( File.join( ASSEMBLY, jar ), 'lib/slf4j' )
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
[ :gem, :test ].each { |t| task t => ( jar_files + loader_files ) }
|
92
|
+
|
93
|
+
task :mvn_clean do
|
94
|
+
rm_f( jar_files )
|
95
|
+
rm_f( loader_files )
|
96
|
+
sh( 'mvn clean' )
|
97
|
+
end
|
98
|
+
task :clean => :mvn_clean
|
99
|
+
|
100
|
+
hoe = Hoe.new( "slf4j", SLF4J::VERSION ) do |p|
|
101
|
+
p.developer( "David Kellum", "dek-ruby@gravitext.com" )
|
102
|
+
p.rubyforge_name = "rjack"
|
103
|
+
end
|
data/assembly.xml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
<assembly>
|
2
|
+
<id>bin</id>
|
3
|
+
<formats>
|
4
|
+
<format>dir</format>
|
5
|
+
</formats>
|
6
|
+
<includeBaseDirectory>false</includeBaseDirectory>
|
7
|
+
<dependencySets>
|
8
|
+
<dependencySet>
|
9
|
+
<includes>
|
10
|
+
<include>org.slf4j:slf4j-api</include>
|
11
|
+
<include>org.slf4j:jcl-over-slf4j</include>
|
12
|
+
<include>org.slf4j:jul-to-slf4j</include>
|
13
|
+
<include>org.slf4j:log4j-over-slf4j</include>
|
14
|
+
<include>org.slf4j:slf4j-jcl</include>
|
15
|
+
<include>org.slf4j:slf4j-jdk14</include>
|
16
|
+
<include>org.slf4j:slf4j-log4j12</include>
|
17
|
+
<include>org.slf4j:slf4j-nop</include>
|
18
|
+
<include>org.slf4j:slf4j-simple</include>
|
19
|
+
</includes>
|
20
|
+
</dependencySet>
|
21
|
+
|
22
|
+
</dependencySets>
|
23
|
+
|
24
|
+
</assembly>
|
data/lib/slf4j.rb
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (C) 2008 David Kellum
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation files
|
6
|
+
# (the "Software"), to deal in the Software without restriction,
|
7
|
+
# including without limitation the rights to use, copy, modify, merge,
|
8
|
+
# publish, distribute, sublicense, and/or sell copies of the Software,
|
9
|
+
# and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
19
|
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
20
|
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
21
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
require 'slf4j/base'
|
26
|
+
require 'java'
|
27
|
+
|
28
|
+
# Wrapper and core Logger compatible adapter for the
|
29
|
+
# SLF4J[http://www.slf4j.org/] logging interface.
|
30
|
+
#
|
31
|
+
# == Usage
|
32
|
+
#
|
33
|
+
# require 'slf4j'
|
34
|
+
#
|
35
|
+
# log = SLF4J[ "my.app.logger" ]
|
36
|
+
# log.info "Hello World!"
|
37
|
+
#
|
38
|
+
# == Adapters
|
39
|
+
#
|
40
|
+
# All of the following output adapters are available via +require+:
|
41
|
+
#
|
42
|
+
# require 'slf4j/jcl' # Output to Jakarta Commons Logging
|
43
|
+
# require 'slf4j/jdk14' # JDK java.util.logging
|
44
|
+
# require 'slf4j/log4j12' # Log4j (provided elsewhere)
|
45
|
+
# require 'slf4j/nop' # NOP null logger (provided)
|
46
|
+
# require 'slf4j/simple' # Simple logger (provided)
|
47
|
+
#
|
48
|
+
# The first loaded output adapter wins (as with mulitple adapters on
|
49
|
+
# the classpath). A warning will be logged to "slf4j" if an attempt is
|
50
|
+
# made to require a second output adapter.
|
51
|
+
#
|
52
|
+
# And the following input adapters will intercept JCL,
|
53
|
+
# java.util.logging (jdk14), or log4j log output and direct it through
|
54
|
+
# SLF4J:
|
55
|
+
#
|
56
|
+
# require 'slf4j/jcl-over-slf4j' # Route Jakarta Commons Logging to SLF4J
|
57
|
+
# require 'slf4j/jul-to-slf4j' # JDK java.util.logging to SLF4J
|
58
|
+
# require 'slf4j/log4j-over-slf4j' # Log4j to SLF4J
|
59
|
+
#
|
60
|
+
# Multiple input adapters may be require'd. However, a RuntimeError
|
61
|
+
# will be raised in the attempt to require both an output adapter and
|
62
|
+
# input adapter from/to the same interface, for example
|
63
|
+
# 'slf4j/jcl-over-slf4j' and 'slf4j/jcl', which would otherwise cause
|
64
|
+
# a circular logging loop (and stack overflow.)
|
65
|
+
#
|
66
|
+
# Adapter names match the corresponding SLF4J jars.
|
67
|
+
#
|
68
|
+
module SLF4J
|
69
|
+
include SLF4JBase
|
70
|
+
|
71
|
+
# Require an adapter by name (add the jar to classpath)
|
72
|
+
# This is normally done via require 'slf4j/_name_'
|
73
|
+
def self.require_adapter( name )
|
74
|
+
row = ADAPTERS.assoc( name )
|
75
|
+
if row
|
76
|
+
name,ban = row
|
77
|
+
output = false
|
78
|
+
else
|
79
|
+
row = ADAPTERS.rassoc( name )
|
80
|
+
ban,name = row
|
81
|
+
output = true
|
82
|
+
end
|
83
|
+
|
84
|
+
if @@loaded[ ban ]
|
85
|
+
raise "Illegal attempt to load '#{name}' when '#{ban}' is loaded."
|
86
|
+
end
|
87
|
+
|
88
|
+
if output
|
89
|
+
if ! @@output_name.nil? && name != @@output_name
|
90
|
+
logger("slf4j").warn do
|
91
|
+
"Ignoring attempt to load #{name} after #{@@output_name} already loaded."
|
92
|
+
end
|
93
|
+
return
|
94
|
+
end
|
95
|
+
if java.lang.Thread::current_thread.context_class_loader != @@api_loader
|
96
|
+
$stderr.puts( "WARNING: Attempting to load #{name} in child class" +
|
97
|
+
" loader of slf4j-api.jar loader." )
|
98
|
+
end
|
99
|
+
require_jar( 'slf4j-' + name )
|
100
|
+
@@output_name = name
|
101
|
+
else
|
102
|
+
require_jar( name )
|
103
|
+
end
|
104
|
+
|
105
|
+
# Special case, requires explicit 'install'
|
106
|
+
if name == 'jul-to-slf4j'
|
107
|
+
org.slf4j.bridge.SLF4JBridgeHandler.install
|
108
|
+
end
|
109
|
+
|
110
|
+
@@loaded[ name ] = true
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.require_jar( name ) # :nodoc:
|
114
|
+
require File.join( SLF4J_DIR, "#{name}-#{ SLF4J_VERSION }.jar" )
|
115
|
+
end
|
116
|
+
|
117
|
+
require_jar 'slf4j-api'
|
118
|
+
|
119
|
+
@@api_loader = org.slf4j.ILoggerFactory.java_class.class_loader
|
120
|
+
@@loaded = {}
|
121
|
+
@@output_name = nil
|
122
|
+
|
123
|
+
# Output adapter name if one has been added, or nil.
|
124
|
+
def self.output_name
|
125
|
+
@@output_name
|
126
|
+
end
|
127
|
+
|
128
|
+
# SLF4J severity levels
|
129
|
+
LEVELS = %w{ trace debug info warn error }
|
130
|
+
|
131
|
+
# Logger compatible facade over org.slf4j.Logger
|
132
|
+
#
|
133
|
+
# === Generated Methods
|
134
|
+
#
|
135
|
+
# Corresponding methods are generated for each of the SLF4J levels:
|
136
|
+
#
|
137
|
+
# * trace
|
138
|
+
# * debug
|
139
|
+
# * info
|
140
|
+
# * warn
|
141
|
+
# * error
|
142
|
+
# * fatal (alias to error)
|
143
|
+
#
|
144
|
+
# These have the form (using _info_ as example)
|
145
|
+
#
|
146
|
+
# log = Logger.new( "name" )
|
147
|
+
# log.info? # Is this level enabled for logging?
|
148
|
+
# log.info( "message" ) # Log message
|
149
|
+
# log.info { "message" } # Execute block if enabled
|
150
|
+
# and log returned value
|
151
|
+
class Logger
|
152
|
+
attr_reader :name
|
153
|
+
|
154
|
+
# Create new or find existing Logger by name
|
155
|
+
#
|
156
|
+
# Note that loggers are arranged in a hiearchy by dot '.' name
|
157
|
+
# notation, i.e.:
|
158
|
+
#
|
159
|
+
# * "parent"
|
160
|
+
# * "parent.child"
|
161
|
+
def initialize( name )
|
162
|
+
@name = name
|
163
|
+
@logger = org.slf4j.LoggerFactory.getLogger( @name )
|
164
|
+
end
|
165
|
+
|
166
|
+
# Define logging methods for each level: debug(), error(), etc.
|
167
|
+
LEVELS.each do |lvl|
|
168
|
+
module_eval( %Q{
|
169
|
+
|
170
|
+
def #{lvl}?
|
171
|
+
@logger.is#{lvl.capitalize}Enabled
|
172
|
+
end
|
173
|
+
|
174
|
+
def #{lvl}( msg=nil )
|
175
|
+
msg = yield if ( block_given? && #{lvl}? )
|
176
|
+
@logger.#{lvl}( msg.to_s ) unless msg.nil?
|
177
|
+
end
|
178
|
+
|
179
|
+
} )
|
180
|
+
end
|
181
|
+
|
182
|
+
# Alias fatal to error for Logger compatibility
|
183
|
+
alias_method :fatal, :error
|
184
|
+
alias_method :fatal?, :error?
|
185
|
+
end
|
186
|
+
|
187
|
+
# Get Logger by name
|
188
|
+
def logger( name = self.class.name )
|
189
|
+
Logger.new( name )
|
190
|
+
end
|
191
|
+
module_function :logger
|
192
|
+
|
193
|
+
# Synonym for logger( name )
|
194
|
+
def self.[]( name )
|
195
|
+
Logger.new( name )
|
196
|
+
end
|
197
|
+
|
198
|
+
# The ILoggerFactory instance if an output adapter jas been loaded
|
199
|
+
def self.linked_factory
|
200
|
+
org.slf4j.LoggerFactory.getILoggerFactory
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
data/lib/slf4j/base.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (C) 2008 David Kellum
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person
|
5
|
+
# obtaining a copy of this software and associated documentation files
|
6
|
+
# (the "Software"), to deal in the Software without restriction,
|
7
|
+
# including without limitation the rights to use, copy, modify, merge,
|
8
|
+
# publish, distribute, sublicense, and/or sell copies of the Software,
|
9
|
+
# and to permit persons to whom the Software is furnished to do so,
|
10
|
+
# subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
19
|
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
20
|
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
21
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
# SOFTWARE.
|
23
|
+
#++
|
24
|
+
|
25
|
+
# Base constants for Rakefile, etc.
|
26
|
+
module SLF4JBase
|
27
|
+
|
28
|
+
# SLF4J-java version
|
29
|
+
SLF4J_VERSION = '1.5.3'
|
30
|
+
# SLF4J gem version
|
31
|
+
VERSION = SLF4J_VERSION + '.1'
|
32
|
+
|
33
|
+
SLF4J_DIR = File.dirname(__FILE__) # :nodoc:
|
34
|
+
|
35
|
+
# :input :output (jar with slf4j- prefix)
|
36
|
+
ADAPTERS = [ [ "jul-to-slf4j", "jdk14" ],
|
37
|
+
[ "jcl-over-slf4j", "jcl" ],
|
38
|
+
[ "log4j-over-slf4j", "log4j12" ],
|
39
|
+
[ nil, "nop" ],
|
40
|
+
[ nil, "simple" ] ] # :nodoc:
|
41
|
+
end
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
SLF4J.require_adapter( 'jcl-over-slf4j' )
|
data/lib/slf4j/jcl.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SLF4J.require_adapter( 'jcl' )
|
data/lib/slf4j/jdk14.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SLF4J.require_adapter( 'jdk14' )
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
SLF4J.require_adapter( 'jul-to-slf4j' )
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
SLF4J.require_adapter( 'log4j-over-slf4j' )
|
@@ -0,0 +1 @@
|
|
1
|
+
SLF4J.require_adapter( 'log4j12' )
|
data/lib/slf4j/nop.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SLF4J.require_adapter( 'nop' )
|
data/lib/slf4j/simple.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SLF4J.require_adapter( 'simple' )
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/pom.xml
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
2
|
+
|
3
|
+
<modelVersion>4.0.0</modelVersion>
|
4
|
+
<groupId>com.gravitext</groupId>
|
5
|
+
<artifactId>slf4j-assembly</artifactId>
|
6
|
+
<packaging>pom</packaging>
|
7
|
+
<version>1.0</version>
|
8
|
+
<name>SLF4J assembly</name>
|
9
|
+
|
10
|
+
<dependencies>
|
11
|
+
|
12
|
+
<dependency>
|
13
|
+
<groupId>org.slf4j</groupId>
|
14
|
+
<artifactId>slf4j-api</artifactId>
|
15
|
+
<version>1.5.3</version>
|
16
|
+
</dependency>
|
17
|
+
|
18
|
+
<dependency>
|
19
|
+
<groupId>org.slf4j</groupId>
|
20
|
+
<artifactId>jcl-over-slf4j</artifactId> <!-- vs jcl104? -->
|
21
|
+
<version>1.5.3</version>
|
22
|
+
<scope>runtime</scope>
|
23
|
+
</dependency>
|
24
|
+
|
25
|
+
<dependency>
|
26
|
+
<groupId>org.slf4j</groupId>
|
27
|
+
<artifactId>jul-to-slf4j</artifactId>
|
28
|
+
<version>1.5.3</version>
|
29
|
+
<scope>runtime</scope>
|
30
|
+
</dependency>
|
31
|
+
|
32
|
+
<dependency>
|
33
|
+
<groupId>org.slf4j</groupId>
|
34
|
+
<artifactId>log4j-over-slf4j</artifactId>
|
35
|
+
<version>1.5.3</version>
|
36
|
+
<scope>runtime</scope>
|
37
|
+
</dependency>
|
38
|
+
|
39
|
+
<dependency>
|
40
|
+
<groupId>org.slf4j</groupId>
|
41
|
+
<artifactId>slf4j-jdk14</artifactId>
|
42
|
+
<version>1.5.3</version>
|
43
|
+
<scope>runtime</scope>
|
44
|
+
<optional>true</optional>
|
45
|
+
</dependency>
|
46
|
+
|
47
|
+
<dependency>
|
48
|
+
<groupId>org.slf4j</groupId>
|
49
|
+
<artifactId>slf4j-log4j12</artifactId>
|
50
|
+
<version>1.5.3</version>
|
51
|
+
<scope>runtime</scope>
|
52
|
+
<optional>true</optional>
|
53
|
+
</dependency>
|
54
|
+
|
55
|
+
<dependency>
|
56
|
+
<groupId>org.slf4j</groupId>
|
57
|
+
<artifactId>slf4j-jcl</artifactId>
|
58
|
+
<version>1.5.3</version>
|
59
|
+
<scope>runtime</scope>
|
60
|
+
<optional>true</optional>
|
61
|
+
</dependency>
|
62
|
+
|
63
|
+
<dependency>
|
64
|
+
<groupId>org.slf4j</groupId>
|
65
|
+
<artifactId>slf4j-simple</artifactId>
|
66
|
+
<version>1.5.3</version>
|
67
|
+
<scope>runtime</scope>
|
68
|
+
<optional>true</optional>
|
69
|
+
</dependency>
|
70
|
+
|
71
|
+
<dependency>
|
72
|
+
<groupId>org.slf4j</groupId>
|
73
|
+
<artifactId>slf4j-nop</artifactId>
|
74
|
+
<version>1.5.3</version>
|
75
|
+
<scope>runtime</scope>
|
76
|
+
<optional>true</optional>
|
77
|
+
</dependency>
|
78
|
+
|
79
|
+
</dependencies>
|
80
|
+
|
81
|
+
<build>
|
82
|
+
<plugins>
|
83
|
+
<plugin>
|
84
|
+
<artifactId>maven-assembly-plugin</artifactId>
|
85
|
+
<configuration>
|
86
|
+
<descriptors>
|
87
|
+
<descriptor>assembly.xml</descriptor>
|
88
|
+
</descriptors>
|
89
|
+
<tarLongFileMode>gnu</tarLongFileMode>
|
90
|
+
</configuration>
|
91
|
+
<executions>
|
92
|
+
<execution>
|
93
|
+
<id>assembly</id>
|
94
|
+
<phase>package</phase>
|
95
|
+
<goals>
|
96
|
+
<goal>attached</goal>
|
97
|
+
</goals>
|
98
|
+
</execution>
|
99
|
+
</executions>
|
100
|
+
</plugin>
|
101
|
+
</plugins>
|
102
|
+
</build>
|
103
|
+
|
104
|
+
</project>
|
data/test/test_slf4j.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
#!/usr/bin/env jruby
|
2
|
+
#--
|
3
|
+
# Copyright (c) 2008 David Kellum
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person
|
6
|
+
# obtaining a copy of this software and associated documentation files
|
7
|
+
# (the "Software"), to deal in the Software without restriction,
|
8
|
+
# including without limitation the rights to use, copy, modify, merge,
|
9
|
+
# publish, distribute, sublicense, and/or sell copies of the Software,
|
10
|
+
# and to permit persons to whom the Software is furnished to do so,
|
11
|
+
# subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
20
|
+
# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
21
|
+
# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
22
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
# SOFTWARE.
|
24
|
+
#++
|
25
|
+
|
26
|
+
$LOAD_PATH.unshift File.join( File.dirname(__FILE__), "..", "lib" )
|
27
|
+
|
28
|
+
require 'slf4j'
|
29
|
+
|
30
|
+
# Load jdk14 implementation for testing
|
31
|
+
require 'slf4j/jdk14'
|
32
|
+
|
33
|
+
# Load these only to confirm loading works
|
34
|
+
require 'slf4j/jcl-over-slf4j'
|
35
|
+
require 'slf4j/log4j-over-slf4j'
|
36
|
+
|
37
|
+
require 'test/unit'
|
38
|
+
|
39
|
+
class TestHandler < java.util.logging.Handler
|
40
|
+
attr_accessor :count, :last
|
41
|
+
|
42
|
+
def initialize
|
43
|
+
reset
|
44
|
+
end
|
45
|
+
|
46
|
+
def flush; end
|
47
|
+
def close; end
|
48
|
+
|
49
|
+
def publish( record )
|
50
|
+
@count += 1
|
51
|
+
@last = record
|
52
|
+
end
|
53
|
+
|
54
|
+
def reset
|
55
|
+
@count = 0
|
56
|
+
@last = nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class TestSlf4j < Test::Unit::TestCase
|
61
|
+
JdkLogger = java.util.logging.Logger
|
62
|
+
def setup
|
63
|
+
@handler = TestHandler.new
|
64
|
+
@jdk_logger = JdkLogger.getLogger ""
|
65
|
+
@jdk_logger.addHandler @handler
|
66
|
+
@jdk_logger.level = java.util.logging.Level::INFO
|
67
|
+
@log = SLF4J[ "my.app" ]
|
68
|
+
end
|
69
|
+
|
70
|
+
def teardown
|
71
|
+
@handler.reset
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_logger
|
75
|
+
assert !@log.trace?
|
76
|
+
@log.trace( "not written" )
|
77
|
+
assert !@log.debug?
|
78
|
+
@log.debug { "also not written" }
|
79
|
+
assert @log.info?
|
80
|
+
@log.info { "test write info" }
|
81
|
+
assert @log.warn?
|
82
|
+
@log.warn { "test write warning" }
|
83
|
+
assert @log.error?
|
84
|
+
@log.error( "test write error" )
|
85
|
+
assert @log.fatal?
|
86
|
+
@log.fatal { "test write fatal --> error" }
|
87
|
+
assert_equal( 4, @handler.count )
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_circular_ban
|
91
|
+
assert_raise( RuntimeError ) do
|
92
|
+
require 'slf4j/jul-to-slf4j'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
3
|
+
requirements:
|
4
|
+
- - '>='
|
5
|
+
- !ruby/object:Gem::Version
|
6
|
+
version: "0"
|
7
|
+
version:
|
8
|
+
email:
|
9
|
+
- dek-ruby@gravitext.com
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
summary: A JRuby adaption and gem packaging of the {Simple Logging Facade for Java}[http://www.slf4j.org/]
|
13
|
+
post_install_message:
|
14
|
+
extra_rdoc_files:
|
15
|
+
- Manifest.txt
|
16
|
+
- README.txt
|
17
|
+
- History.txt
|
18
|
+
homepage: http://rjack.rubyforge.org
|
19
|
+
signing_key:
|
20
|
+
name: slf4j
|
21
|
+
rdoc_options:
|
22
|
+
- --main
|
23
|
+
- README.txt
|
24
|
+
autorequire:
|
25
|
+
rubyforge_project: rjack
|
26
|
+
executables: []
|
27
|
+
|
28
|
+
description: A JRuby adaption and gem packaging of the {Simple Logging Facade for
|
29
|
+
Java}[http://www.slf4j.org/]. Provides all jar dependencies and a Ruby Logger
|
30
|
+
compatible facade. SLF4J is a java logging abstraction and set of adapters to various
|
31
|
+
concrete logging implementations and legacy logging APIs. The slf4j gem adds a
|
32
|
+
ruby core Logger compatible facade to SLF4J, and makes any needed adapters available
|
33
|
+
to JRuby applications. This makes it possible to unify and control logging output
|
34
|
+
of both java and ruby components in a JRuby application.
|
35
|
+
specification_version: 2
|
36
|
+
default_executable:
|
37
|
+
files:
|
38
|
+
- Manifest.txt
|
39
|
+
- README.txt
|
40
|
+
- History.txt
|
41
|
+
- Rakefile
|
42
|
+
- pom.xml
|
43
|
+
- assembly.xml
|
44
|
+
- lib/slf4j.rb
|
45
|
+
- lib/slf4j/base.rb
|
46
|
+
- test/test_slf4j.rb
|
47
|
+
- lib/slf4j/jul-to-slf4j.rb
|
48
|
+
- lib/slf4j/jdk14.rb
|
49
|
+
- lib/slf4j/jcl-over-slf4j.rb
|
50
|
+
- lib/slf4j/jcl.rb
|
51
|
+
- lib/slf4j/log4j-over-slf4j.rb
|
52
|
+
- lib/slf4j/log4j12.rb
|
53
|
+
- lib/slf4j/nop.rb
|
54
|
+
- lib/slf4j/simple.rb
|
55
|
+
- lib/slf4j/slf4j-api-1.5.3.jar
|
56
|
+
- lib/slf4j/jul-to-slf4j-1.5.3.jar
|
57
|
+
- lib/slf4j/slf4j-jdk14-1.5.3.jar
|
58
|
+
- lib/slf4j/jcl-over-slf4j-1.5.3.jar
|
59
|
+
- lib/slf4j/slf4j-jcl-1.5.3.jar
|
60
|
+
- lib/slf4j/log4j-over-slf4j-1.5.3.jar
|
61
|
+
- lib/slf4j/slf4j-log4j12-1.5.3.jar
|
62
|
+
- lib/slf4j/slf4j-nop-1.5.3.jar
|
63
|
+
- lib/slf4j/slf4j-simple-1.5.3.jar
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
extensions: []
|
71
|
+
|
72
|
+
rubygems_version: 1.2.0
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
authors:
|
76
|
+
- David Kellum
|
77
|
+
date: 2008-10-13 08:00:00 +00:00
|
78
|
+
platform: ruby
|
79
|
+
test_files:
|
80
|
+
- test/test_slf4j.rb
|
81
|
+
version: !ruby/object:Gem::Version
|
82
|
+
version: 1.5.3.1
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
dependencies:
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 1.8.0
|
92
|
+
version:
|
93
|
+
type: :development
|
94
|
+
version_requirement:
|
95
|
+
name: hoe
|
96
|
+
bindir: bin
|
97
|
+
has_rdoc: true
|