betterlog 2.0.5 → 2.1.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/.tool-versions +1 -1
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/betterlog.gemspec +6 -5
- data/lib/betterlog/global_metadata.rb +49 -0
- data/lib/betterlog/log/event.rb +161 -2
- data/lib/betterlog/log/event_formatter.rb +90 -0
- data/lib/betterlog/log/legacy_event_formatter.rb +30 -0
- data/lib/betterlog/log/severity.rb +104 -0
- data/lib/betterlog/log.rb +32 -10
- data/lib/betterlog/notifiers.rb +38 -0
- data/lib/betterlog/railtie.rb +8 -0
- data/lib/betterlog/version.rb +1 -1
- data/lib/betterlog.rb +15 -0
- data/spec/spec_helper.rb +2 -6
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5b1ea80565dc5b5e0b95a525f8e50a3aded59cd3038c2e76610d6fe36427d20
|
4
|
+
data.tar.gz: 8b98f5b839d2bbaecb6bd2171a52e11c728a00eb415039d833669016b842fc2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d9306aa22d8b0032d684d0e61026059aed39bf19ea2f83cef327d60b982f534eb70740e59e6610cc38223980cbab152ee9942e7c3b6af02418d1cec4bbc6182
|
7
|
+
data.tar.gz: 372ab8b900747df79f51019b6905a66065b3c00157484da3aa3a5c963517e61411b2da7e443ae900d34af842d2d4f7fecccf09827b03adc947a9d57e5589a9af
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.4.
|
1
|
+
ruby 3.4.5
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0
|
data/betterlog.gemspec
CHANGED
@@ -1,28 +1,29 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: betterlog 2.0
|
2
|
+
# stub: betterlog 2.1.0 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.1.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]
|
10
10
|
s.authors = ["betterplace Developers".freeze]
|
11
|
-
s.date = "
|
11
|
+
s.date = "1980-01-02"
|
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
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
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/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]
|
17
17
|
s.homepage = "http://github.com/betterplace/betterlog".freeze
|
18
|
+
s.licenses = ["Apache-2.0".freeze]
|
18
19
|
s.rdoc_options = ["--title".freeze, "Betterlog".freeze, "--main".freeze, "README.md".freeze]
|
19
|
-
s.rubygems_version = "3.6.
|
20
|
+
s.rubygems_version = "3.6.9".freeze
|
20
21
|
s.summary = "Structured logging support for bp".freeze
|
21
22
|
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]
|
22
23
|
|
23
24
|
s.specification_version = 4
|
24
25
|
|
25
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.
|
26
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.28".freeze])
|
26
27
|
s.add_development_dependency(%q<rake>.freeze, [">= 0".freeze])
|
27
28
|
s.add_development_dependency(%q<rspec>.freeze, [">= 0".freeze])
|
28
29
|
s.add_development_dependency(%q<simplecov>.freeze, [">= 0".freeze])
|
@@ -4,22 +4,61 @@
|
|
4
4
|
# tools etc.
|
5
5
|
|
6
6
|
module Betterlog
|
7
|
+
|
8
|
+
# Thread-local storage for global metadata used to enrich log events.
|
9
|
+
#
|
10
|
+
# This class provides a thread-safe mechanism to store and manage metadata
|
11
|
+
# that should be included with log events. It ensures that metadata is
|
12
|
+
# scoped to the current thread and can be easily added, removed, or
|
13
|
+
# temporarily applied within a block context.
|
14
|
+
#
|
15
|
+
# @see Betterlog::Log::Event
|
16
|
+
# @see Betterlog.with_meta
|
7
17
|
class GlobalMetadata
|
8
18
|
include Tins::SexySingleton
|
9
19
|
|
10
20
|
thread_local(:current) { {} }
|
11
21
|
|
22
|
+
# Adds metadata to the current thread-local storage.
|
23
|
+
#
|
24
|
+
# This method takes a hash of data and merges it with the existing metadata
|
25
|
+
# in the current thread's storage. The provided data is symbolized and then
|
26
|
+
# combined with the current metadata using a union operation, ensuring that
|
27
|
+
# new keys overwrite existing ones with the same name.
|
28
|
+
#
|
29
|
+
# @param data [ Hash ] A hash containing the metadata to be added
|
30
|
+
# @return [ Betterlog::GlobalMetadata ] Returns the GlobalMetadata instance itself
|
12
31
|
def add(data)
|
13
32
|
data = data.symbolize_keys_recursive
|
14
33
|
self.current = data | current
|
15
34
|
self
|
16
35
|
end
|
17
36
|
|
37
|
+
# Removes metadata keys from the current thread-local storage.
|
38
|
+
#
|
39
|
+
# This method takes a hash or array of keys and deletes the corresponding
|
40
|
+
# entries from the global metadata stored in the current thread. It ensures
|
41
|
+
# that only the specified keys are removed, leaving other metadata intact.
|
42
|
+
#
|
43
|
+
# @param data [ Hash, Array ] A hash containing keys to remove or an array
|
44
|
+
# of key symbols
|
45
|
+
# @return [ void ] Returns nil after removing the specified keys
|
18
46
|
def remove(data)
|
19
47
|
keys = data.ask_and_send_or_self(:keys).map(&:to_sym)
|
20
48
|
keys.each { current.delete(_1) }
|
21
49
|
end
|
22
50
|
|
51
|
+
# Temporarily adds metadata to the current thread-local storage for the
|
52
|
+
# duration of a block execution.
|
53
|
+
#
|
54
|
+
# This method allows for the temporary addition of metadata to the global
|
55
|
+
# metadata store within the context of a block. The metadata is
|
56
|
+
# automatically removed after the block completes, ensuring that the
|
57
|
+
# metadata changes do not persist beyond the intended scope.
|
58
|
+
#
|
59
|
+
# @param data [ Hash ] A hash containing the metadata key-value pairs to be added
|
60
|
+
# @yield [ data ] Executes the provided block with the metadata in place
|
61
|
+
# @return [ void ] Returns nil after the block has been executed and metadata removed
|
23
62
|
def with_meta(data = {}, &block)
|
24
63
|
add data
|
25
64
|
block.call
|
@@ -28,6 +67,16 @@ module Betterlog
|
|
28
67
|
end
|
29
68
|
end
|
30
69
|
|
70
|
+
# Provides a convenient way to temporarily add metadata to the global
|
71
|
+
# metadata store within the scope of a block.
|
72
|
+
#
|
73
|
+
# This method serves as a shortcut to Betterlog::GlobalMetadata.with_meta,
|
74
|
+
# allowing for easy temporary addition of metadata that is automatically
|
75
|
+
# removed after the block execution completes.
|
76
|
+
#
|
77
|
+
# @param data [ Hash ] A hash containing the metadata key-value pairs to be added
|
78
|
+
# @yield [ data ] Executes the provided block with the metadata in place
|
79
|
+
# @return [ void ] Returns nil after the block has been executed and metadata removed
|
31
80
|
def self.with_meta(data = {}, &block)
|
32
81
|
Betterlog::GlobalMetadata.with_meta(data, &block)
|
33
82
|
end
|
data/lib/betterlog/log/event.rb
CHANGED
@@ -1,8 +1,30 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
1
3
|
module Betterlog
|
2
4
|
class Log
|
5
|
+
# A structured logging event representation.
|
6
|
+
#
|
7
|
+
# This class encapsulates log event data with standardized formatting and
|
8
|
+
# metadata enrichment. It provides methods for creating, formatting, and
|
9
|
+
# serializing log events while ensuring consistent structure and
|
10
|
+
# compatibility with various logging systems.
|
11
|
+
#
|
12
|
+
# @see Betterlog::Log::EventFormatter
|
13
|
+
# @see Betterlog::Log::Severity
|
14
|
+
# @see Betterlog::GlobalMetadata
|
3
15
|
class Event
|
4
|
-
|
5
|
-
|
16
|
+
# Converts an input argument into a log event object with standardized
|
17
|
+
# formatting.
|
18
|
+
#
|
19
|
+
# This method processes various types of input including exceptions,
|
20
|
+
# strings, and hashes, transforming them into structured log events while
|
21
|
+
# preserving or enhancing their metadata. It ensures consistent event
|
22
|
+
# creation by normalizing keys and applying default values
|
23
|
+
# where necessary.
|
24
|
+
#
|
25
|
+
# @param arg [ Object ] the input argument to be converted into a log event
|
26
|
+
# @param rest [ Hash ] additional key-value pairs to be merged into the resulting event
|
27
|
+
# @return [ Betterlog::Log::Event ] a new log event instance created from the input argument
|
6
28
|
def self.ify(arg, **rest)
|
7
29
|
rest = rest.symbolize_keys_recursive(circular: :circular)
|
8
30
|
if e = arg.ask_and_send(:exception)
|
@@ -23,11 +45,32 @@ module Betterlog
|
|
23
45
|
end
|
24
46
|
end
|
25
47
|
|
48
|
+
# Parses a JSON string into a new log event instance.
|
49
|
+
#
|
50
|
+
# This method takes a JSON representation of a log event and converts it
|
51
|
+
# into a structured event object. It attempts to parse the JSON string
|
52
|
+
# and create a new event using the parsed data. If the JSON is malformed
|
53
|
+
# or cannot be parsed, the method silently rescues the error and returns
|
54
|
+
# nil.
|
55
|
+
#
|
56
|
+
# @param json [ String ] a JSON-formatted string representing a log event
|
57
|
+
# @return [ Betterlog::Log::Event, nil ] a new log event instance if
|
58
|
+
# parsing succeeds, nil otherwise
|
26
59
|
def self.parse(json)
|
27
60
|
new(JSON.parse(json))
|
28
61
|
rescue JSON::ParserError
|
29
62
|
end
|
30
63
|
|
64
|
+
# Checks if a JSON string represents a log event with emitter data.
|
65
|
+
#
|
66
|
+
# This method attempts to parse a JSON string and determine whether it
|
67
|
+
# contains a log event structure by checking for the presence of an
|
68
|
+
# 'emitter' key in the parsed data. It returns true if the JSON is valid
|
69
|
+
# and contains the emitter key, false otherwise.
|
70
|
+
#
|
71
|
+
# @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
|
31
74
|
def self.is?(json)
|
32
75
|
if json = json.ask_and_send(:to_str)
|
33
76
|
data = JSON.parse(json).ask_and_send(:to_hash)
|
@@ -37,6 +80,15 @@ module Betterlog
|
|
37
80
|
false
|
38
81
|
end
|
39
82
|
|
83
|
+
# Initializes a new log event with the provided data.
|
84
|
+
#
|
85
|
+
# This constructor processes the input data by normalizing keys, computing
|
86
|
+
# default values for missing fields, and setting up the event's severity level.
|
87
|
+
# It ensures that all log events have consistent structure and required fields
|
88
|
+
# such as timestamp, PID, program name, and host information.
|
89
|
+
#
|
90
|
+
# @param data [ Hash ] a hash containing the initial data for the log event
|
91
|
+
# @return [ Betterlog::Log::Event ] a new log event instance with processed data
|
40
92
|
def initialize(data = {})
|
41
93
|
data = compute_data(data.symbolize_keys_recursive(circular: :circular))
|
42
94
|
data[:severity] =
|
@@ -51,10 +103,31 @@ module Betterlog
|
|
51
103
|
@data = Hash[data.sort_by(&:first)]
|
52
104
|
end
|
53
105
|
|
106
|
+
# Returns a duplicate of the internal data hash for JSON serialization.
|
107
|
+
#
|
108
|
+
# This method provides access to the log event's underlying data
|
109
|
+
# structure by returning a shallow copy of the internal @data instance
|
110
|
+
# variable. It is primarily used to enable JSON serialization of log
|
111
|
+
# events while ensuring that modifications to the returned hash do not
|
112
|
+
# affect the original event data.
|
113
|
+
#
|
114
|
+
# @return [ Hash ] a duplicate of the internal data hash containing all
|
115
|
+
# log event attributes and metadata
|
54
116
|
def as_json(*a)
|
55
117
|
@data.dup
|
56
118
|
end
|
57
119
|
|
120
|
+
# Converts the log event to a JSON string representation.
|
121
|
+
#
|
122
|
+
# This method generates a JSON-encoded string of the log event's data,
|
123
|
+
# providing a structured format suitable for logging and transmission.
|
124
|
+
# In cases where JSON generation fails due to encoding issues or other errors,
|
125
|
+
# it falls back to a minimal JSON representation containing only the severity
|
126
|
+
# and a cleaned-up message to ensure logging functionality remains intact.
|
127
|
+
#
|
128
|
+
# @return [ String ] A JSON string representation of the log event
|
129
|
+
# @see #as_json
|
130
|
+
# @see JSON.generate
|
58
131
|
def to_json(*a)
|
59
132
|
JSON.generate(as_json)
|
60
133
|
rescue
|
@@ -67,44 +140,130 @@ module Betterlog
|
|
67
140
|
})
|
68
141
|
end
|
69
142
|
|
143
|
+
# Formats the log event using the specified formatting options.
|
144
|
+
#
|
145
|
+
# This method delegates to an EventFormatter instance to process the log
|
146
|
+
# event according to the provided arguments, enabling flexible output
|
147
|
+
# generation including JSON representation and pretty-printed strings
|
148
|
+
# with optional colorization.
|
149
|
+
#
|
150
|
+
# @param args [ Hash ] A hash of formatting options to control the output format
|
151
|
+
# @return [ String ] The formatted string representation of the log event
|
70
152
|
def format(**args)
|
71
153
|
Log::EventFormatter.new(self).format(**args)
|
72
154
|
end
|
73
155
|
|
74
156
|
alias to_s format
|
75
157
|
|
158
|
+
# Sets a value in the event data hash using the provided name as a key.
|
159
|
+
#
|
160
|
+
# This method allows for direct assignment of a value to a specific key
|
161
|
+
# within the log event's internal data structure. The key is converted to a
|
162
|
+
# symbol before being used to store the value, ensuring consistency with
|
163
|
+
# the internal storage format.
|
164
|
+
#
|
165
|
+
# @param name [ String, Symbol ] the key to set in the event data
|
166
|
+
# @param value [ Object ] the value to associate with the given key
|
167
|
+
# @return [ Object ] the assigned value
|
76
168
|
def []=(name, value)
|
77
169
|
@data[name.to_sym] = value
|
78
170
|
end
|
79
171
|
|
172
|
+
# Retrieves a value from the event data hash using the provided name as a key.
|
173
|
+
#
|
174
|
+
# This method allows for access to specific fields stored within the log
|
175
|
+
# event's internal data structure by converting the provided name to a
|
176
|
+
# symbol and using it to look up the corresponding value.
|
177
|
+
#
|
178
|
+
# @param name [ String, Symbol ] the key used to retrieve the value from
|
179
|
+
# the event data
|
180
|
+
# @return [ Object, nil ] the value associated with the given key, or nil
|
181
|
+
# if the key does not exist
|
80
182
|
def [](name)
|
81
183
|
@data[name.to_sym]
|
82
184
|
end
|
83
185
|
|
186
|
+
# Returns the severity level of the log event.
|
187
|
+
#
|
188
|
+
# This method provides access to the severity attribute that was assigned
|
189
|
+
# to the log event during its initialization. The severity indicates the
|
190
|
+
# importance or urgency of the log message, such as debug, info, warn,
|
191
|
+
# error, or fatal levels.
|
192
|
+
#
|
193
|
+
# @return [ Betterlog::Log::Severity ] the severity level object associated
|
194
|
+
# with this log event
|
84
195
|
def severity
|
85
196
|
@data[:severity]
|
86
197
|
end
|
87
198
|
|
199
|
+
# Returns the emitter identifier associated with the log event.
|
200
|
+
#
|
201
|
+
# This method provides access to the emitter field stored within the log
|
202
|
+
# event's data hash. The emitter typically indicates the source or type
|
203
|
+
# of system that generated the log entry, helping to categorize and route
|
204
|
+
# log messages appropriately.
|
205
|
+
#
|
206
|
+
# @return [ String, nil ] the emitter identifier if set, otherwise nil
|
88
207
|
def emitter
|
89
208
|
@data[:emitter]
|
90
209
|
end
|
91
210
|
|
211
|
+
# Returns the notification flag from the log event data.
|
212
|
+
#
|
213
|
+
# This method retrieves the value associated with the :notify key from
|
214
|
+
# the event's internal data hash. The return value indicates whether the
|
215
|
+
# log event should trigger notifications to registered notifiers.
|
216
|
+
#
|
217
|
+
# @return [ Object, nil ] the notification setting from the event data,
|
218
|
+
# or nil if not set
|
92
219
|
def notify?
|
93
220
|
@data[:notify]
|
94
221
|
end
|
95
222
|
|
223
|
+
# Checks equality between this log event and another object based on
|
224
|
+
# their internal data.
|
225
|
+
#
|
226
|
+
# This method compares the internal data hash of this log event with that
|
227
|
+
# of another object to determine if they contain identical content. It
|
228
|
+
# accesses the private @data instance variable from both objects and uses
|
229
|
+
# the built-in eql? method for hash comparison to ensure a deep equality
|
230
|
+
# check.
|
231
|
+
#
|
232
|
+
# @param other [ Object ] the object to compare against, expected to be another
|
233
|
+
# Betterlog::Log::Event instance
|
234
|
+
# @return [ TrueClass, FalseClass ] true if both objects have equal internal data,
|
235
|
+
# false otherwise
|
96
236
|
def eql?(other)
|
97
237
|
@data.eql? other.instance_variable_get(:@data)
|
98
238
|
end
|
99
239
|
|
100
240
|
alias == eql?
|
101
241
|
|
242
|
+
# Returns the hash value corresponding to the event's data.
|
243
|
+
#
|
244
|
+
# This method provides access to the cached hash representation of the
|
245
|
+
# internal data hash, which is used for consistent identification and
|
246
|
+
# comparison operations within the logging system. The returned hash
|
247
|
+
# value is derived from the event's current data state and remains stable
|
248
|
+
# as long as the data does not change.
|
249
|
+
#
|
250
|
+
# @return [ Integer ] the hash value of the event's internal data structure
|
102
251
|
def hash
|
103
252
|
@data.hash
|
104
253
|
end
|
105
254
|
|
106
255
|
private
|
107
256
|
|
257
|
+
# Processes input data to compute and enrich log event information.
|
258
|
+
#
|
259
|
+
# This method takes raw log data and enriches it with default values for
|
260
|
+
# standard log fields such as timestamp, process ID, program name, and
|
261
|
+
# host information. It also merges in global metadata and Sidekiq context
|
262
|
+
# information when available to provide comprehensive context for the log
|
263
|
+
# event.
|
264
|
+
#
|
265
|
+
# @param data [ Hash ] the raw input data to be processed and enriched
|
266
|
+
# @return [ Hash ] the processed data hash with default values and metadata merged in
|
108
267
|
def compute_data(data)
|
109
268
|
d = data | {
|
110
269
|
timestamp: Time.now.utc.iso8601(3),
|
@@ -3,14 +3,48 @@ require 'term/ansicolor'
|
|
3
3
|
|
4
4
|
module Betterlog
|
5
5
|
class Log
|
6
|
+
# Formats log events for structured logging output.
|
7
|
+
#
|
8
|
+
# This class provides functionality to format log events into various
|
9
|
+
# output formats, including JSON representation and pretty-printed strings
|
10
|
+
# with color support. It handles the conversion of log data into
|
11
|
+
# human-readable formats while maintaining structured logging capabilities.
|
12
|
+
#
|
13
|
+
# @see Betterlog::Log::Event
|
14
|
+
# @see Betterlog::Log::EventFormatter#format
|
6
15
|
class EventFormatter
|
7
16
|
include Term::ANSIColor
|
8
17
|
include ComplexConfig::Provider::Shortcuts
|
9
18
|
|
19
|
+
# Initializes a new EventFormatter instance with the given log event.
|
20
|
+
#
|
21
|
+
# This constructor sets up the formatter with a specific log event to be
|
22
|
+
# formatted, preparing it for subsequent formatting operations such as
|
23
|
+
# JSON generation or pretty printing with color support.
|
24
|
+
#
|
25
|
+
# @param event [Betterlog::Log::Event] the log event to be formatted by
|
26
|
+
# this instance
|
27
|
+
# @return [Betterlog::Log::EventFormatter] a new EventFormatter instance
|
10
28
|
def initialize(event)
|
11
29
|
@event = event
|
12
30
|
end
|
13
31
|
|
32
|
+
# Formats the log event according to specified options.
|
33
|
+
#
|
34
|
+
# This method processes a log event and returns either a JSON
|
35
|
+
# representation or a formatted string based on the provided formatting
|
36
|
+
# options. It supports pretty printing with custom format patterns and
|
37
|
+
# optional colorization.
|
38
|
+
#
|
39
|
+
# @param pretty [ Boolean, Symbol ] when true, enables pretty printing;
|
40
|
+
# when :format, uses a specific format pattern; otherwise uses JSON generation
|
41
|
+
# @param color [ Boolean ] whether to apply color formatting to the output
|
42
|
+
# @param format [ Symbol ] the format identifier to use for pretty printing
|
43
|
+
#
|
44
|
+
# @return [ String ] the formatted log event as a string
|
45
|
+
#
|
46
|
+
# @see Betterlog::Log::EventFormatter#format_pattern
|
47
|
+
# @see JSON.generate
|
14
48
|
def format(pretty: false, color: false, format: :default)
|
15
49
|
old_coloring, Term::ANSIColor.coloring = Term::ANSIColor.coloring?, color
|
16
50
|
f = cc.log.formats[format] and format = f
|
@@ -26,6 +60,20 @@ module Betterlog
|
|
26
60
|
|
27
61
|
private
|
28
62
|
|
63
|
+
# Colorizes a string value based on configured styles for a given key and
|
64
|
+
# optional value.
|
65
|
+
#
|
66
|
+
# This method applies visual styling to a string by looking up the
|
67
|
+
# appropriate style configuration based on the provided key and value,
|
68
|
+
# then applying that style using the internal apply_style method.
|
69
|
+
#
|
70
|
+
# @param key [ Object ] the lookup key for determining the style
|
71
|
+
# configuration
|
72
|
+
# @param value [ Object ] the value used to determine which specific
|
73
|
+
# style to apply
|
74
|
+
# @param string [ Object ] the string to be colorized, defaults to the
|
75
|
+
# key if not provided
|
76
|
+
# @return [ String ] the colorized string based on the configured styles
|
29
77
|
def colorize(key, value, string = key)
|
30
78
|
case style = cc.log.styles[key]
|
31
79
|
when nil, String, Array
|
@@ -35,6 +83,19 @@ module Betterlog
|
|
35
83
|
end
|
36
84
|
end
|
37
85
|
|
86
|
+
# Applies visual styling to a string using the provided style
|
87
|
+
# configuration.
|
88
|
+
#
|
89
|
+
# This method takes a style definition and applies it to a given string,
|
90
|
+
# supporting both single styles and arrays of styles. It handles the case
|
91
|
+
# where no style is provided by returning the string with reset
|
92
|
+
# formatting. When multiple styles are specified, they are applied
|
93
|
+
# sequentially to the string.
|
94
|
+
#
|
95
|
+
# @param style [ Object ] The style configuration to apply, which can be nil,
|
96
|
+
# a string, an array of styles, or a ComplexConfig::Settings object
|
97
|
+
# @param string [ String ] The input string to which the style will be applied
|
98
|
+
# @return [ String ] The styled string with appropriate ANSI color codes inserted
|
38
99
|
def apply_style(style, string)
|
39
100
|
style.nil? and return string + Term::ANSIColor.reset
|
40
101
|
string = Term::ANSIColor.uncolor(string)
|
@@ -48,6 +109,18 @@ module Betterlog
|
|
48
109
|
end
|
49
110
|
end
|
50
111
|
|
112
|
+
# Formats a log event using a specified pattern with support for
|
113
|
+
# directives and colorization.
|
114
|
+
#
|
115
|
+
# This method processes a format string by replacing placeholders with
|
116
|
+
# actual event data, applying formatting directives for special handling
|
117
|
+
# of values like objects or timestamps, and optionally applying color
|
118
|
+
# styling based on configured styles.
|
119
|
+
#
|
120
|
+
# @param format [ String ] the format pattern to apply to the log event
|
121
|
+
# @return [ String ] the formatted string representation of the log event
|
122
|
+
# @see Betterlog::Log::EventFormatter#format_object
|
123
|
+
# @see Betterlog::Log::EventFormatter#colorize
|
51
124
|
def format_pattern(format:)
|
52
125
|
format.
|
53
126
|
gsub('\n', "\n").
|
@@ -99,6 +172,23 @@ module Betterlog
|
|
99
172
|
}
|
100
173
|
end
|
101
174
|
|
175
|
+
# Formats complex objects into a readable string representation with
|
176
|
+
# nested structure visualization.
|
177
|
+
#
|
178
|
+
# This method recursively processes arrays and hashes, converting them
|
179
|
+
# into indented string representations that show the hierarchical
|
180
|
+
# structure of the data. It handles nested arrays and hashes by
|
181
|
+
# increasing the indentation level for each nesting level, making it
|
182
|
+
# easier to visualize the data structure.
|
183
|
+
#
|
184
|
+
# @param object [ Object ] the object to be formatted, which can be an
|
185
|
+
# array, hash, or any other object
|
186
|
+
# @param depth [ Integer ] the current depth level for indentation, used
|
187
|
+
# internally during recursion
|
188
|
+
# @param nl [ String ] the newline character or string to use for
|
189
|
+
# separating elements
|
190
|
+
# @return [ String ] a formatted string representation of the object,
|
191
|
+
# with proper indentation for nested structures
|
102
192
|
def format_object(object, depth: 0, nl: ?\n)
|
103
193
|
case
|
104
194
|
when a = object.ask_and_send(:to_ary)
|
@@ -2,14 +2,44 @@ require 'term/ansicolor'
|
|
2
2
|
|
3
3
|
module Betterlog
|
4
4
|
class Log
|
5
|
+
# Formats log messages for legacy Rails logging compatibility.
|
6
|
+
#
|
7
|
+
# This class provides a formatter that integrates with Rails' legacy
|
8
|
+
# logging system, converting standard log messages into structured JSON
|
9
|
+
# events while preserving the original formatting behavior for backward
|
10
|
+
# compatibility.
|
11
|
+
#
|
12
|
+
# @see Betterlog::Log::Event
|
13
|
+
# @see ActiveSupport::Logger::Formatter
|
5
14
|
class LegacyEventFormatter < ::ActiveSupport::Logger::Formatter
|
6
15
|
include ActiveSupport::TaggedLogging::Formatter
|
7
16
|
include ComplexConfig::Provider::Shortcuts
|
8
17
|
|
18
|
+
# Returns the emitter identifier string for legacy log events.
|
19
|
+
#
|
20
|
+
# This method provides a constant string value that represents the
|
21
|
+
# emitter type for logs formatted using the legacy event formatter.
|
22
|
+
#
|
23
|
+
# @return [ String ] the string 'legacy' indicating the legacy emitter type
|
9
24
|
def emitter
|
10
25
|
'legacy'
|
11
26
|
end
|
12
27
|
|
28
|
+
# Processes a log message using the legacy formatting approach.
|
29
|
+
#
|
30
|
+
# This method handles the conversion of standard log messages into
|
31
|
+
# structured JSON events when legacy logging support is enabled. It
|
32
|
+
# extracts relevant information from the input message, such as
|
33
|
+
# backtraces and location data, and formats it according to the legacy
|
34
|
+
# event structure.
|
35
|
+
#
|
36
|
+
# @param severity [ String ] the severity level of the log message
|
37
|
+
# @param timestamp [ Time ] the time when the log entry was created
|
38
|
+
# @param program [ String ] the name of the program generating the log
|
39
|
+
# @param message [ String ] the raw log message content
|
40
|
+
#
|
41
|
+
# @return [ String ] the formatted log message, either as a JSON event or
|
42
|
+
# the original message if it's not suitable for conversion
|
13
43
|
def call(severity, timestamp, program, message)
|
14
44
|
if cc.log.legacy_supported
|
15
45
|
if message.blank?
|
@@ -2,13 +2,42 @@ require 'logger'
|
|
2
2
|
|
3
3
|
module Betterlog
|
4
4
|
class Log
|
5
|
+
# A severity level representation for logging events.
|
6
|
+
#
|
7
|
+
# This class provides a structured way to handle logging severity levels,
|
8
|
+
# ensuring consistent formatting and comparison of severity values. It
|
9
|
+
# integrates with Ruby's standard Logger::Severity constants while
|
10
|
+
# providing additional functionality for normalization, caching, and
|
11
|
+
# comparison operations.
|
12
|
+
#
|
13
|
+
# @see Betterlog::Log::Event
|
14
|
+
# @see Logger::Severity
|
5
15
|
class Severity
|
6
16
|
include ::Logger::Severity
|
7
17
|
include Comparable
|
8
18
|
|
9
19
|
class << self
|
20
|
+
|
21
|
+
# Defines a thread-local variable named shared within the class.
|
22
|
+
#
|
23
|
+
# This method sets up a thread-local storage area called shared,
|
24
|
+
# which can be used to store data that is unique to each thread.
|
25
|
+
# It is typically used to maintain state or caches that should
|
26
|
+
# not be shared across different threads in a multi-threaded environment.
|
10
27
|
thread_local :shared
|
11
28
|
|
29
|
+
# Creates a new Severity instance with the given name, normalizing it
|
30
|
+
# to uppercase symbols for consistent lookup.
|
31
|
+
#
|
32
|
+
# This method converts the input name to a standardized format by
|
33
|
+
# converting it to a symbol, uppercasing its string representation, and
|
34
|
+
# then attempting to retrieve or create a corresponding Severity
|
35
|
+
# constant. It ensures that only one instance exists per unique
|
36
|
+
# severity name by using a shared cache.
|
37
|
+
#
|
38
|
+
# @param name [ String, Symbol, Betterlog::Log::Severity ] the severity
|
39
|
+
# name to initialize with
|
40
|
+
# @return [ Betterlog::Log::Severity ] a new or cached severity instance
|
12
41
|
def new(name)
|
13
42
|
name = name.to_sym if self.class === name
|
14
43
|
name = name.to_s.upcase.to_sym
|
@@ -17,6 +46,17 @@ module Betterlog
|
|
17
46
|
end
|
18
47
|
end
|
19
48
|
|
49
|
+
# Initializes a new Severity instance with the given name.
|
50
|
+
#
|
51
|
+
# This constructor creates a severity level object by converting the
|
52
|
+
# input name to a standardized symbol format and attempting to map it to
|
53
|
+
# a corresponding logger severity constant. If the constant is not found,
|
54
|
+
# it defaults to the UNKNOWN severity level.
|
55
|
+
#
|
56
|
+
# @param name [ String, Symbol, Betterlog::Log::Severity ] the severity name
|
57
|
+
# to initialize with, which will be converted to uppercase and normalized
|
58
|
+
# to a symbol for lookup
|
59
|
+
# @return [ Betterlog::Log::Severity ] a new severity instance
|
20
60
|
def initialize(name)
|
21
61
|
name = name.to_sym if self.class === name
|
22
62
|
@name = name.to_s.downcase.to_sym
|
@@ -28,36 +68,100 @@ module Betterlog
|
|
28
68
|
end
|
29
69
|
end
|
30
70
|
|
71
|
+
# Returns an array of all Severity constants as initialized objects.
|
72
|
+
#
|
73
|
+
# This method retrieves all available severity constants defined in the
|
74
|
+
# class and creates a new instance of Severity for each one. The results
|
75
|
+
# are cached in an instance variable to avoid re-computation on
|
76
|
+
# subsequent calls.
|
77
|
+
#
|
78
|
+
# @return [ Array<Betterlog::Log::Severity> ] an array containing Severity
|
79
|
+
# instances for each constant defined in the class
|
31
80
|
def self.all
|
32
81
|
@all_constants ||= constants.map { |c| new(c) }
|
33
82
|
end
|
34
83
|
|
84
|
+
# Converts the severity level to its integer representation.
|
85
|
+
#
|
86
|
+
# This method returns the underlying integer value that represents the
|
87
|
+
# severity level, which corresponds to standard logging severity
|
88
|
+
# constants.
|
89
|
+
#
|
90
|
+
# @return [ Integer ] the integer value of the severity level
|
35
91
|
def to_i
|
36
92
|
@level
|
37
93
|
end
|
38
94
|
|
95
|
+
# Converts the severity name to an uppercase string representation.
|
96
|
+
#
|
97
|
+
# This method returns a string version of the severity name, converted to
|
98
|
+
# uppercase for consistent formatting and display purposes.
|
99
|
+
#
|
100
|
+
# @return [ String ] the uppercase string representation of the severity name
|
39
101
|
def to_s
|
40
102
|
@name.to_s.upcase
|
41
103
|
end
|
42
104
|
|
105
|
+
# Converts the severity name to a symbol representation.
|
106
|
+
#
|
107
|
+
# This method returns the internal symbol representation of the severity
|
108
|
+
# name, which is used for consistent identification and comparison of
|
109
|
+
# severity levels.
|
110
|
+
#
|
111
|
+
# @return [ Symbol ] the symbol representation of the severity name
|
43
112
|
def to_sym
|
44
113
|
@name
|
45
114
|
end
|
46
115
|
|
116
|
+
# Converts the log event to a JSON-compatible hash representation.
|
117
|
+
#
|
118
|
+
# This method provides a way to serialize the log event data into a
|
119
|
+
# format suitable for JSON generation, ensuring that the event's data can
|
120
|
+
# be easily converted to a JSON string while maintaining its structure
|
121
|
+
# and content.
|
122
|
+
#
|
123
|
+
# @return [ Hash ] a hash representation of the log event data
|
47
124
|
def as_json(*)
|
48
125
|
to_s
|
49
126
|
end
|
50
127
|
|
128
|
+
# Compares this severity instance with another value for ordering.
|
129
|
+
#
|
130
|
+
# This method enables sorting and comparison of severity levels by
|
131
|
+
# converting both the current instance and the provided value to their
|
132
|
+
# integer representations and performing a standard numeric comparison.
|
133
|
+
#
|
134
|
+
# @param other [ Object ] the value to compare against, which will be converted
|
135
|
+
# to a Severity instance for comparison
|
136
|
+
# @return [ Integer ] -1 if this instance is less than the other, 0 if they are
|
137
|
+
# equal, 1 if this instance is greater than the other
|
51
138
|
def <=>(other)
|
52
139
|
to_i <=> self.class.new(other).to_i
|
53
140
|
end
|
54
141
|
|
142
|
+
# Checks equality between this severity instance and another object based
|
143
|
+
# on their symbol representations.
|
144
|
+
#
|
145
|
+
# This method compares the symbol representation of the current severity
|
146
|
+
# instance with that of another object to determine if they are
|
147
|
+
# equivalent.
|
148
|
+
#
|
149
|
+
# @param other [ Object ] the object to compare against
|
150
|
+
# @return [ TrueClass, FalseClass ] true if both objects have equal
|
151
|
+
# symbol representations, false otherwise
|
55
152
|
def eql?(other)
|
56
153
|
to_sym == other.to_sym
|
57
154
|
end
|
58
155
|
|
59
156
|
alias == eql?
|
60
157
|
|
158
|
+
# Returns the hash value corresponding to the severity name symbol.
|
159
|
+
#
|
160
|
+
# This method provides a hash representation of the internal symbol
|
161
|
+
# identifier for the severity level, which is used for consistent
|
162
|
+
# identification and comparison operations within the logging system.
|
163
|
+
#
|
164
|
+
# @return [ Integer ] the hash value of the severity name symbol
|
61
165
|
def hash
|
62
166
|
@name.hash
|
63
167
|
end
|
data/lib/betterlog/log.rb
CHANGED
@@ -5,6 +5,16 @@ require 'betterlog/log/event_formatter'
|
|
5
5
|
require 'betterlog/log/severity'
|
6
6
|
|
7
7
|
module Betterlog
|
8
|
+
# A flexible, framework-agnostic logging solution that provides a clean API
|
9
|
+
# for structured logging with automatic Rails integration and error recovery.
|
10
|
+
#
|
11
|
+
# This class implements a singleton pattern using Tins::SexySingleton and
|
12
|
+
# automatically detects Rails environment to use its logger when available.
|
13
|
+
# It supports structured logging with contextual information, location
|
14
|
+
# tracking, and event notification capabilities.
|
15
|
+
#
|
16
|
+
# @example Basic usage
|
17
|
+
# Betterlog::Log.info("User logged in", meta: { user_id: 123 })
|
8
18
|
class Log
|
9
19
|
include Tins::SexySingleton
|
10
20
|
extend ComplexConfig::Provider::Shortcuts
|
@@ -15,6 +25,12 @@ module Betterlog
|
|
15
25
|
default_logger.level = level
|
16
26
|
end
|
17
27
|
|
28
|
+
# Returns the appropriate logger instance for the application.
|
29
|
+
#
|
30
|
+
# This method checks if Rails is defined and has a logger available,
|
31
|
+
# falling back to a default logger otherwise.
|
32
|
+
#
|
33
|
+
# @return [Logger] The Rails logger if available, otherwise the default logger.
|
18
34
|
def logger
|
19
35
|
defined?(Rails) && Rails.respond_to?(:logger) ? Rails.logger : self.class.default_logger
|
20
36
|
end
|
@@ -22,7 +38,7 @@ module Betterlog
|
|
22
38
|
# Logs a message on severity info.
|
23
39
|
#
|
24
40
|
# @param object this object is logged
|
25
|
-
# @param
|
41
|
+
# @param rest additional data is logged as well.
|
26
42
|
# @return [ Log ] this object itself.
|
27
43
|
def info(object, **rest)
|
28
44
|
protect do
|
@@ -34,7 +50,7 @@ module Betterlog
|
|
34
50
|
# Logs a message on severity warn.
|
35
51
|
#
|
36
52
|
# @param object this object is logged
|
37
|
-
# @param
|
53
|
+
# @param rest additional data is logged as well.
|
38
54
|
# @return [ Log ] this object itself.
|
39
55
|
def warn(object, **rest)
|
40
56
|
protect do
|
@@ -46,7 +62,7 @@ module Betterlog
|
|
46
62
|
# Logs a message on severity debug.
|
47
63
|
#
|
48
64
|
# @param object this object is logged
|
49
|
-
# @param
|
65
|
+
# @param rest additional data is logged as well.
|
50
66
|
# @return [ Log ] this object itself.
|
51
67
|
def debug(object, **rest)
|
52
68
|
protect do
|
@@ -58,7 +74,7 @@ module Betterlog
|
|
58
74
|
# Logs a message on severity error.
|
59
75
|
#
|
60
76
|
# @param object this object is logged
|
61
|
-
# @param
|
77
|
+
# @param rest additional data is logged as well.
|
62
78
|
# @return [ Log ] this object itself.
|
63
79
|
def error(object, **rest)
|
64
80
|
protect do
|
@@ -70,7 +86,7 @@ module Betterlog
|
|
70
86
|
# Logs a message on severity fatal.
|
71
87
|
#
|
72
88
|
# @param object this object is logged
|
73
|
-
# @param
|
89
|
+
# @param rest additional data is logged as well.
|
74
90
|
# @return [ Log ] this object itself.
|
75
91
|
def fatal(object, **rest)
|
76
92
|
protect do
|
@@ -83,7 +99,7 @@ module Betterlog
|
|
83
99
|
# passing the severity: keyword.
|
84
100
|
#
|
85
101
|
# @param object this object is logged
|
86
|
-
# @param
|
102
|
+
# @param rest additional data is logged as well.
|
87
103
|
# @return [ Log ] this object itself.
|
88
104
|
def output(object, **rest)
|
89
105
|
protect do
|
@@ -91,10 +107,16 @@ module Betterlog
|
|
91
107
|
end
|
92
108
|
end
|
93
109
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
110
|
+
# Emits a log event by adding contextual information, notifying
|
111
|
+
# subscribers, and logging through the configured logger.
|
112
|
+
#
|
113
|
+
# This method enhances the provided event with location information if
|
114
|
+
# available, sets the emitter identifier, triggers any registered
|
115
|
+
# notifiers, and finally logs the event using the application's logger at
|
116
|
+
# the event's severity level.
|
117
|
+
#
|
118
|
+
# @param event [Betterlog::Log::Event] the log event to be emitted
|
119
|
+
# @return [Betterlog::Log] the log instance itself
|
98
120
|
def emit(event)
|
99
121
|
l = caller_locations.reverse_each.each_cons(3).find { |c, n1, n2|
|
100
122
|
n2.absolute_path =~ /betterlog\/log\.rb/ and break c # TODO check if this still works
|
data/lib/betterlog/notifiers.rb
CHANGED
@@ -1,10 +1,31 @@
|
|
1
1
|
module Betterlog
|
2
|
+
# Module for managing and coordinating log event notifiers.
|
3
|
+
#
|
4
|
+
# This module provides a centralized mechanism for registering and notifying
|
5
|
+
# objects when specific log events occur. It maintains a collection of
|
6
|
+
# notifier instances that can respond to log events, allowing for flexible
|
7
|
+
# integration with external monitoring, alerting, or logging systems.
|
8
|
+
# Notifiers are invoked when log events explicitly request notification,
|
9
|
+
# enabling decoupled communication between the logging system and downstream
|
10
|
+
# services.
|
11
|
+
#
|
12
|
+
# @see Betterlog::Log#emit
|
13
|
+
# @see Betterlog::Log::Event#notify?
|
2
14
|
module Notifiers
|
3
15
|
|
4
16
|
class_attr_accessor :notifiers
|
5
17
|
|
6
18
|
self.notifiers = Set[]
|
7
19
|
|
20
|
+
# Registers a notifier object with the Notifiers module.
|
21
|
+
#
|
22
|
+
# This method adds a notifier to the collection of registered notifiers,
|
23
|
+
# ensuring that it responds to the required notify interface. The notifier
|
24
|
+
# will subsequently be invoked when log events with notification requests
|
25
|
+
# are emitted.
|
26
|
+
#
|
27
|
+
# @param notifier [ Object ] the notifier object to be registered
|
28
|
+
# @return [ Class ] Returns the Notifiers class itself
|
8
29
|
def self.register(notifier)
|
9
30
|
notifier.respond_to?(:notify) or raise TypeError,
|
10
31
|
"notifier has to respond to notify(message, hash) interface"
|
@@ -12,6 +33,14 @@ module Betterlog
|
|
12
33
|
self
|
13
34
|
end
|
14
35
|
|
36
|
+
# Notifies registered notifiers with the event data.
|
37
|
+
#
|
38
|
+
# This method checks if the provided event has notification enabled,
|
39
|
+
# and if so, iterates through all registered notifiers to send them
|
40
|
+
# the event's message and metadata. It also updates the context for
|
41
|
+
# each notifier before sending the notification.
|
42
|
+
#
|
43
|
+
# @param event [Betterlog::Log::Event] the log event to be notified about
|
15
44
|
def self.notify(event)
|
16
45
|
event.notify? or return
|
17
46
|
notifiers.each do |notifier|
|
@@ -20,6 +49,15 @@ module Betterlog
|
|
20
49
|
end
|
21
50
|
end
|
22
51
|
|
52
|
+
# Sets the context for all registered notifiers with the provided data.
|
53
|
+
#
|
54
|
+
# This method iterates through all registered notifiers and invokes their
|
55
|
+
# context method if they respond to it, passing the given data hash to
|
56
|
+
# allow notifiers to update their internal state or configuration based
|
57
|
+
# on the provided context information.
|
58
|
+
#
|
59
|
+
# @param data [ Hash ] A hash containing the context data to be passed
|
60
|
+
# to each notifier that supports the context interface
|
23
61
|
def self.context(data)
|
24
62
|
notifiers.each do |notifier|
|
25
63
|
notifier.respond_to?(:context) or next
|
data/lib/betterlog/railtie.rb
CHANGED
@@ -1,4 +1,12 @@
|
|
1
1
|
module Betterlog
|
2
|
+
# Integrates Betterlog with Rails application initialization.
|
3
|
+
#
|
4
|
+
# This Railtie is responsible for configuring Rails to use Betterlog's legacy event formatter
|
5
|
+
# as the default logger formatter. It ensures that log messages are properly structured
|
6
|
+
# and enriched with metadata when used within a Rails application context.
|
7
|
+
#
|
8
|
+
# @see Betterlog::Log::LegacyEventFormatter
|
9
|
+
# @see Rails::Railtie
|
2
10
|
class Railtie < Rails::Railtie
|
3
11
|
initializer "betterlog_railtie.configure_rails_initialization" do
|
4
12
|
require 'betterlog/log/legacy_event_formatter'
|
data/lib/betterlog/version.rb
CHANGED
data/lib/betterlog.rb
CHANGED
@@ -3,6 +3,12 @@ require 'json'
|
|
3
3
|
require 'complex_config'
|
4
4
|
require 'term/ansicolor'
|
5
5
|
|
6
|
+
# Main module for Betterlog logging functionality.
|
7
|
+
#
|
8
|
+
# Provides structured logging tools designed for betterplace's logging
|
9
|
+
# infrastructure in Rails applications. Offers thread-local metadata
|
10
|
+
# management, event formatting, severity handling, and integration with Rails
|
11
|
+
# logging systems.
|
6
12
|
module Betterlog
|
7
13
|
end
|
8
14
|
|
@@ -16,3 +22,12 @@ if defined? Rails
|
|
16
22
|
end
|
17
23
|
|
18
24
|
Log = Betterlog::Log
|
25
|
+
|
26
|
+
# This class serves as a convenience alias for the Betterlog::Log module,
|
27
|
+
# providing a simple way to access the logging functionality throughout a Rails
|
28
|
+
# application
|
29
|
+
#
|
30
|
+
# @see Betterlog::Log
|
31
|
+
# @see Betterlog
|
32
|
+
class Log
|
33
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betterlog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- betterplace Developers
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: gem_hadar
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '1.
|
18
|
+
version: '1.28'
|
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: '1.
|
25
|
+
version: '1.28'
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rake
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -246,7 +246,8 @@ files:
|
|
246
246
|
- spec/betterlog/version_spec.rb
|
247
247
|
- spec/spec_helper.rb
|
248
248
|
homepage: http://github.com/betterplace/betterlog
|
249
|
-
licenses:
|
249
|
+
licenses:
|
250
|
+
- Apache-2.0
|
250
251
|
metadata: {}
|
251
252
|
rdoc_options:
|
252
253
|
- "--title"
|
@@ -266,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
266
267
|
- !ruby/object:Gem::Version
|
267
268
|
version: '0'
|
268
269
|
requirements: []
|
269
|
-
rubygems_version: 3.6.
|
270
|
+
rubygems_version: 3.6.9
|
270
271
|
specification_version: 4
|
271
272
|
summary: Structured logging support for bp
|
272
273
|
test_files:
|