betterlog 2.2.1 → 2.4.0
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 +4 -4
- data/CHANGES.md +47 -0
- data/Gemfile +0 -2
- data/Rakefile +2 -4
- data/VERSION +1 -1
- data/betterlog.gemspec +4 -4
- data/lib/betterlog/global_metadata.rb +0 -1
- data/lib/betterlog/log/event.rb +10 -4
- data/lib/betterlog/log/event_formatter.rb +2 -2
- data/lib/betterlog/log.rb +24 -19
- data/lib/betterlog/notifiers.rb +6 -5
- data/lib/betterlog/version.rb +7 -2
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1944e34bd53637fd1aa870943673e85a152d53086e49bf4bb1311c5d7d3dd0cc
|
|
4
|
+
data.tar.gz: 0626e6dd7f22a266b559d8614381a74d9f99e4830f567ac4194bfbe5b771fef2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3cb67224647580d7b3f68ad5030b74e7d7e4f6eda6a31c5df784886cebdaf571aff1209d6f4f2dc1db72d85bc9bb4c574d6a02acb6f3467b5de83caab9b0a4fb
|
|
7
|
+
data.tar.gz: 20dfb7f824f00fd8670c785ee6868b6979861f663efbebabb9ffaf6e0dd45bd9419aefe694ab776bf6314d04cb5239e7de4e4cef25f4b627fd589632102ceacc
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-11-20 v2.4.0
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- Corrected YARD documentation accuracy across multiple files:
|
|
8
|
+
- Removed redundant `@return [ void ]` tag from
|
|
9
|
+
`Betterlog::GlobalMetadata#remove`.
|
|
10
|
+
- Broadened `@return` for `Betterlog::Log::Event.is?` to `[ Boolean, nil ]`
|
|
11
|
+
and clarified the `nil` return case.
|
|
12
|
+
- Updated `@param rest` documentation for `Betterlog::Log::Event.ify` and
|
|
13
|
+
`Betterlog::Log` methods (`info`, `warn`, `debug`, `error`, `fatal`,
|
|
14
|
+
`output`) to use specific `@option` tags for `:meta`, `:severity`, and
|
|
15
|
+
`:notify`, with a `@note` for additional keyword arguments.
|
|
16
|
+
- Escaped braces in `Betterlog::Log::EventFormatter#colorize` documentation
|
|
17
|
+
to prevent misparsing of log-format DSL syntax.
|
|
18
|
+
- Updated `Betterlog::Notifiers.notify` documentation to accurately reflect
|
|
19
|
+
the implementation.
|
|
20
|
+
|
|
21
|
+
### Improvements
|
|
22
|
+
|
|
23
|
+
- Optimized `Betterlog::Notifiers.notify` to serialize the event JSON once and
|
|
24
|
+
hoist context setting out of the notifier loop, reducing complexity from
|
|
25
|
+
O(N²) to O(N).
|
|
26
|
+
- Removed dead code `Betterlog::Log#build_metric` which had no call sites.
|
|
27
|
+
|
|
28
|
+
### Build & CI
|
|
29
|
+
|
|
30
|
+
- Updated Ruby version from **3.4.8** to **3.4.13** in `.tool-versions`
|
|
31
|
+
(picks up the 18 Nov 2026 Ruby advisory: 7 RCE-grade Regexp/String
|
|
32
|
+
case-conversion GHSAs + ~46 memory-safety fixes).
|
|
33
|
+
- Updated `gem_hadar` development dependency constraint from `>= 2.16.3` to `>=
|
|
34
|
+
2.24.1` in `betterlog.gemspec`.
|
|
35
|
+
- Regenerated `lib/betterlog/version.rb`, `Gemfile`, and `Rakefile` via
|
|
36
|
+
`gem_hadar`, removing stale vim modeline comments.
|
|
37
|
+
- Updated ignore patterns in `Rakefile` and `.gitignore` to replace
|
|
38
|
+
`betterlog-server` and `gospace` with `cscope.out`.
|
|
39
|
+
|
|
40
|
+
## 2026-01-08 v2.3.0
|
|
41
|
+
|
|
42
|
+
- Updated `required_ruby_version` from `~> 3.2` to `>= 3.2` in `Rakefile` and
|
|
43
|
+
`betterlog.gemspec`
|
|
44
|
+
- Added `readline-dev` to Dockerfile for readline support
|
|
45
|
+
- Replaced `bundle` and `rake spec` with `bundle update --all`, `bundle
|
|
46
|
+
install`, and `bundle exec rake spec` in `.all_images.yml`
|
|
47
|
+
- Added Ruby **4.0-alpine** support to CI matrix
|
|
48
|
+
- Updated `Gemfile` to use `>= 3.2` for `required_ruby_version`
|
|
49
|
+
|
|
3
50
|
## 2026-01-05 v2.2.1
|
|
4
51
|
|
|
5
52
|
- Migrated all CI/CD pipelines from Ubuntu 20.04 to Ubuntu **24.04**
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# vim: set filetype=ruby et sw=2 ts=2:
|
|
2
|
-
|
|
3
1
|
require 'gem_hadar'
|
|
4
2
|
|
|
5
3
|
GemHadar do
|
|
@@ -13,7 +11,7 @@ GemHadar do
|
|
|
13
11
|
ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', 'coverage', '.rvmrc',
|
|
14
12
|
'.ruby-version', '.AppleDouble', 'tags', '.DS_Store', '.utilsrc',
|
|
15
13
|
'.bundle', '.byebug_history', 'errors.lst', '.yardoc', 'doc',
|
|
16
|
-
'
|
|
14
|
+
'cscope.out'
|
|
17
15
|
package_ignore '.all_images.yml', '.utilsrc', '.rspec', '.tool-versions',
|
|
18
16
|
'.gitignore', *Dir['.semaphore/**/*'], *Dir['.github/**/*']
|
|
19
17
|
readme 'README.md'
|
|
@@ -25,7 +23,7 @@ GemHadar do
|
|
|
25
23
|
filename 'CHANGES.md'
|
|
26
24
|
end
|
|
27
25
|
|
|
28
|
-
required_ruby_version '
|
|
26
|
+
required_ruby_version '>= 3.2'
|
|
29
27
|
|
|
30
28
|
dependency 'tins', '~>1.47'
|
|
31
29
|
dependency 'complex_config'
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.4.0
|
data/betterlog.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: betterlog 2.
|
|
2
|
+
# stub: betterlog 2.4.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "betterlog".freeze
|
|
6
|
-
s.version = "2.
|
|
6
|
+
s.version = "2.4.0".freeze
|
|
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]
|
|
@@ -17,14 +17,14 @@ Gem::Specification.new do |s|
|
|
|
17
17
|
s.homepage = "http://github.com/betterplace/betterlog".freeze
|
|
18
18
|
s.licenses = ["Apache-2.0".freeze]
|
|
19
19
|
s.rdoc_options = ["--title".freeze, "Betterlog".freeze, "--main".freeze, "README.md".freeze]
|
|
20
|
-
s.required_ruby_version = Gem::Requirement.new("
|
|
20
|
+
s.required_ruby_version = Gem::Requirement.new(">= 3.2".freeze)
|
|
21
21
|
s.rubygems_version = "3.6.9".freeze
|
|
22
22
|
s.summary = "Structured logging support for bp".freeze
|
|
23
23
|
s.test_files = ["spec/betterlog/global_metadata_spec.rb".freeze, "spec/betterlog/log/event_spec.rb".freeze, "spec/betterlog/log/legacy_event_formatter_spec.rb".freeze, "spec/betterlog/log/severity_spec.rb".freeze, "spec/betterlog/log_spec.rb".freeze, "spec/betterlog/version_spec.rb".freeze, "spec/spec_helper.rb".freeze]
|
|
24
24
|
|
|
25
25
|
s.specification_version = 4
|
|
26
26
|
|
|
27
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, [">= 2.
|
|
27
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, [">= 2.24.1".freeze])
|
|
28
28
|
s.add_development_dependency(%q<rake>.freeze, [">= 0".freeze])
|
|
29
29
|
s.add_development_dependency(%q<rspec>.freeze, [">= 0".freeze])
|
|
30
30
|
s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
|
|
@@ -42,7 +42,6 @@ module Betterlog
|
|
|
42
42
|
#
|
|
43
43
|
# @param data [ Hash, Array ] A hash containing keys to remove or an array
|
|
44
44
|
# of key symbols
|
|
45
|
-
# @return [ void ] Returns nil after removing the specified keys
|
|
46
45
|
def remove(data)
|
|
47
46
|
keys = data.ask_and_send_or_self(:keys).map(&:to_sym)
|
|
48
47
|
keys.each { current.delete(_1) }
|
data/lib/betterlog/log/event.rb
CHANGED
|
@@ -23,7 +23,10 @@ module Betterlog
|
|
|
23
23
|
# where necessary.
|
|
24
24
|
#
|
|
25
25
|
# @param arg [ Object ] the input argument to be converted into a log event
|
|
26
|
-
# @
|
|
26
|
+
# @option rest [ Hash ] :meta thread-global metadata merged into the event
|
|
27
|
+
# @option rest [ Symbol ] :severity severity override (default: inferred from the calling method)
|
|
28
|
+
# @option rest [ Boolean ] :notify whether to trigger registered notifiers (default: false)
|
|
29
|
+
# @note Additional keyword arguments are passed through into the event data as-is.
|
|
27
30
|
# @return [ Betterlog::Log::Event ] a new log event instance created from the input argument
|
|
28
31
|
def self.ify(arg, **rest)
|
|
29
32
|
rest = rest.symbolize_keys_recursive(circular: :circular)
|
|
@@ -66,11 +69,14 @@ module Betterlog
|
|
|
66
69
|
# This method attempts to parse a JSON string and determine whether it
|
|
67
70
|
# contains a log event structure by checking for the presence of an
|
|
68
71
|
# 'emitter' key in the parsed data. It returns true if the JSON is valid
|
|
69
|
-
# and contains the emitter key, false
|
|
72
|
+
# and contains the emitter key, false if the JSON is valid but has no
|
|
73
|
+
# emitter key (or parsing fails), and nil if the argument is not a
|
|
74
|
+
# string and cannot be converted to one.
|
|
70
75
|
#
|
|
71
76
|
# @param json [ String ] A JSON-formatted string to check
|
|
72
|
-
# @return [ Boolean ] true if the JSON represents a log event with
|
|
73
|
-
# emitter data, false if not or if parsing fails
|
|
77
|
+
# @return [ Boolean, nil ] true if the JSON represents a log event with
|
|
78
|
+
# emitter data, false if not or if parsing fails, nil if the argument is
|
|
79
|
+
# not string-convertible
|
|
74
80
|
def self.is?(json)
|
|
75
81
|
if json = json.ask_and_send(:to_str)
|
|
76
82
|
data = JSON.parse(json).ask_and_send(:to_hash)
|
|
@@ -93,8 +93,8 @@ module Betterlog
|
|
|
93
93
|
# error: red
|
|
94
94
|
#
|
|
95
95
|
# The method will:
|
|
96
|
-
# - Colorize "{timestamp}" with yellow/bold styling
|
|
97
|
-
# - Colorize "{severity}" with green for "debug"/"info", yellow for "warn", red for "error"
|
|
96
|
+
# - Colorize "\\{timestamp\\}" with yellow/bold styling
|
|
97
|
+
# - Colorize "\\{severity\\}" with green for "debug"/"info", yellow for "warn", red for "error"
|
|
98
98
|
#
|
|
99
99
|
# @param key [Object] the lookup key for determining the style configuration
|
|
100
100
|
# @param value [Object] the value used to determine which specific style to apply
|
data/lib/betterlog/log.rb
CHANGED
|
@@ -38,7 +38,10 @@ module Betterlog
|
|
|
38
38
|
# Logs a message on severity info.
|
|
39
39
|
#
|
|
40
40
|
# @param object this object is logged
|
|
41
|
-
# @
|
|
41
|
+
# @option rest [ Hash ] :meta thread-global metadata merged into the event
|
|
42
|
+
# @option rest [ Symbol ] :severity severity override (default: :info)
|
|
43
|
+
# @option rest [ Boolean ] :notify whether to trigger registered notifiers (default: false)
|
|
44
|
+
# @note Additional keyword arguments are passed through into the event data as-is.
|
|
42
45
|
# @return [ Log ] this object itself.
|
|
43
46
|
def info(object, **rest)
|
|
44
47
|
protect do
|
|
@@ -50,7 +53,10 @@ module Betterlog
|
|
|
50
53
|
# Logs a message on severity warn.
|
|
51
54
|
#
|
|
52
55
|
# @param object this object is logged
|
|
53
|
-
# @
|
|
56
|
+
# @option rest [ Hash ] :meta thread-global metadata merged into the event
|
|
57
|
+
# @option rest [ Symbol ] :severity severity override (default: :warn)
|
|
58
|
+
# @option rest [ Boolean ] :notify whether to trigger registered notifiers (default: false)
|
|
59
|
+
# @note Additional keyword arguments are passed through into the event data as-is.
|
|
54
60
|
# @return [ Log ] this object itself.
|
|
55
61
|
def warn(object, **rest)
|
|
56
62
|
protect do
|
|
@@ -62,7 +68,10 @@ module Betterlog
|
|
|
62
68
|
# Logs a message on severity debug.
|
|
63
69
|
#
|
|
64
70
|
# @param object this object is logged
|
|
65
|
-
# @
|
|
71
|
+
# @option rest [ Hash ] :meta thread-global metadata merged into the event
|
|
72
|
+
# @option rest [ Symbol ] :severity severity override (default: :debug)
|
|
73
|
+
# @option rest [ Boolean ] :notify whether to trigger registered notifiers (default: false)
|
|
74
|
+
# @note Additional keyword arguments are passed through into the event data as-is.
|
|
66
75
|
# @return [ Log ] this object itself.
|
|
67
76
|
def debug(object, **rest)
|
|
68
77
|
protect do
|
|
@@ -74,7 +83,10 @@ module Betterlog
|
|
|
74
83
|
# Logs a message on severity error.
|
|
75
84
|
#
|
|
76
85
|
# @param object this object is logged
|
|
77
|
-
# @
|
|
86
|
+
# @option rest [ Hash ] :meta thread-global metadata merged into the event
|
|
87
|
+
# @option rest [ Symbol ] :severity severity override (default: :error)
|
|
88
|
+
# @option rest [ Boolean ] :notify whether to trigger registered notifiers (default: false)
|
|
89
|
+
# @note Additional keyword arguments are passed through into the event data as-is.
|
|
78
90
|
# @return [ Log ] this object itself.
|
|
79
91
|
def error(object, **rest)
|
|
80
92
|
protect do
|
|
@@ -86,7 +98,10 @@ module Betterlog
|
|
|
86
98
|
# Logs a message on severity fatal.
|
|
87
99
|
#
|
|
88
100
|
# @param object this object is logged
|
|
89
|
-
# @
|
|
101
|
+
# @option rest [ Hash ] :meta thread-global metadata merged into the event
|
|
102
|
+
# @option rest [ Symbol ] :severity severity override (default: :fatal)
|
|
103
|
+
# @option rest [ Boolean ] :notify whether to trigger registered notifiers (default: false)
|
|
104
|
+
# @note Additional keyword arguments are passed through into the event data as-is.
|
|
90
105
|
# @return [ Log ] this object itself.
|
|
91
106
|
def fatal(object, **rest)
|
|
92
107
|
protect do
|
|
@@ -99,7 +114,10 @@ module Betterlog
|
|
|
99
114
|
# passing the severity: keyword.
|
|
100
115
|
#
|
|
101
116
|
# @param object this object is logged
|
|
102
|
-
# @
|
|
117
|
+
# @option rest [ Hash ] :meta thread-global metadata merged into the event
|
|
118
|
+
# @option rest [ Symbol ] :severity severity override (default: :debug)
|
|
119
|
+
# @option rest [ Boolean ] :notify whether to trigger registered notifiers (default: false)
|
|
120
|
+
# @note Additional keyword arguments are passed through into the event data as-is.
|
|
103
121
|
# @return [ Log ] this object itself.
|
|
104
122
|
def output(object, **rest)
|
|
105
123
|
protect do
|
|
@@ -148,19 +166,6 @@ module Betterlog
|
|
|
148
166
|
self
|
|
149
167
|
end
|
|
150
168
|
|
|
151
|
-
def build_metric(name:, value:, **rest)
|
|
152
|
-
rest |= {
|
|
153
|
-
message: "a metric #{name}=#{value}",
|
|
154
|
-
}
|
|
155
|
-
Log::Event.ify(
|
|
156
|
-
{
|
|
157
|
-
name: name,
|
|
158
|
-
value: value,
|
|
159
|
-
type: 'metric'
|
|
160
|
-
} | rest,
|
|
161
|
-
)
|
|
162
|
-
end
|
|
163
|
-
|
|
164
169
|
def notify(event)
|
|
165
170
|
if event.notify?
|
|
166
171
|
Notifiers.notify(event)
|
data/lib/betterlog/notifiers.rb
CHANGED
|
@@ -36,16 +36,17 @@ module Betterlog
|
|
|
36
36
|
# Notifies registered notifiers with the event data.
|
|
37
37
|
#
|
|
38
38
|
# This method checks if the provided event has notification enabled,
|
|
39
|
-
# and if so,
|
|
40
|
-
#
|
|
41
|
-
# each
|
|
39
|
+
# and if so, serializes the event once, applies it as context to all
|
|
40
|
+
# registered notifiers via `context`, then iterates through them to send
|
|
41
|
+
# each one its message and metadata.
|
|
42
42
|
#
|
|
43
43
|
# @param event [Betterlog::Log::Event] the log event to be notified about
|
|
44
44
|
def self.notify(event)
|
|
45
45
|
event.notify? or return
|
|
46
|
+
event_json = event.as_json
|
|
47
|
+
context(event_json)
|
|
46
48
|
notifiers.each do |notifier|
|
|
47
|
-
|
|
48
|
-
notifier.notify(event[:message], event.as_json)
|
|
49
|
+
notifier.notify(event[:message], event_json)
|
|
49
50
|
end
|
|
50
51
|
end
|
|
51
52
|
|
data/lib/betterlog/version.rb
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
# Version information for the Betterlog gem.
|
|
2
|
+
#
|
|
3
|
+
# This module is auto-generated by GemHadar and exposes the
|
|
4
|
+
# current release version as a set of constants. Do not edit it
|
|
5
|
+
# by hand; it is rewritten on every `rake version` invocation.
|
|
1
6
|
module Betterlog
|
|
2
|
-
# Betterlog
|
|
3
|
-
VERSION = '2.
|
|
7
|
+
# The current version of the Betterlog gem as a String.
|
|
8
|
+
VERSION = '2.4.0'
|
|
4
9
|
VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
|
|
5
10
|
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
|
6
11
|
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: betterlog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- betterplace Developers
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 2.
|
|
18
|
+
version: 2.24.1
|
|
19
19
|
type: :development
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 2.
|
|
25
|
+
version: 2.24.1
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: rake
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -248,7 +248,7 @@ require_paths:
|
|
|
248
248
|
- lib
|
|
249
249
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
250
250
|
requirements:
|
|
251
|
-
- - "
|
|
251
|
+
- - ">="
|
|
252
252
|
- !ruby/object:Gem::Version
|
|
253
253
|
version: '3.2'
|
|
254
254
|
required_rubygems_version: !ruby/object:Gem::Requirement
|