Permalink
Browse files

better decision on which logger to use as default: ruby, slf4j, etc

  • Loading branch information...
1 parent 68d7962 commit 3a9343289a8edfe4d5ded0130e0200c9bdac4c3c @mkristian committed Jul 28, 2010
Showing with 12 additions and 1 deletion.
  1. +11 −0 lib/slf4r.rb
  2. +1 −1 lib/slf4r/version.rb
View
11 lib/slf4r.rb
@@ -1,6 +1,17 @@
require 'slf4r/logger'
begin
+ # make sure we have java
+ require 'java'
+ begin
+ # make sure we have SLF4J in the classloader
+ import 'org.slf4j.LoggerFactory'
+ rescue NameError
+ puts "no SLF4J found in classloader - using ruby logger"
+ require 'slf4r/ruby_logger'
+ end
require 'slf4r/java_logger'
+ puts "using slf4j logger"
rescue LoadError
+ puts "using ruby logger"
require 'slf4r/ruby_logger'
end
View
2 lib/slf4r/version.rb
@@ -1,3 +1,3 @@
module Slf4r
- VERSION = '0.3.2'
+ VERSION = '0.3.2'.freeze
end

0 comments on commit 3a93432

Please sign in to comment.