betterlog 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/betterlog.gemspec +38 -20
- data/lib/betterlog/log/legacy_event_formatter.rb +56 -0
- data/lib/betterlog/railtie.rb +2 -2
- data/lib/betterlog/version.rb +1 -1
- metadata +5 -5
- data/lib/betterlog/log_event_formatter.rb +0 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1cf962b9cfc91342bd36a4cda723361b67c6b0356242d6614c2c5feb7f53bfa
|
4
|
+
data.tar.gz: f364e9791ba336bf6757584c8afd2d46ed9e81afc0383fb398a88b5bbde9bd2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e828c8de110ada030616ed5fc3bff0c02875e9bf7544bd9a41a4d8814fc8927347ceae531283273ff78abf786ba60ef2d398e6aa273b9014dc49e7f5eaf6832
|
7
|
+
data.tar.gz: 190114f48d8662d9f7203740a843bd5e57940cf0a2292f522d643e4eb10c13e5e2581d51d2cbe4d6ac0227d1c578b1a265b2c1e3fffea13db5049dcf384bb4dc
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.3
|
data/betterlog.gemspec
CHANGED
@@ -1,38 +1,56 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: betterlog 2.0.
|
2
|
+
# stub: betterlog 2.0.3 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "betterlog".freeze
|
6
|
-
s.version = "2.0.
|
6
|
+
s.version = "2.0.3"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
10
10
|
s.authors = ["betterplace Developers".freeze]
|
11
|
-
s.date = "2024-
|
11
|
+
s.date = "2024-03-13"
|
12
12
|
s.description = "This library provides structure json logging for our rails projects".freeze
|
13
13
|
s.email = "developers@betterplace.org".freeze
|
14
14
|
s.executables = ["betterlog".freeze]
|
15
|
-
s.extra_rdoc_files = ["README.md".freeze, "lib/betterlog.rb".freeze, "lib/betterlog/global_metadata.rb".freeze, "lib/betterlog/log.rb".freeze, "lib/betterlog/log/event.rb".freeze, "lib/betterlog/log/event_formatter.rb".freeze, "lib/betterlog/log/
|
16
|
-
s.files = [".all_images.yml".freeze, ".github/workflows/codeql-analysis.yml".freeze, ".gitignore".freeze, ".semaphore/semaphore.yml".freeze, ".tool-versions".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "betterlog.gemspec".freeze, "bin/betterlog".freeze, "config/log.yml".freeze, "lib/betterlog.rb".freeze, "lib/betterlog/global_metadata.rb".freeze, "lib/betterlog/log.rb".freeze, "lib/betterlog/log/event.rb".freeze, "lib/betterlog/log/event_formatter.rb".freeze, "lib/betterlog/log/
|
15
|
+
s.extra_rdoc_files = ["README.md".freeze, "lib/betterlog.rb".freeze, "lib/betterlog/global_metadata.rb".freeze, "lib/betterlog/log.rb".freeze, "lib/betterlog/log/event.rb".freeze, "lib/betterlog/log/event_formatter.rb".freeze, "lib/betterlog/log/legacy_event_formatter.rb".freeze, "lib/betterlog/log/severity.rb".freeze, "lib/betterlog/notifiers.rb".freeze, "lib/betterlog/railtie.rb".freeze, "lib/betterlog/version.rb".freeze]
|
16
|
+
s.files = [".all_images.yml".freeze, ".github/workflows/codeql-analysis.yml".freeze, ".gitignore".freeze, ".semaphore/semaphore.yml".freeze, ".tool-versions".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "VERSION".freeze, "betterlog.gemspec".freeze, "bin/betterlog".freeze, "config/log.yml".freeze, "lib/betterlog.rb".freeze, "lib/betterlog/global_metadata.rb".freeze, "lib/betterlog/log.rb".freeze, "lib/betterlog/log/event.rb".freeze, "lib/betterlog/log/event_formatter.rb".freeze, "lib/betterlog/log/legacy_event_formatter.rb".freeze, "lib/betterlog/log/severity.rb".freeze, "lib/betterlog/notifiers.rb".freeze, "lib/betterlog/railtie.rb".freeze, "lib/betterlog/version.rb".freeze, "spec/betterlog/global_metadata_spec.rb".freeze, "spec/betterlog/log/event_spec.rb".freeze, "spec/betterlog/log/severity_spec.rb".freeze, "spec/betterlog/log_event_formatter_spec.rb".freeze, "spec/betterlog/log_spec.rb".freeze, "spec/betterlog/version_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
17
17
|
s.homepage = "http://github.com/betterplace/betterlog".freeze
|
18
18
|
s.rdoc_options = ["--title".freeze, "Betterlog".freeze, "--main".freeze, "README.md".freeze]
|
19
|
-
s.rubygems_version = "3.
|
19
|
+
s.rubygems_version = "3.3.26".freeze
|
20
20
|
s.summary = "Structured logging support for bp".freeze
|
21
21
|
s.test_files = ["spec/betterlog/global_metadata_spec.rb".freeze, "spec/betterlog/log/event_spec.rb".freeze, "spec/betterlog/log/severity_spec.rb".freeze, "spec/betterlog/log_event_formatter_spec.rb".freeze, "spec/betterlog/log_spec.rb".freeze, "spec/betterlog/version_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
22
22
|
|
23
|
-
s.specification_version
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
s.specification_version = 4
|
25
|
+
end
|
24
26
|
|
25
|
-
s.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
if s.respond_to? :add_runtime_dependency then
|
28
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.12.0"])
|
29
|
+
s.add_development_dependency(%q<rake>.freeze, [">= 0"])
|
30
|
+
s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
|
31
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
32
|
+
s.add_development_dependency(%q<debug>.freeze, [">= 0"])
|
33
|
+
s.add_development_dependency(%q<all_images>.freeze, [">= 0"])
|
34
|
+
s.add_runtime_dependency(%q<tins>.freeze, ["~> 1.3", ">= 1.22.0"])
|
35
|
+
s.add_runtime_dependency(%q<complex_config>.freeze, [">= 0"])
|
36
|
+
s.add_runtime_dependency(%q<file-tail>.freeze, ["~> 1.0"])
|
37
|
+
s.add_runtime_dependency(%q<json>.freeze, ["~> 2.0"])
|
38
|
+
s.add_runtime_dependency(%q<term-ansicolor>.freeze, ["~> 1.3"])
|
39
|
+
s.add_runtime_dependency(%q<redlock>.freeze, [">= 0"])
|
40
|
+
s.add_runtime_dependency(%q<excon>.freeze, [">= 0"])
|
41
|
+
else
|
42
|
+
s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.12.0"])
|
43
|
+
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
44
|
+
s.add_dependency(%q<rspec>.freeze, [">= 0"])
|
45
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
46
|
+
s.add_dependency(%q<debug>.freeze, [">= 0"])
|
47
|
+
s.add_dependency(%q<all_images>.freeze, [">= 0"])
|
48
|
+
s.add_dependency(%q<tins>.freeze, ["~> 1.3", ">= 1.22.0"])
|
49
|
+
s.add_dependency(%q<complex_config>.freeze, [">= 0"])
|
50
|
+
s.add_dependency(%q<file-tail>.freeze, ["~> 1.0"])
|
51
|
+
s.add_dependency(%q<json>.freeze, ["~> 2.0"])
|
52
|
+
s.add_dependency(%q<term-ansicolor>.freeze, ["~> 1.3"])
|
53
|
+
s.add_dependency(%q<redlock>.freeze, [">= 0"])
|
54
|
+
s.add_dependency(%q<excon>.freeze, [">= 0"])
|
55
|
+
end
|
38
56
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'term/ansicolor'
|
2
|
+
|
3
|
+
module Betterlog
|
4
|
+
class Log
|
5
|
+
class LegacyEventFormatter < ::ActiveSupport::Logger::Formatter
|
6
|
+
include ActiveSupport::TaggedLogging::Formatter
|
7
|
+
include ComplexConfig::Provider::Shortcuts
|
8
|
+
|
9
|
+
def emitter
|
10
|
+
'legacy'
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(severity, timestamp, program, message)
|
14
|
+
if cc.log.legacy_supported
|
15
|
+
if message.blank?
|
16
|
+
message = ''
|
17
|
+
elsif !Log::Event.is?(message)
|
18
|
+
|
19
|
+
m = message.to_s
|
20
|
+
m = Term::ANSIColor.uncolor(m)
|
21
|
+
m = m.sub(/\s+$/, '')
|
22
|
+
|
23
|
+
timestamp = timestamp.utc.iso8601(3)
|
24
|
+
event = Log::Event.new(
|
25
|
+
emitter: emitter,
|
26
|
+
timestamp: timestamp,
|
27
|
+
message: m,
|
28
|
+
severity: severity.to_s.downcase,
|
29
|
+
# tags: current_tags,
|
30
|
+
)
|
31
|
+
backtrace = m.scan(/^\s*(?:[^:]+):(?:\d+).*$/)
|
32
|
+
if backtrace.size > 1
|
33
|
+
event[:backtrace] = backtrace.map { |b| b.sub(/\s+$/, '') }
|
34
|
+
event[:message] = "#{backtrace.first}\n"
|
35
|
+
end
|
36
|
+
if l = caller_locations.reverse_each.each_cons(2).find { |c, n|
|
37
|
+
n.absolute_path =~ /\/lib\/ruby\/.*?\/logger\.rb/ and break c
|
38
|
+
}
|
39
|
+
then
|
40
|
+
event[:location] = [ l.absolute_path, l.lineno ] * ?:
|
41
|
+
end
|
42
|
+
program and event[:program] = program
|
43
|
+
message = JSON.generate(event)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
rescue => e
|
47
|
+
Betterlog::Log.logger.error(e)
|
48
|
+
ensure
|
49
|
+
message = message.to_s
|
50
|
+
# Do not "message << ?\n" - A frozen string may be passed in
|
51
|
+
message.end_with?(?\n) or message = "#{message}\n"
|
52
|
+
return message
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/betterlog/railtie.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Betterlog
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
initializer "betterlog_railtie.configure_rails_initialization" do
|
4
|
-
require 'betterlog/
|
5
|
-
Rails.logger.formatter = Betterlog::
|
4
|
+
require 'betterlog/log/legacy_event_formatter'
|
5
|
+
Rails.logger.formatter = Betterlog::Log::LegacyEventFormatter.new
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
data/lib/betterlog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betterlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- betterplace Developers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|
@@ -210,8 +210,8 @@ extra_rdoc_files:
|
|
210
210
|
- lib/betterlog/log.rb
|
211
211
|
- lib/betterlog/log/event.rb
|
212
212
|
- lib/betterlog/log/event_formatter.rb
|
213
|
+
- lib/betterlog/log/legacy_event_formatter.rb
|
213
214
|
- lib/betterlog/log/severity.rb
|
214
|
-
- lib/betterlog/log_event_formatter.rb
|
215
215
|
- lib/betterlog/notifiers.rb
|
216
216
|
- lib/betterlog/railtie.rb
|
217
217
|
- lib/betterlog/version.rb
|
@@ -234,8 +234,8 @@ files:
|
|
234
234
|
- lib/betterlog/log.rb
|
235
235
|
- lib/betterlog/log/event.rb
|
236
236
|
- lib/betterlog/log/event_formatter.rb
|
237
|
+
- lib/betterlog/log/legacy_event_formatter.rb
|
237
238
|
- lib/betterlog/log/severity.rb
|
238
|
-
- lib/betterlog/log_event_formatter.rb
|
239
239
|
- lib/betterlog/notifiers.rb
|
240
240
|
- lib/betterlog/railtie.rb
|
241
241
|
- lib/betterlog/version.rb
|
@@ -268,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
268
|
- !ruby/object:Gem::Version
|
269
269
|
version: '0'
|
270
270
|
requirements: []
|
271
|
-
rubygems_version: 3.
|
271
|
+
rubygems_version: 3.3.26
|
272
272
|
signing_key:
|
273
273
|
specification_version: 4
|
274
274
|
summary: Structured logging support for bp
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'term/ansicolor'
|
2
|
-
|
3
|
-
module Betterlog
|
4
|
-
class LogEventFormatter < ActiveSupport::Logger::Formatter
|
5
|
-
include ActiveSupport::TaggedLogging::Formatter
|
6
|
-
include ComplexConfig::Provider::Shortcuts
|
7
|
-
|
8
|
-
def emitter
|
9
|
-
'legacy'
|
10
|
-
end
|
11
|
-
|
12
|
-
def call(severity, timestamp, program, message)
|
13
|
-
if cc.log.legacy_supported
|
14
|
-
if message.blank?
|
15
|
-
message = ''
|
16
|
-
elsif !Log::Event.is?(message)
|
17
|
-
|
18
|
-
m = message.to_s
|
19
|
-
m = Term::ANSIColor.uncolor(m)
|
20
|
-
m = m.sub(/\s+$/, '')
|
21
|
-
|
22
|
-
timestamp = timestamp.utc.iso8601(3)
|
23
|
-
event = Log::Event.new({
|
24
|
-
emitter: emitter,
|
25
|
-
timestamp: timestamp,
|
26
|
-
message: m,
|
27
|
-
severity: severity.to_s.downcase,
|
28
|
-
# tags: current_tags,
|
29
|
-
meta: (
|
30
|
-
Sidekiq::Context.current&.symbolize_keys_recursive if defined?(Sidekiq::Context.current)
|
31
|
-
)}.compact
|
32
|
-
)
|
33
|
-
backtrace = m.scan(/^\s*(?:[^:]+):(?:\d+).*$/)
|
34
|
-
if backtrace.size > 1
|
35
|
-
event[:backtrace] = backtrace.map { |b| b.sub(/\s+$/, '') }
|
36
|
-
event[:message] = "#{backtrace.first}\n"
|
37
|
-
end
|
38
|
-
if l = caller_locations.reverse_each.each_cons(2).find { |c, n|
|
39
|
-
n.absolute_path =~ /\/lib\/ruby\/.*?\/logger\.rb/ and break c
|
40
|
-
}
|
41
|
-
then
|
42
|
-
event[:location] = [ l.absolute_path, l.lineno ] * ?:
|
43
|
-
end
|
44
|
-
program and event[:program] = program
|
45
|
-
message = JSON.generate(event)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
rescue => e
|
49
|
-
Betterlog::Log.logger.error(e)
|
50
|
-
ensure
|
51
|
-
message = message.to_s
|
52
|
-
# Do not "message << ?\n" - A frozen string may be passed in
|
53
|
-
message.end_with?(?\n) or message = "#{message}\n"
|
54
|
-
return message
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|