log4jruby 2.0.0.rc1-java → 2.0.0.rc2-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7f89b3af3a89c4ca208a322188f30046f5e402e
4
- data.tar.gz: 3dcd279c0ce788d02898707987eb4b14ec1a9826
3
+ metadata.gz: 697befc3d72d9240809724c8dcfc6024c0b0bf07
4
+ data.tar.gz: 3ed0bdba649f88a4d1c85ba3ce79a4c86349cb78
5
5
  SHA512:
6
- metadata.gz: f54a8f287e040444e357a2953b78af7ef75c2bba3fed5ab7745eb5c27cc3be297126d79227d35c00a7912bf88028cce0581645c9a776aaea7b12e0e625effbf8
7
- data.tar.gz: e183b855910b6dd860959c8abeb2a6ee743e038c9706876e94a5dace9a029f10f0371a968411763c81eda6e83b5419e07ad83abcbef42823b83ebda156704454
6
+ metadata.gz: 48084bb0a2d70263062a48bc611f84f8e906361411227eddd2172c015631bca6178c79f88771b0fc5d4441b0d55e713a4db1803412de1e393bd135b0f270474f
7
+ data.tar.gz: 79a4041e5123dc4a1dc189c438c150e12ea7f435104f6749c1e041a1f7c11f995bc18d905c065c1340507065e7d68d4d65830ce3842dfceeca7b3974138600d8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # log4jruby Changelog
2
2
 
3
+ ## v2.0.0.rc2
4
+
5
+ * Internal implementation changes - https://github.com/lenny/log4jruby/pull/8
6
+
3
7
  ## v2.0.0.rc1
4
8
 
5
9
  * ```Log4jruby::Rails``` has been removed - Rails apps seem better off configuring
data/lib/log4jruby.rb CHANGED
@@ -1,16 +1,16 @@
1
- require 'log4jruby/logger'
2
- require 'log4jruby/logger_for_class'
3
-
4
1
  module Log4jruby
5
2
  module Support
6
-
7
3
  end
8
4
  end
9
5
 
6
+ require 'log4jruby/support/bootstrap'
7
+ require 'log4jruby/logger'
8
+ require 'log4jruby/logger_for_class'
9
+
10
10
  Object.class_eval do
11
11
  class << self
12
12
  def enable_logger
13
13
  send(:include, Log4jruby::LoggerForClass)
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -31,7 +31,7 @@ module Log4jruby
31
31
  def[](name)
32
32
  name = name.nil? ? 'jruby' : "jruby.#{name.gsub('::', '.')}"
33
33
  log4j = Java::org.apache.log4j.Logger.getLogger(name)
34
- fetch_logger(log4j, new(log4j))
34
+ fetch_logger(log4j)
35
35
  end
36
36
 
37
37
  # same as [] but accepts attributes
@@ -44,21 +44,19 @@ module Log4jruby
44
44
  # Return root Logger(i.e. jruby)
45
45
  def root
46
46
  log4j = Java::org.apache.log4j.Logger.getLogger('jruby')
47
- fetch_logger(log4j, new(log4j))
47
+ fetch_logger(log4j)
48
48
  end
49
49
 
50
50
  def reset # :nodoc:
51
- init_store
51
+ Java::org.apache.log4j.LogManager.getCurrentLoggers.each do |l|
52
+ l.ruby_logger = nil
53
+ end
52
54
  end
53
55
 
54
56
  private
55
57
 
56
- def fetch_logger(log4j_logger, default)
57
- @logger_mapping.putIfAbsent(log4j_logger.getName, default) || @logger_mapping.get(log4j_logger.getName)
58
- end
59
-
60
- def init_store
61
- @logger_mapping = Java::java.util.concurrent.ConcurrentHashMap.new
58
+ def fetch_logger(log4j_logger)
59
+ Java::org.apache.log4j.Logger.getLogger(log4j_logger.getName).ruby_logger
62
60
  end
63
61
  end
64
62
 
@@ -171,7 +169,7 @@ module Log4jruby
171
169
  end
172
170
 
173
171
  def parent
174
- fetch_logger(log4j_logger.parent, Logger.root)
172
+ fetch_logger(log4j_logger.parent)
175
173
  end
176
174
 
177
175
  private
@@ -218,10 +216,9 @@ module Log4jruby
218
216
  Java::org.apache.log4j.MDC
219
217
  end
220
218
 
221
- def fetch_logger(log4j_logger, default)
222
- self.class.send(:fetch_logger, log4j_logger, default)
219
+ def fetch_logger(log4j_logger)
220
+ self.class.send(:fetch_logger, log4j_logger)
223
221
  end
224
222
  end
225
223
  end
226
224
 
227
- Log4jruby::Logger.send(:init_store) #Avoid lazy-initialization thread-safety issues on logger_mapping
@@ -0,0 +1,18 @@
1
+ require 'thread'
2
+
3
+ Java::org.apache.log4j.Logger.class_eval do
4
+ attr_accessor :ruby_logger
5
+ @ruby_logger_lock = Mutex.new
6
+
7
+ class << self
8
+ def ruby_logger_lock
9
+ @ruby_logger_lock
10
+ end
11
+ end
12
+
13
+ def ruby_logger
14
+ self.class.ruby_logger_lock.synchronize do
15
+ @ruby_logger ||= Log4jruby::Logger.new(self)
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Log4jruby
2
- VERSION = '2.0.0.rc1'
2
+ VERSION = '2.0.0.rc2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log4jruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc1
4
+ version: 2.0.0.rc2
5
5
  platform: java
6
6
  authors:
7
7
  - Lenny Marks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-30 00:00:00.000000000 Z
11
+ date: 2015-05-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby Logger using Log4j, geared toward those who use JRuby to write Ruby code using/extending Java code. Ruby and Java are configured together using traditional Log4j methods.
14
14
  email:
@@ -22,6 +22,7 @@ files:
22
22
  - lib/log4jruby.rb
23
23
  - lib/log4jruby/logger.rb
24
24
  - lib/log4jruby/logger_for_class.rb
25
+ - lib/log4jruby/support/bootstrap.rb
25
26
  - lib/log4jruby/support/log4j_args.rb
26
27
  - lib/log4jruby/version.rb
27
28
  homepage: https://github.com/lenny/log4jruby