betterlog 2.1.0 → 2.1.1
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 +338 -0
- data/Rakefile +4 -0
- data/VERSION +1 -1
- data/betterlog.gemspec +4 -3
- data/bin/betterlog +147 -2
- data/lib/betterlog/version.rb +1 -1
- metadata +4 -8
- data/.all_images.yml +0 -18
- data/.github/workflows/codeql-analysis.yml +0 -72
- data/.gitignore +0 -16
- data/.semaphore/semaphore.yml +0 -45
- data/.tool-versions +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f2e9ee107c04ca121cd96cfa729d5f38ffa93ba4fcc72a0b98d9a6eff616177
|
4
|
+
data.tar.gz: c921b345079562a1ea1959fbe357d86ee56a54922cb4d367d8b4c8bdff719d45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e9527c09905b4263af1e541cc6b6c3c48f6712c50fa853b084ec07a29146da16aad4ebaed0d53d1fe6c0f95765d35a0fbdc970d78bd9b60ad105d7ca6c5ce11
|
7
|
+
data.tar.gz: 2155967f4c360239bd4f45b33dfc7af976a9ef302caf1cd949a103167aeaf5d1d0a632c1411b99dfa254d5498ca53d732984fb656ae519df4bb0da1c21a12aaa
|
data/CHANGES.md
ADDED
@@ -0,0 +1,338 @@
|
|
1
|
+
# Changes
|
2
|
+
|
3
|
+
## 2025-09-02 v2.1.1
|
4
|
+
|
5
|
+
- Set required Ruby version to ~> **3.2** in both `Rakefile` and
|
6
|
+
`betterlog.gemspec`
|
7
|
+
- Added `.all_images.yml`, `.tool-versions`, `.gitignore`, and files under
|
8
|
+
`.semaphore/` and `.github/` to package_ignore in `Rakefile`
|
9
|
+
- Added comprehensive documentation to the `Betterlog::App` class, including
|
10
|
+
detailed class documentation, method documentation with parameters and return
|
11
|
+
values, and improved code organization with comments
|
12
|
+
- Removed ruby version **3.1** from the image list in `.all_images.yml`
|
13
|
+
- Added `CHANGES.md` file to document project history and version updates
|
14
|
+
|
15
|
+
## 2025-09-02 v2.1.0
|
16
|
+
|
17
|
+
- Improved documentation and added comprehensive comments throughout Betterlog
|
18
|
+
modules
|
19
|
+
- Updated Ruby version from **3.4.1** to **3.4.5** in tool versions
|
20
|
+
configuration
|
21
|
+
- Removed metric deprecation warning.
|
22
|
+
|
23
|
+
## 2025-02-19 v2.0.6
|
24
|
+
|
25
|
+
- Added `licenses` attribute to GemHadar in Rakefile
|
26
|
+
|
27
|
+
## 2025-02-13 v2.0.5
|
28
|
+
|
29
|
+
- Removed `gem update --system` command from Dockerfile to prevent version
|
30
|
+
changes
|
31
|
+
- Added `yaml-dev` package to `build-base` installation in Dockerfile
|
32
|
+
- Updated `gem install gem_hadar` command in Dockerfile to run without bundler
|
33
|
+
- Added support for Ruby versions **3.4** and **3.3** with new Docker image
|
34
|
+
configurations
|
35
|
+
- Updated `.tool-versions` file to use Ruby version **3.4.1** and removed
|
36
|
+
**2.3.17**
|
37
|
+
|
38
|
+
## 2024-03-13 v2.0.4
|
39
|
+
|
40
|
+
- Improved the legacy event formatter implementation
|
41
|
+
- Updated code to use the new name for the legacy event formatter
|
42
|
+
|
43
|
+
## 2024-03-13 v2.0.3
|
44
|
+
|
45
|
+
- Added global metadata support to the legacy emitter
|
46
|
+
- Renamed and moved the legacy formatter/emitter components
|
47
|
+
- Removed the passing of context to blocks in the code
|
48
|
+
|
49
|
+
## 2024-01-25 v2.0.2
|
50
|
+
|
51
|
+
- Removed the passing of context to block in the codebase
|
52
|
+
- Eliminated unnecessary context parameter handling in block execution flow
|
53
|
+
|
54
|
+
## 2023-08-17 v2.0.1
|
55
|
+
|
56
|
+
- Renamed `with_metadata` method to `with_meta`
|
57
|
+
- Added new `Betterlog.with_meth` convenience method
|
58
|
+
- Updated method names to improve clarity and consistency in logging
|
59
|
+
functionality
|
60
|
+
|
61
|
+
## 2023-08-17 v2.0.0
|
62
|
+
|
63
|
+
- Removed obsolete metric support with warning implementation
|
64
|
+
- Simplified code significantly
|
65
|
+
- Added support for `Betterlog::GlobalMetadata` via block form of
|
66
|
+
`with_context` method
|
67
|
+
- Updated `with_context` method to handle context variable removal properly
|
68
|
+
- Changed behavior to warn about removed metric support instead of maintaining
|
69
|
+
it
|
70
|
+
|
71
|
+
## 2023-08-16 v1.1.1
|
72
|
+
|
73
|
+
- Added Sidekiq context to metadata of regularly emitted events
|
74
|
+
- Enhanced event metadata with Sidekiq information for better tracking and
|
75
|
+
debugging capabilities
|
76
|
+
|
77
|
+
## 2023-02-10 v1.1.0
|
78
|
+
|
79
|
+
- Added context of Sidekiq logger to legacy emitter output
|
80
|
+
- Enhanced logging capabilities by incorporating Sidekiq context information
|
81
|
+
- Improved debugging and monitoring of legacy emitter functionality
|
82
|
+
- Updated logging infrastructure to support Sidekiq integration
|
83
|
+
- Modified emitter output format to include additional contextual information
|
84
|
+
|
85
|
+
## 2023-01-30 v1.0.0
|
86
|
+
|
87
|
+
- Removed the `log_pusher` functionality from the codebase
|
88
|
+
- Eliminated the associated logging mechanism that was previously used for
|
89
|
+
pushing logs
|
90
|
+
|
91
|
+
## 2022-08-18 v0.20.3
|
92
|
+
|
93
|
+
- Added example code to demonstrate usage
|
94
|
+
- Updated build configuration to use Go version **1.17**
|
95
|
+
- Upgraded base image to Alpine **3.14.3**
|
96
|
+
- Removed deprecated `cloudbuild.yaml` file
|
97
|
+
- Implemented proper loading of version specification
|
98
|
+
- Configured CodeQL analysis workflow
|
99
|
+
- Reverted previous message-related changes
|
100
|
+
- Built project from scratch with updated dependencies
|
101
|
+
- Updated build system and tooling configurations
|
102
|
+
|
103
|
+
## 2021-10-28 v0.20.2
|
104
|
+
|
105
|
+
- Reverted previous changes that modified the behavior of passing arguments
|
106
|
+
- Changed implementation to rely on the originally passed argument instead of
|
107
|
+
alternative approaches
|
108
|
+
- Removed modifications that had been previously introduced for argument
|
109
|
+
handling
|
110
|
+
|
111
|
+
## 2021-10-28 v0.20.1
|
112
|
+
|
113
|
+
- Fixed backtrace parsing logic to handle edge cases properly
|
114
|
+
- Corrected backtrace parsing implementation for more reliable error reporting
|
115
|
+
- Improved backtrace parsing to work correctly with **Ruby** version **3.1**+
|
116
|
+
error messages
|
117
|
+
- Enhanced backtrace parsing to properly extract method names and file
|
118
|
+
locations from stack traces
|
119
|
+
|
120
|
+
## 2021-10-26 v0.20.0
|
121
|
+
|
122
|
+
- Modified message coloring behavior to remove colors from JSON output
|
123
|
+
- Updated test execution to continue running tests even when push operations
|
124
|
+
fail
|
125
|
+
|
126
|
+
## 2021-09-21 v0.19.0
|
127
|
+
|
128
|
+
- Upgraded Ruby version to **3.0.2**
|
129
|
+
- Upgraded labstack/echo to specific v4 version
|
130
|
+
- Upgraded Alpine Linux to version **3.14.2**
|
131
|
+
- Upgraded Alpine Linux to version **3.14.1**
|
132
|
+
- Upgraded Alpine Linux to version **3.14**
|
133
|
+
- Upgraded Alpine Linux to version **3.13.5**
|
134
|
+
- Upgraded Alpine Linux to version **3.13.4**
|
135
|
+
- Implemented git SHA tagging for master commits
|
136
|
+
|
137
|
+
## 2021-03-05 v0.18.0
|
138
|
+
|
139
|
+
- Fixed compatibility issue with **Ruby 3.0**
|
140
|
+
- Updated version tag
|
141
|
+
|
142
|
+
## 2021-03-01 v0.17.0
|
143
|
+
|
144
|
+
- Updated base image to **alpine 3.13.2**
|
145
|
+
|
146
|
+
## 2021-02-10 v0.16.0
|
147
|
+
|
148
|
+
- Added check for tag name in the codebase
|
149
|
+
- Upgraded base system to Alpine version **3.13.1**
|
150
|
+
|
151
|
+
## 2021-02-03 v0.15.2
|
152
|
+
|
153
|
+
- Handle invalid UTF-8 characters in log messages
|
154
|
+
- Add bx configuration
|
155
|
+
- Add path configuration
|
156
|
+
- Pass registry name being used
|
157
|
+
- Upgrade dependencies
|
158
|
+
- Base image on alpine:**3.12.3**
|
159
|
+
- Only push on master branch builds
|
160
|
+
|
161
|
+
## 2020-12-07 v0.15.1
|
162
|
+
|
163
|
+
- Move testing configuration to Semaphore CI environment
|
164
|
+
- Improve search syntax implementation
|
165
|
+
|
166
|
+
## 2020-11-02 v0.15.0
|
167
|
+
|
168
|
+
- Added test configuration for Semaphore CI platform
|
169
|
+
- Updated continuous integration setup to include Semaphore testing environment
|
170
|
+
- Configured build pipeline to run tests on Semaphore infrastructure
|
171
|
+
- Integrated Semaphore-specific test execution settings
|
172
|
+
|
173
|
+
## 2020-08-26 v0.14.1
|
174
|
+
|
175
|
+
- Allow log file to be missing during loading process
|
176
|
+
- Handle cases where log file may not exist when loading configuration
|
177
|
+
|
178
|
+
## 2020-07-30 v0.14.0
|
179
|
+
|
180
|
+
- Fixed regexp encoding match problem
|
181
|
+
- Made log level easily configurable
|
182
|
+
|
183
|
+
## 2020-07-20 v0.13.1
|
184
|
+
|
185
|
+
- Replace existence check with boolean method
|
186
|
+
- Upgrade base image to Alpine **3.12.0**
|
187
|
+
|
188
|
+
## 2020-05-12 v0.13.0
|
189
|
+
|
190
|
+
- Updated base image to **alpine 3.11.6**
|
191
|
+
- Modified `kubectl` config name in `betterlog_sink` to use `cluster.name` from
|
192
|
+
configuration instead of hardcoded value
|
193
|
+
|
194
|
+
## 2020-04-20 v0.12.2
|
195
|
+
|
196
|
+
- Added support for using `as_json` method for automatic serialization
|
197
|
+
- Enabled automatic serialization functionality when `as_json` is present
|
198
|
+
|
199
|
+
## 2020-04-02 v0.12.1
|
200
|
+
|
201
|
+
- Updated output handling to include **false** values in addition to previously
|
202
|
+
handled values
|
203
|
+
- Modified the output logic to ensure boolean **false** is properly processed
|
204
|
+
and displayed
|
205
|
+
|
206
|
+
## 2020-04-02 v0.12.0
|
207
|
+
|
208
|
+
- Added ability to evaluate block results and log with metric
|
209
|
+
- Implemented new functionality for block result evaluation
|
210
|
+
- Enhanced logging capabilities with metric support
|
211
|
+
- Updated code to support metric-based logging of block evaluations
|
212
|
+
- Modified evaluation logic to incorporate metric tracking
|
213
|
+
- Added logging infrastructure for block result metrics
|
214
|
+
- Improved block evaluation reporting with metric integration
|
215
|
+
|
216
|
+
## 2020-04-02 v0.11.0
|
217
|
+
|
218
|
+
- Simplified the interface by refactoring code structure
|
219
|
+
- Improved CLI command implementation for better usability
|
220
|
+
- Updated build configuration to target Alpine Linux version **3.11.5**
|
221
|
+
- Switched to using `better-builder` for enhanced build capabilities
|
222
|
+
|
223
|
+
## 2020-01-22 v0.10.0
|
224
|
+
|
225
|
+
- Handle intermittent redis failover events with liberal logging to a fallback
|
226
|
+
logger
|
227
|
+
- Fallback to a standard stderr logger when redis has connection problems,
|
228
|
+
particularly during failover events
|
229
|
+
- Mute output and use expect instead for improved behavior
|
230
|
+
- Improve output formatting
|
231
|
+
- Add support for testing on Ruby **2.7**
|
232
|
+
- Include Redis failover fixes
|
233
|
+
- Add `cloudbuild.yaml` configuration file
|
234
|
+
|
235
|
+
## 2020-01-17 v0.9.0
|
236
|
+
|
237
|
+
- Added support for using sentinel configuration for high availability Redis
|
238
|
+
setups
|
239
|
+
- Included `error_class` in the pl (package list) command output format
|
240
|
+
|
241
|
+
## 2019-11-15 v0.8.1
|
242
|
+
|
243
|
+
- Fixed the output format of metrics in the `Metric` class
|
244
|
+
- Repurposed the `type` attribute to function as a metric identifier across all
|
245
|
+
metrics
|
246
|
+
- Updated metric handling to use `metric` as the primary classification instead
|
247
|
+
of `type`
|
248
|
+
|
249
|
+
## 2019-11-15 v0.8.0
|
250
|
+
|
251
|
+
- Changed the keyword arguments and semantics of the `Log.metric` method
|
252
|
+
- Updated the `Log.metric` method to support new parameter handling
|
253
|
+
- Modified how metric data is processed and stored within the logging system
|
254
|
+
- Adjusted internal logic for metric collection and reporting
|
255
|
+
- Enhanced flexibility in how metrics are configured and used throughout the
|
256
|
+
application
|
257
|
+
|
258
|
+
## 2019-11-06 v0.7.2
|
259
|
+
|
260
|
+
- Prevented honeybadger notifier from modifying its argument, which caused
|
261
|
+
circular reference issues
|
262
|
+
- Removed original hash from being passed to honeybadger as it corrupts the
|
263
|
+
data structure
|
264
|
+
- Fixed circular reference problem in honeybadger integration by avoiding
|
265
|
+
modification of notifier arguments
|
266
|
+
- Ensured honeybadger does not ruin the original hash by not passing it through
|
267
|
+
- Addressed issue where honeybadger was modifying its input argument causing
|
268
|
+
unexpected behavior
|
269
|
+
|
270
|
+
## 2019-11-01 v0.7.1
|
271
|
+
|
272
|
+
- Fixed casing issues in the codebase
|
273
|
+
- Updated version number to **1.5.0**
|
274
|
+
|
275
|
+
## 2019-10-31 v0.7.0
|
276
|
+
|
277
|
+
- Allow configuration using `redis_url` directly by catching
|
278
|
+
`Redis::CannotConnectError` to prevent application crashes and disable
|
279
|
+
logging instead
|
280
|
+
- Implement flyweight pattern on `Betterlog::Log::Severity` constant wrapper
|
281
|
+
for improved performance
|
282
|
+
- Add test for circular regression with repeated immediate objects
|
283
|
+
- Use `tins symbolize_keys_recursive` to handle circular data structures
|
284
|
+
- Fix clobbering of repeated scalar values in configuration
|
285
|
+
- Switch to using `go mod` for package management
|
286
|
+
- Add server and clients for logging functionality
|
287
|
+
|
288
|
+
## 2019-07-22 v0.6.1
|
289
|
+
|
290
|
+
- Made `maximum buffer_size` configurable through a new configuration option
|
291
|
+
- Added ability to customize the buffer size limit for data processing
|
292
|
+
operations
|
293
|
+
|
294
|
+
## 2019-07-18 v0.6.0
|
295
|
+
|
296
|
+
- Updated implementation to actually perform the actions previously only
|
297
|
+
announced
|
298
|
+
- Fixed discrepancy between declared functionality and actual code behavior
|
299
|
+
- Ensured proper execution of intended operations in the codebase
|
300
|
+
|
301
|
+
## 2019-07-18 v0.5.0
|
302
|
+
|
303
|
+
- Fixed implementation to actually perform the intended behavior as announced
|
304
|
+
in previous commit
|
305
|
+
- Corrected logic to properly handle the expected functionality for **v3.5.0**
|
306
|
+
release
|
307
|
+
|
308
|
+
## 2019-07-17 v0.4.0
|
309
|
+
|
310
|
+
- Added lock mechanism to `betterlog_pusher` to ensure the task runs only once,
|
311
|
+
preventing issues during scalingo deployments where the task might start
|
312
|
+
multiple times simultaneously
|
313
|
+
- Improved test specifications
|
314
|
+
- Added configuration hints for better user guidance
|
315
|
+
- Updated example `log.yml` configuration file
|
316
|
+
- Enhanced documentation with additional information
|
317
|
+
|
318
|
+
## 2019-07-15 v0.3.0
|
319
|
+
|
320
|
+
- Added `betterlog_sink` command and sink to path
|
321
|
+
- Updated dependency to use the newest version of `gem_hadar` **1.0.0**
|
322
|
+
|
323
|
+
## 2019-07-04 v0.2.2
|
324
|
+
|
325
|
+
- Added support for providing health page in disabled SSL mode
|
326
|
+
- Moved some code into separate files to improve organization
|
327
|
+
- Bumped version number to **0.15.0**
|
328
|
+
|
329
|
+
## 2019-06-27 v0.2.1
|
330
|
+
|
331
|
+
- Logger configuration still requires manual setup
|
332
|
+
- The `Logger` component needs explicit configuration rather than automatic
|
333
|
+
initialization
|
334
|
+
- Users must manually configure the logger settings in their applications
|
335
|
+
|
336
|
+
## 2019-06-27 v0.2.0
|
337
|
+
|
338
|
+
* Start
|
data/Rakefile
CHANGED
@@ -14,11 +14,15 @@ GemHadar do
|
|
14
14
|
'.ruby-version', '.AppleDouble', 'tags', '.DS_Store', '.utilsrc',
|
15
15
|
'.bundle', '.byebug_history', 'errors.lst', '.yardoc', 'betterlog-server',
|
16
16
|
'gospace'
|
17
|
+
package_ignore '.all_images.yml', '.utilsrc', '.rspec', '.tool-versions',
|
18
|
+
'.gitignore', *Dir['.semaphore/**/*'], *Dir['.github/**/*']
|
17
19
|
readme 'README.md'
|
18
20
|
title "#{name.camelize}"
|
19
21
|
executables %w[ betterlog ]
|
20
22
|
licenses << 'Apache-2.0'
|
21
23
|
|
24
|
+
required_ruby_version '~> 3.2'
|
25
|
+
|
22
26
|
dependency 'tins', '~>1.3', '>=1.22.0'
|
23
27
|
dependency 'complex_config'
|
24
28
|
dependency 'file-tail', '~>1.0'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.1
|
data/betterlog.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: betterlog 2.1.
|
2
|
+
# stub: betterlog 2.1.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "betterlog".freeze
|
6
|
-
s.version = "2.1.
|
6
|
+
s.version = "2.1.1".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]
|
@@ -13,10 +13,11 @@ Gem::Specification.new do |s|
|
|
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
|
-
s.files = [".
|
16
|
+
s.files = ["CHANGES.md".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
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("~> 3.2".freeze)
|
20
21
|
s.rubygems_version = "3.6.9".freeze
|
21
22
|
s.summary = "Structured logging support for bp".freeze
|
22
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]
|
data/bin/betterlog
CHANGED
@@ -7,7 +7,43 @@ require 'zlib'
|
|
7
7
|
require 'file/tail'
|
8
8
|
|
9
9
|
module Betterlog
|
10
|
+
# The main application class responsible for processing command-line arguments,
|
11
|
+
# configuring log filtering and formatting options, and orchestrating the core
|
12
|
+
# log processing workflow.
|
13
|
+
#
|
14
|
+
# This class serves as the entry point for the betterlog CLI tool. It handles
|
15
|
+
# argument parsing, configuration of filters (severity, search terms, emitters),
|
16
|
+
# and manages the different modes of operation including file following,
|
17
|
+
# stdin filtering, and file-based processing.
|
18
|
+
#
|
19
|
+
# The application supports various features such as:
|
20
|
+
# - Real-time log file monitoring with -f flag
|
21
|
+
# - Severity-based filtering with -S flag
|
22
|
+
# - Search term matching with -s flag
|
23
|
+
# - Configuration file shortcuts with -F flag
|
24
|
+
# - Pretty-printing with color support via -p and -c flags
|
25
|
+
# - Support for gzipped log files
|
26
|
+
# - Multiple log source handling
|
27
|
+
#
|
28
|
+
# Example usage:
|
29
|
+
# # Follow Rails logs in long format with colors for errors or greater
|
30
|
+
# $ betterlog -f -F rails -p long -c -S ">=error"
|
31
|
+
#
|
32
|
+
# # Match any event containing SELECT
|
33
|
+
# $ betterlog -f -s SELECT
|
34
|
+
#
|
35
|
+
# # Follow multiple log files with default format in colors
|
36
|
+
# $ betterlog -f -F rails -F redis -pd -c -n 10
|
10
37
|
class App
|
38
|
+
# Initializes a new instance with command-line arguments.
|
39
|
+
#
|
40
|
+
# This constructor sets up the object by processing command-line arguments,
|
41
|
+
# configuring options for filtering and formatting, and preparing the
|
42
|
+
# internal state for log processing operations.
|
43
|
+
#
|
44
|
+
# @param args [ Array<String> ] an array of command-line arguments to be
|
45
|
+
# processed @return [ Betterlog::CLI ] returns the initialized instance
|
46
|
+
# itself
|
11
47
|
def initialize(args = ARGV.dup)
|
12
48
|
STDOUT.sync = true
|
13
49
|
@args = args
|
@@ -16,8 +52,17 @@ module Betterlog
|
|
16
52
|
@opts[?h] and usage
|
17
53
|
end
|
18
54
|
|
55
|
+
# Displays the usage information and help text for the betterlog command.
|
56
|
+
#
|
57
|
+
# This method outputs a formatted help message that describes the available
|
58
|
+
# command-line options, format specifiers, severity levels, and configuration
|
59
|
+
# file shortcuts for the betterlog tool. It provides examples of common usage
|
60
|
+
# patterns and then exits the program with a success status.
|
61
|
+
#
|
62
|
+
# @see Betterlog::Log::Severity#all
|
63
|
+
# @see ComplexConfig::Settings#attribute_names
|
19
64
|
def usage
|
20
|
-
puts <<~
|
65
|
+
puts <<~EOT
|
21
66
|
Usage: #{prog} [OPTIONS] [LOGFILES]
|
22
67
|
|
23
68
|
Options are
|
@@ -70,11 +115,17 @@ module Betterlog
|
|
70
115
|
|
71
116
|
$ betterlog -n 10 unicorn.log
|
72
117
|
|
73
|
-
|
118
|
+
EOT
|
74
119
|
exit(0)
|
75
120
|
end
|
76
121
|
|
77
122
|
private\
|
123
|
+
# Filters log severities based on command-line options.
|
124
|
+
#
|
125
|
+
# This method processes the configured severity filters from the options hash,
|
126
|
+
# applying inclusive and exclusive selection criteria to narrow down the
|
127
|
+
# available severity levels. It supports comparison operators for range-based
|
128
|
+
# filtering and exact matches for specific severities.
|
78
129
|
def filter_severities
|
79
130
|
@severities = Log::Severity.all
|
80
131
|
if severity = @opts[?S]
|
@@ -90,14 +141,37 @@ module Betterlog
|
|
90
141
|
end
|
91
142
|
end
|
92
143
|
|
144
|
+
# Returns the base name of the current program file.
|
145
|
+
#
|
146
|
+
# This method extracts and returns the file name portion of the script
|
147
|
+
# being executed, excluding any directory path components.
|
148
|
+
#
|
149
|
+
# @return [ String ] the base name of the current program file
|
93
150
|
def prog
|
94
151
|
File.basename($0)
|
95
152
|
end
|
96
153
|
|
154
|
+
# Returns the emitters option value as an array.
|
155
|
+
#
|
156
|
+
# This method retrieves the emitters option from the internal options hash
|
157
|
+
# and ensures it is returned as an array format, even if it was originally
|
158
|
+
# provided as a single value.
|
159
|
+
#
|
160
|
+
# @return [ Array ] the array of emitters, or an empty array if none were
|
161
|
+
# specified
|
97
162
|
def emitters
|
98
163
|
Array(@opts[?e])
|
99
164
|
end
|
100
165
|
|
166
|
+
# Checks if a log event matches the specified search criteria.
|
167
|
+
#
|
168
|
+
# This method evaluates whether a given log event satisfies the search
|
169
|
+
# parameters defined in the instance options. It supports searching within
|
170
|
+
# nested hash values and direct string matching against the JSON
|
171
|
+
# representation of the event.
|
172
|
+
#
|
173
|
+
# @param event [ Betterlog::Log::Event ] the log event to be checked against the search criteria
|
174
|
+
# @return [ TrueClass, FalseClass ] true if the event matches all search criteria, false otherwise
|
101
175
|
def search_matched?(event)
|
102
176
|
return true unless @opts[?s]
|
103
177
|
@opts[?s].all? do |param|
|
@@ -114,6 +188,15 @@ module Betterlog
|
|
114
188
|
end
|
115
189
|
end
|
116
190
|
|
191
|
+
# Outputs a formatted log event to the console based on configured options and filters.
|
192
|
+
#
|
193
|
+
# This method processes a log event by checking if it matches the configured severity
|
194
|
+
# levels, emitters, and search criteria. If the event passes all filters, it formats
|
195
|
+
# the event according to the specified output options and prints it to standard output.
|
196
|
+
# The formatting can be JSON, a custom format, or a simple string representation.
|
197
|
+
#
|
198
|
+
# @param prefix [ String ] A string to prepend to the formatted event output
|
199
|
+
# @param event [ Betterlog::Log::Event ] The log event to be processed and displayed
|
117
200
|
def output_log_event(prefix, event)
|
118
201
|
return unless @severities.include?(event.severity)
|
119
202
|
return if emitters.full? && !emitters.include?(event.emitter)
|
@@ -128,6 +211,17 @@ module Betterlog
|
|
128
211
|
end
|
129
212
|
end
|
130
213
|
|
214
|
+
# Parses a log line and outputs it as a structured event or plain text.
|
215
|
+
#
|
216
|
+
# This method processes a log line by attempting to parse it as a
|
217
|
+
# structured log event. If parsing succeeds, the event is formatted and
|
218
|
+
# displayed with an optional filename prefix. If the line doesn't match the
|
219
|
+
# expected structured format but appears to have an ISO timestamp prefix,
|
220
|
+
# it creates a new event from that data. Otherwise, the raw line is output
|
221
|
+
# as-is unless error handling is enabled.
|
222
|
+
#
|
223
|
+
# @param l [ String ] the log line to process
|
224
|
+
# @param filename [ String, nil ] the name of the file the log line came from
|
131
225
|
def output_log_line(l, filename)
|
132
226
|
l.blank? and return
|
133
227
|
prefix =
|
@@ -152,6 +246,16 @@ module Betterlog
|
|
152
246
|
@opts[?e] or puts "#{prefix}#{l}"
|
153
247
|
end
|
154
248
|
|
249
|
+
# Processes configuration file arguments based on command-line options and
|
250
|
+
# configuration settings.
|
251
|
+
#
|
252
|
+
# This method handles the logic for resolving and expanding configuration
|
253
|
+
# file references provided via the -F command-line flag or falling back to
|
254
|
+
# default Rails configuration files. It ensures that the resulting argument
|
255
|
+
# list contains unique filenames after processing.
|
256
|
+
#
|
257
|
+
# @param args [ Array<String> ] The array of arguments to be processed
|
258
|
+
# @return [ Array<String> ] The processed and deduplicated array of filenames
|
155
259
|
def query_config_file_configuration
|
156
260
|
if @opts[?F]
|
157
261
|
if cfs = cc.log.config_files?
|
@@ -172,6 +276,16 @@ module Betterlog
|
|
172
276
|
@args.uniq!
|
173
277
|
end
|
174
278
|
|
279
|
+
# Follows log files and outputs their contents in real-time.
|
280
|
+
#
|
281
|
+
# This method sets up a file tailing mechanism to monitor specified log
|
282
|
+
# files for new content. It creates a group of files to tail, configures
|
283
|
+
# the polling interval, and starts a background thread to process new lines
|
284
|
+
# as they are written to the files. The method handles cases where files do
|
285
|
+
# not exist by outputting a warning message and skipping those files.
|
286
|
+
#
|
287
|
+
# @see File::Tail::Group
|
288
|
+
# @see File::Tail::File
|
175
289
|
def follow_files
|
176
290
|
group = File::Tail::Group.new
|
177
291
|
@args.each do |f|
|
@@ -189,6 +303,16 @@ module Betterlog
|
|
189
303
|
rescue Interrupt
|
190
304
|
end
|
191
305
|
|
306
|
+
# Filters log files from command line arguments, processing each file line
|
307
|
+
# by line.
|
308
|
+
#
|
309
|
+
# This method iterates over the provided file paths, checking their
|
310
|
+
# existence and processing them accordingly. For gzipped files, it uses
|
311
|
+
# Zlib::GzipReader to decompress and read the content. For regular files,
|
312
|
+
# it uses File::Tail::Logfile to read the lines. Each line is then passed
|
313
|
+
# to the output_log_line method for further processing.
|
314
|
+
#
|
315
|
+
# @param args [ Array<String> ] An array of file paths to be processed
|
192
316
|
def filter_argv
|
193
317
|
for fn in @args
|
194
318
|
unless File.exist?(fn)
|
@@ -212,12 +336,25 @@ module Betterlog
|
|
212
336
|
end
|
213
337
|
end
|
214
338
|
|
339
|
+
# Processes each line from standard input and outputs formatted log lines.
|
340
|
+
#
|
341
|
+
# This method reads all lines from STDIN and passes each line to the
|
342
|
+
# output_log_line method for processing and formatting. It is typically
|
343
|
+
# used to filter or transform log data coming from stdin before outputting
|
344
|
+
# it.
|
345
|
+
#
|
346
|
+
# @param _ [ nil ] This method does not require any parameters
|
215
347
|
def filter_stdin
|
216
348
|
STDIN.each_line do |l|
|
217
349
|
output_log_line(l, nil)
|
218
350
|
end
|
219
351
|
end
|
220
352
|
|
353
|
+
# Outputs log source information to standard error.
|
354
|
+
#
|
355
|
+
# This method prints information about the log sources being tracked to
|
356
|
+
# standard error, including whether stdin or specific files are being
|
357
|
+
# monitored, along with the configured severity levels.
|
221
358
|
def output_log_sources
|
222
359
|
if @args.empty?
|
223
360
|
STDERR.puts "#{prog} tracking stdin\nseverities: #{@severities * ?|}"
|
@@ -228,6 +365,14 @@ module Betterlog
|
|
228
365
|
end
|
229
366
|
end
|
230
367
|
|
368
|
+
# Runs the main application logic based on command-line options and
|
369
|
+
# arguments.
|
370
|
+
#
|
371
|
+
# This method orchestrates the core functionality of the application by
|
372
|
+
# determining the appropriate logging behavior based on the provided
|
373
|
+
# command-line flags and input sources. It handles file following,
|
374
|
+
# filtering from standard input, or filtering from command-line arguments
|
375
|
+
# depending on the configuration.
|
231
376
|
def run
|
232
377
|
if @opts[?f]
|
233
378
|
query_config_file_configuration
|
data/lib/betterlog/version.rb
CHANGED
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.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- betterplace Developers
|
@@ -215,11 +215,7 @@ extra_rdoc_files:
|
|
215
215
|
- lib/betterlog/railtie.rb
|
216
216
|
- lib/betterlog/version.rb
|
217
217
|
files:
|
218
|
-
-
|
219
|
-
- ".github/workflows/codeql-analysis.yml"
|
220
|
-
- ".gitignore"
|
221
|
-
- ".semaphore/semaphore.yml"
|
222
|
-
- ".tool-versions"
|
218
|
+
- CHANGES.md
|
223
219
|
- Gemfile
|
224
220
|
- LICENSE
|
225
221
|
- README.md
|
@@ -258,9 +254,9 @@ require_paths:
|
|
258
254
|
- lib
|
259
255
|
required_ruby_version: !ruby/object:Gem::Requirement
|
260
256
|
requirements:
|
261
|
-
- - "
|
257
|
+
- - "~>"
|
262
258
|
- !ruby/object:Gem::Version
|
263
|
-
version: '
|
259
|
+
version: '3.2'
|
264
260
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
265
261
|
requirements:
|
266
262
|
- - ">="
|
data/.all_images.yml
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
dockerfile: |-
|
2
|
-
RUN apk add --no-cache yaml-dev build-base git
|
3
|
-
RUN gem install gem_hadar
|
4
|
-
|
5
|
-
script: &script |-
|
6
|
-
echo -e "\e[1m"
|
7
|
-
ruby -v
|
8
|
-
echo -e "\e[0m"
|
9
|
-
bundle
|
10
|
-
rake spec
|
11
|
-
|
12
|
-
fail_fast: yes
|
13
|
-
|
14
|
-
images:
|
15
|
-
ruby:3.4-alpine: *script
|
16
|
-
ruby:3.3-alpine: *script
|
17
|
-
ruby:3.2-alpine: *script
|
18
|
-
ruby:3.1-alpine: *script
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# For most projects, this workflow file will not need changing; you simply need
|
2
|
-
# to commit it to your repository.
|
3
|
-
#
|
4
|
-
# You may wish to alter this file to override the set of languages analyzed,
|
5
|
-
# or to provide custom queries or build logic.
|
6
|
-
#
|
7
|
-
# ******** NOTE ********
|
8
|
-
# We have attempted to detect the languages in your repository. Please check
|
9
|
-
# the `language` matrix defined below to confirm you have the correct set of
|
10
|
-
# supported CodeQL languages.
|
11
|
-
#
|
12
|
-
name: "CodeQL"
|
13
|
-
|
14
|
-
on:
|
15
|
-
push:
|
16
|
-
branches: [ master ]
|
17
|
-
pull_request:
|
18
|
-
# The branches below must be a subset of the branches above
|
19
|
-
branches: [ master ]
|
20
|
-
schedule:
|
21
|
-
- cron: '27 21 * * 1'
|
22
|
-
|
23
|
-
jobs:
|
24
|
-
analyze:
|
25
|
-
name: Analyze
|
26
|
-
runs-on: ubuntu-latest
|
27
|
-
permissions:
|
28
|
-
actions: read
|
29
|
-
contents: read
|
30
|
-
security-events: write
|
31
|
-
|
32
|
-
strategy:
|
33
|
-
fail-fast: false
|
34
|
-
matrix:
|
35
|
-
language: [ 'go', 'ruby' ]
|
36
|
-
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
37
|
-
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
38
|
-
|
39
|
-
steps:
|
40
|
-
- name: Checkout repository
|
41
|
-
uses: actions/checkout@v3
|
42
|
-
|
43
|
-
# Initializes the CodeQL tools for scanning.
|
44
|
-
- name: Initialize CodeQL
|
45
|
-
uses: github/codeql-action/init@v2
|
46
|
-
with:
|
47
|
-
languages: ${{ matrix.language }}
|
48
|
-
# If you wish to specify custom queries, you can do so here or in a config file.
|
49
|
-
# By default, queries listed here will override any specified in a config file.
|
50
|
-
# Prefix the list here with "+" to use these queries and those in the config file.
|
51
|
-
|
52
|
-
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
53
|
-
# queries: security-extended,security-and-quality
|
54
|
-
|
55
|
-
|
56
|
-
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
57
|
-
# If this step fails, then you should remove it and run the build manually (see below)
|
58
|
-
- name: Autobuild
|
59
|
-
uses: github/codeql-action/autobuild@v2
|
60
|
-
|
61
|
-
# ℹ️ Command-line programs to run using the OS shell.
|
62
|
-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
63
|
-
|
64
|
-
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
65
|
-
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
66
|
-
|
67
|
-
# - run: |
|
68
|
-
# echo "Run, Build Application using script"
|
69
|
-
# ./location_of_script_within_repo/buildscript.sh
|
70
|
-
|
71
|
-
- name: Perform CodeQL Analysis
|
72
|
-
uses: github/codeql-action/analyze@v2
|
data/.gitignore
DELETED
data/.semaphore/semaphore.yml
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
version: v1.0
|
2
|
-
name: Betterlog pipeline
|
3
|
-
agent:
|
4
|
-
machine:
|
5
|
-
type: e1-standard-2
|
6
|
-
os_image: ubuntu2004
|
7
|
-
|
8
|
-
blocks:
|
9
|
-
- name: Caching
|
10
|
-
task:
|
11
|
-
prologue:
|
12
|
-
commands:
|
13
|
-
- checkout
|
14
|
-
jobs:
|
15
|
-
- name: cache bundle
|
16
|
-
commands:
|
17
|
-
- sem-version ruby $(awk '/^ruby/ { print $2 }' .tool-versions)
|
18
|
-
- cache restore gems-$SEMAPHORE_GIT_BRANCH,gems-master
|
19
|
-
- bundle config set path 'vendor/bundle'
|
20
|
-
- bundle config jobs $(getconf _NPROCESSORS_ONLN)
|
21
|
-
- bundle install
|
22
|
-
- cache store gems-$SEMAPHORE_GIT_BRANCH vendor/bundle
|
23
|
-
|
24
|
-
- name: "Unit tests"
|
25
|
-
task:
|
26
|
-
env_vars:
|
27
|
-
- name: RAILS_ENV
|
28
|
-
value: test
|
29
|
-
prologue:
|
30
|
-
commands:
|
31
|
-
- checkout
|
32
|
-
|
33
|
-
# Setup ruby
|
34
|
-
- sem-version ruby $(awk '/^ruby/ { print $2 }' .tool-versions)
|
35
|
-
|
36
|
-
# Setup gems
|
37
|
-
- cache restore gems-$SEMAPHORE_GIT_BRANCH,gems-master
|
38
|
-
- bundle config set path 'vendor/bundle'
|
39
|
-
- bundle config jobs $(getconf _NPROCESSORS_ONLN)
|
40
|
-
- bundle install
|
41
|
-
|
42
|
-
jobs:
|
43
|
-
- name: RSpec Unit Tests
|
44
|
-
commands:
|
45
|
-
- bundle exec rake
|
data/.tool-versions
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ruby 3.4.5
|