log4jruby 3.0.0.rc2-java → 3.0.0.rc3-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
  SHA256:
3
- metadata.gz: a1668efce6b23c33b459992956795614d50f3178ed3c2787e7651f1715b60235
4
- data.tar.gz: ba8e28cc7b8dbc9531ccec0cb34b7642ab8beacc37eee8be0cd7df2abb5f661e
3
+ metadata.gz: f490ce9d3d34da275ebe45ea7f79fcb059bd1eb65382b7caad07ac56cff39319
4
+ data.tar.gz: 52f088f32e0ed016a29d0b1aad801980eff8998823f364b48046dab02c732ecb
5
5
  SHA512:
6
- metadata.gz: 36c6cbd7bae1b08f33156a3ef73b3e93f00a174bc0e32b2949b5cfff6424a81c3ac12a766a889f618f308fc55fd4f942b3778f4129b3739c4140a4170c4e23a4
7
- data.tar.gz: 1763996d46b5e5836c911c6061068245464a952c59ba94f890549ea56bf19b97b322a1112471ecb00e21bffc410c78b0e34e2073c0cbbec2ba53ec629ade2310
6
+ metadata.gz: 60f2e59dc9dde9a1ae8b802dc76ac7ecf41498abcea404d2747c9fb189091f4ef8ef5d2ac05bafbe8170620bf1f273d431e80467bab38a57802ee0e72a46ff32
7
+ data.tar.gz: 0c4d4826ee902621b4f4b0847974b5403dba21d2e0c8fc63d8f3a253d64c3d6f981d2c38378b6b9780e9aae36a8cdc650145bfb2594ac38afa67e6a70302717e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # log4jruby Changelog
2
2
 
3
+ ## v3.0.0.rc3
4
+
5
+ * Resolve [missing backtraces with Rails](https://github.com/lenny/log4jruby/issues/27). Stringify
6
+ exceptions outside of the formatter because `ActiveSupport::TaggedLogging` broke
7
+ the `LegacyShimFormatter`. The `LegacyShimFormatter` was formerly responsible for outputing
8
+ backtraces in JRuby < 9.3
9
+ * Optimizations to `Log4jruby::Support::JrubyVersion`
10
+
3
11
  ## v3.0.0.rc2
4
12
 
5
13
  * Restored support for JRuby 9.1.x/Ruby 2.3
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'logger'
4
+
3
5
  require 'log4jruby/support/log4j_args'
4
6
  require 'log4jruby/support/levels'
5
7
  require 'log4jruby/support/location'
6
8
  require 'log4jruby/support/log_manager'
7
9
  require 'log4jruby/support/formatter'
8
- require 'log4jruby/support/legacy_shim_formatter'
9
10
  require 'log4jruby/support/jruby_version'
10
-
11
- require 'logger'
11
+ require 'log4jruby/support/ruby_backtrace_shim'
12
12
 
13
13
  module Log4jruby
14
14
  # Author:: Lenny Marks
@@ -125,7 +125,7 @@ module Log4jruby
125
125
  return @formatter if defined?(@formatter)
126
126
 
127
127
  @formatter = if self == Logger.root
128
- new_default_formatter
128
+ Support::Formatter.new
129
129
  else
130
130
  parent.formatter
131
131
  end
@@ -160,6 +160,9 @@ module Log4jruby
160
160
 
161
161
  def send_to_log4j(level, object, &block)
162
162
  progname, msg, throwable = Support::Log4jArgs.convert(object, &block)
163
+ unless Support::JrubyVersion.native_ruby_stacktraces_supported?
164
+ msg = Support::RubyBacktraceShim.adapt(msg)
165
+ end
163
166
  if (f = formatter)
164
167
  msg = f.call(level, Time.now, progname, msg)
165
168
  end
@@ -171,13 +174,5 @@ module Log4jruby
171
174
  @log4j_logger.send(level, msg, throwable)
172
175
  end
173
176
  end
174
-
175
- def new_default_formatter
176
- if Support::JrubyVersion.native_ruby_stacktraces_supported?
177
- Support::Formatter.new
178
- else
179
- Support::LegacyShimFormatter.new
180
- end
181
- end
182
177
  end
183
178
  end
@@ -6,10 +6,21 @@ module Log4jruby
6
6
  # Find consumers and remove this and references when no longer needed.
7
7
  class JrubyVersion
8
8
  class << self
9
+ attr_reader :native_ruby_stacktraces_supported
10
+
9
11
  def native_ruby_stacktraces_supported?
10
- Gem::Version.new(JRUBY_VERSION) >= Gem::Version.new('9.3')
12
+ @native_ruby_stacktraces_supported
13
+ end
14
+
15
+ private
16
+
17
+ def init
18
+ @native_ruby_stacktraces_supported =
19
+ Gem::Version.new(JRUBY_VERSION) >= Gem::Version.new('9.3')
11
20
  end
12
21
  end
13
22
  end
14
23
  end
15
24
  end
25
+
26
+ Log4jruby::Support::JrubyVersion.send(:init)
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Log4jruby
4
+ module Support
5
+ # Transform exceptions into string with full backtraces and nested causes.
6
+ module RubyBacktraceShim
7
+ class << self
8
+ def adapt(msg)
9
+ return msg unless msg.is_a?(::Exception)
10
+
11
+ exception2str(msg)
12
+ end
13
+
14
+ private
15
+
16
+ def exception2str(exception)
17
+ "#{exception.message} (#{exception.class})\n\t#{exception.backtrace&.join("\n\t")}" \
18
+ "#{"\nCaused by: #{exception2str(exception.cause)}" if exception.cause}"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Log4jruby
4
- VERSION = '3.0.0.rc2'
4
+ VERSION = '3.0.0.rc3'
5
5
  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: 3.0.0.rc2
4
+ version: 3.0.0.rc3
5
5
  platform: java
6
6
  authors:
7
7
  - Lenny Marks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-12 00:00:00.000000000 Z
11
+ date: 2022-10-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby Logger using Log4j, geared toward those who use JRuby to write Ruby
14
14
  code using/extending Java code. Ruby and Java are configured together using traditional
@@ -26,11 +26,11 @@ files:
26
26
  - lib/log4jruby/logger_for_class.rb
27
27
  - lib/log4jruby/support/formatter.rb
28
28
  - lib/log4jruby/support/jruby_version.rb
29
- - lib/log4jruby/support/legacy_shim_formatter.rb
30
29
  - lib/log4jruby/support/levels.rb
31
30
  - lib/log4jruby/support/location.rb
32
31
  - lib/log4jruby/support/log4j_args.rb
33
32
  - lib/log4jruby/support/log_manager.rb
33
+ - lib/log4jruby/support/ruby_backtrace_shim.rb
34
34
  - lib/log4jruby/version.rb
35
35
  homepage: https://github.com/lenny/log4jruby
36
36
  licenses:
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Log4jruby
4
- module Support
5
- # Default ruby Logger formatter for Jruby < 9.3.x
6
- # This formatter mimics
7
- # [Logger::Formatter](https://ruby-doc.org/stdlib-2.6.4/libdoc/logger/rdoc/Logger/Formatter.html)
8
- # but excludes log level and timestamp (delegated to Log4j).
9
- # It also appends full backtraces with nested causes.
10
- class LegacyShimFormatter
11
- def call(_severity, _time, progname, msg)
12
- "-- #{msg2str(progname)}: #{msg2str(msg)}"
13
- end
14
-
15
- private
16
-
17
- def msg2str(msg)
18
- case msg
19
- when ::String
20
- msg
21
- when ::Exception
22
- exception2str(msg)
23
- else
24
- msg.inspect
25
- end
26
- end
27
-
28
- def exception2str(exception)
29
- "#{exception.message} (#{exception.class})\n\t#{exception.backtrace&.join("\n\t")}" \
30
- "#{"\nCaused by: #{exception2str(exception.cause)}" if exception.cause}"
31
- end
32
- end
33
- end
34
- end