log4jruby 3.0.0.rc1-java → 3.0.0.rc3-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +4 -0
- data/lib/log4jruby/logger.rb +9 -2
- data/lib/log4jruby/support/formatter.rb +15 -0
- data/lib/log4jruby/support/jruby_version.rb +26 -0
- data/lib/log4jruby/support/log4j_args.rb +6 -1
- data/lib/log4jruby/support/log_manager.rb +1 -1
- data/lib/log4jruby/support/ruby_backtrace_shim.rb +23 -0
- data/lib/log4jruby/version.rb +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f490ce9d3d34da275ebe45ea7f79fcb059bd1eb65382b7caad07ac56cff39319
|
4
|
+
data.tar.gz: 52f088f32e0ed016a29d0b1aad801980eff8998823f364b48046dab02c732ecb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60f2e59dc9dde9a1ae8b802dc76ac7ecf41498abcea404d2747c9fb189091f4ef8ef5d2ac05bafbe8170620bf1f273d431e80467bab38a57802ee0e72a46ff32
|
7
|
+
data.tar.gz: 0c4d4826ee902621b4f4b0847974b5403dba21d2e0c8fc63d8f3a253d64c3d6f981d2c38378b6b9780e9aae36a8cdc650145bfb2594ac38afa67e6a70302717e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
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
|
+
|
11
|
+
## v3.0.0.rc2
|
12
|
+
|
13
|
+
* Restored support for JRuby 9.1.x/Ruby 2.3
|
14
|
+
|
3
15
|
## v3.0.0.rc1
|
4
16
|
|
5
17
|
* JRuby 9.3.x/Ruby 2.6 support - Ruby >= 2.6.8 now required
|
data/README.md
CHANGED
@@ -151,6 +151,10 @@ The default Log4jruby formatter outputs `progname` and `msg` only (as opposed to
|
|
151
151
|
Severity, timestamp, and backtraces are handed according to your `Log4j` configuration.
|
152
152
|
E.g. [PatternLayout](https://logging.apache.org/log4j/2.x/manual/layouts.html).
|
153
153
|
|
154
|
+
* For JRuby versions < 9.3, Ruby exceptions are not passed directly to the `Throwable` arg of log4j. Instead,
|
155
|
+
backtraces are included in the log message by the default formatter. This means that `%throwable` in
|
156
|
+
the log4j config will not affect ruby exceptions for Jruby < 9.3.
|
157
|
+
|
154
158
|
The output of the `formatter` is passed as the `message` parameter of the [Log4j log methods](https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Category.html#log(org.apache.log4j.Priority,%20java.lang.Object).
|
155
159
|
|
156
160
|
## Development
|
data/lib/log4jruby/logger.rb
CHANGED
@@ -1,10 +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
|
-
require '
|
9
|
+
require 'log4jruby/support/formatter'
|
10
|
+
require 'log4jruby/support/jruby_version'
|
11
|
+
require 'log4jruby/support/ruby_backtrace_shim'
|
8
12
|
|
9
13
|
module Log4jruby
|
10
14
|
# Author:: Lenny Marks
|
@@ -121,7 +125,7 @@ module Log4jruby
|
|
121
125
|
return @formatter if defined?(@formatter)
|
122
126
|
|
123
127
|
@formatter = if self == Logger.root
|
124
|
-
|
128
|
+
Support::Formatter.new
|
125
129
|
else
|
126
130
|
parent.formatter
|
127
131
|
end
|
@@ -156,6 +160,9 @@ module Log4jruby
|
|
156
160
|
|
157
161
|
def send_to_log4j(level, object, &block)
|
158
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
|
159
166
|
if (f = formatter)
|
160
167
|
msg = f.call(level, Time.now, progname, msg)
|
161
168
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Log4jruby
|
4
|
+
module Support
|
5
|
+
# Default ruby Logger formatter
|
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 to leave it for the Log4j config
|
9
|
+
class Formatter
|
10
|
+
def call(_severity, _time, progname, msg)
|
11
|
+
"-- #{progname}: #{msg}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Log4jruby
|
4
|
+
module Support
|
5
|
+
# Class for explicitly marking JRuby version specific code.
|
6
|
+
# Find consumers and remove this and references when no longer needed.
|
7
|
+
class JrubyVersion
|
8
|
+
class << self
|
9
|
+
attr_reader :native_ruby_stacktraces_supported
|
10
|
+
|
11
|
+
def native_ruby_stacktraces_supported?
|
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')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Log4jruby::Support::JrubyVersion.send(:init)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'log4jruby/support/jruby_version'
|
4
|
+
|
3
5
|
module Log4jruby
|
4
6
|
module Support
|
5
7
|
# Translate logger args for use by Ruby Logger formatter and log4j.
|
@@ -37,7 +39,10 @@ module Log4jruby
|
|
37
39
|
end
|
38
40
|
|
39
41
|
def exception(obj)
|
40
|
-
|
42
|
+
if (JrubyVersion.native_ruby_stacktraces_supported? && obj.is_a?(::Exception)) ||
|
43
|
+
obj.is_a?(Java::java.lang.Throwable)
|
44
|
+
obj
|
45
|
+
end
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
@@ -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
|
data/lib/log4jruby/version.rb
CHANGED
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.
|
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
|
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
|
@@ -24,10 +24,13 @@ files:
|
|
24
24
|
- lib/log4jruby.rb
|
25
25
|
- lib/log4jruby/logger.rb
|
26
26
|
- lib/log4jruby/logger_for_class.rb
|
27
|
+
- lib/log4jruby/support/formatter.rb
|
28
|
+
- lib/log4jruby/support/jruby_version.rb
|
27
29
|
- lib/log4jruby/support/levels.rb
|
28
30
|
- lib/log4jruby/support/location.rb
|
29
31
|
- lib/log4jruby/support/log4j_args.rb
|
30
32
|
- lib/log4jruby/support/log_manager.rb
|
33
|
+
- lib/log4jruby/support/ruby_backtrace_shim.rb
|
31
34
|
- lib/log4jruby/version.rb
|
32
35
|
homepage: https://github.com/lenny/log4jruby
|
33
36
|
licenses:
|
@@ -40,9 +43,9 @@ require_paths:
|
|
40
43
|
- lib
|
41
44
|
required_ruby_version: !ruby/object:Gem::Requirement
|
42
45
|
requirements:
|
43
|
-
- - "
|
46
|
+
- - ">="
|
44
47
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.
|
48
|
+
version: 2.3.3
|
46
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
50
|
requirements:
|
48
51
|
- - ">"
|