researchable_loggable 1.6.0 → 1.7.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/CHANGELOG.md +7 -0
- data/README.md +17 -12
- data/lib/loggable/railtie.rb +16 -7
- data/lib/loggable/version.rb +1 -1
- data/node_modules/semantic-release-rubygem/src/__tests__/fixtures/valid/lib/test-gem/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26d7a5d5e93a66cb06484a698b260df9ac1867adef2dbb61085a9f420881da2e
|
4
|
+
data.tar.gz: 0b59c63f4400c28f3c1f562928f42d3a2de4c458248744ae265149079d310294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0b20c2fdae4e7cc063453d3e225bdfcb4049e4253c203f40a517c5d08679f0dd1233f5d4a1bf2ea84235a6cca70689e6d92189ed87fb6aafb4041ec68566dab
|
7
|
+
data.tar.gz: d9ddd309f6d6e38af84acf6aad3854e27519be1af7aaa6f3539dc1c736c0ae7520ba9af3557948e3db75176d09efdf29d8265afa4f68e6c853d4838b35f10fe6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# [1.7.0](https://gitlab.com/researchable/general/gems/loggable/compare/v1.6.0...v1.7.0) (2025-02-27)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* add disable_open_telemetry option ([7aa227b](https://gitlab.com/researchable/general/gems/loggable/commit/7aa227b4d0c4cc5392660581e541da0e408c0619))
|
7
|
+
|
1
8
|
# [1.6.0](https://gitlab.com/researchable/general/gems/loggable/compare/v1.5.1...v1.6.0) (2025-01-15)
|
2
9
|
|
3
10
|
|
data/README.md
CHANGED
@@ -30,12 +30,12 @@ readable form. Development logs remain unaffected (see [Usage](#usage) for more
|
|
30
30
|
|
31
31
|
## How it works
|
32
32
|
Loggable is a Railtie that overrides the default rails logger configuration. Right from the initialization process, the
|
33
|
-
logger is set to `::EcsLogging::Logger` and the default log level is set to `INFO` (this can be overridden in
|
34
|
-
application.rb or your environment configuration). It also configures lograge automatically. Note that the
|
33
|
+
logger is set to `::EcsLogging::Logger` and the default log level is set to `INFO` (this can be overridden in
|
34
|
+
application.rb or your environment configuration). It also configures lograge automatically. Note that the
|
35
35
|
base_controller_class is set to `'ApplicationController'`. All your controllers should extend from this class.
|
36
36
|
|
37
37
|
By default lograge and ::EcsLogging::Logger are not mutually compatible. The ECS formatter will try to render the output
|
38
|
-
of lograge as the message, however some of the fields in the lograge output are metadata. To fix this, this gem uses a
|
38
|
+
of lograge as the message, however some of the fields in the lograge output are metadata. To fix this, this gem uses a
|
39
39
|
monkey patch on the ECS gem that flattens the lograge output onto the Ecs object.
|
40
40
|
|
41
41
|
## Installation
|
@@ -65,11 +65,11 @@ gem will automatically configure the Rails logger and lograge to follow the Rese
|
|
65
65
|
### Parameters
|
66
66
|
This are the parameters that can be configured in the `config.loggable` namespace:
|
67
67
|
|
68
|
-
`production_like`. By default loggable will only
|
69
|
-
modify how the logs look on production. This is because the format that this gem enforces is slightly less
|
70
|
-
human readable (in favour of machine readability and compatibility with the Elastic Common Schema) than the default
|
68
|
+
`production_like`. By default loggable will only
|
69
|
+
modify how the logs look on production. This is because the format that this gem enforces is slightly less
|
70
|
+
human readable (in favour of machine readability and compatibility with the Elastic Common Schema) than the default
|
71
71
|
Rails one. For development, the more human readable format is preferred. However, if you want to override this and
|
72
|
-
log in the production format while on development (e.g. because you are troubleshooting a problem with the logs or you
|
72
|
+
log in the production format while on development (e.g. because you are troubleshooting a problem with the logs or you
|
73
73
|
are developing against this gem) then you may add the following to your `config/environment/development.rb` file:
|
74
74
|
```ruby
|
75
75
|
config.loggable.production_like = true
|
@@ -81,17 +81,22 @@ config.loggable.current_user_method = :my_current_user_method
|
|
81
81
|
```
|
82
82
|
This method is used for ECS logging, if the method is not found, the user.id field will be set to nil.
|
83
83
|
|
84
|
+
`disable_open_telemetry`. By default, loggable will try to inject the open telemetry trace ids into the log line. If you want to disable this, you may add the following to your `config/application.rb` file:
|
85
|
+
```ruby
|
86
|
+
config.loggable.disable_open_telemetry = true
|
87
|
+
```
|
88
|
+
|
84
89
|
No other configuration options are provided because this gem seeks to enforce consistency across all applications.
|
85
90
|
|
86
91
|
For applications that already had some level of log customization, some cleanup might be needed:
|
87
92
|
|
88
|
-
1. If lograge was added to the Gemfile already, it may be removed. Loggable relies on lograge internally, and will
|
93
|
+
1. If lograge was added to the Gemfile already, it may be removed. Loggable relies on lograge internally, and will
|
89
94
|
make it available to the Rails application.
|
90
95
|
2. Consequently, remove `config/lograge.rb` and all lograge related configuration.
|
91
|
-
3. Remove all existing log configuration, specially for production environments. Places to look for this
|
92
|
-
configuration are `config/application.rb` and `config/environment/production.rb`. If you chose to enable
|
93
|
-
`production_like` mode on your development environment, you might also want to cleanup
|
94
|
-
`config/environment/development.rb`. Things to look for when cleaning up are statements like `config.logger` and
|
96
|
+
3. Remove all existing log configuration, specially for production environments. Places to look for this
|
97
|
+
configuration are `config/application.rb` and `config/environment/production.rb`. If you chose to enable
|
98
|
+
`production_like` mode on your development environment, you might also want to cleanup
|
99
|
+
`config/environment/development.rb`. Things to look for when cleaning up are statements like `config.logger` and
|
95
100
|
`config.log_formatter` and anything with the word `log` or `logger` in it.
|
96
101
|
|
97
102
|
## Development
|
data/lib/loggable/railtie.rb
CHANGED
@@ -18,6 +18,8 @@ module Loggable
|
|
18
18
|
initializer :loggable_web, before: :initialize_logger do
|
19
19
|
Rails.application.configure do
|
20
20
|
production_like = Rails.env.production? || config.loggable.production_like
|
21
|
+
disable_open_telemetry = config.loggable.disable_open_telemetry
|
22
|
+
|
21
23
|
if production_like
|
22
24
|
if Rails.application.config.respond_to?(:assets) && Rails.application.config.assets.quiet
|
23
25
|
Loggable::Logfmt::Logger.include_logger_silence
|
@@ -25,7 +27,9 @@ module Loggable
|
|
25
27
|
Rails.logger = Loggable::Logfmt::Logger.new($stdout)
|
26
28
|
Rails.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase || 'INFO')
|
27
29
|
|
28
|
-
|
30
|
+
unless disable_open_telemetry
|
31
|
+
Loggable::OpenTelemetryConfig.configure(Rails.application.class.module_parent_name.underscore.dasherize)
|
32
|
+
end
|
29
33
|
end
|
30
34
|
|
31
35
|
# lograge configuration
|
@@ -42,14 +46,17 @@ module Loggable
|
|
42
46
|
controller.request.headers['traceparent'] || # Check for the W3C Trace Context header
|
43
47
|
controller.request.env['HTTP_X_REQUEST_ID'] # Fallback to Rack's normalized header
|
44
48
|
|
45
|
-
{
|
49
|
+
payload = {
|
46
50
|
'source.ip': controller.request.ip,
|
47
51
|
'user.id': user_id,
|
48
52
|
'request.id': request_id,
|
49
|
-
status: response_code
|
50
|
-
span_id: OpenTelemetry::Trace.current_span.context.hex_span_id,
|
51
|
-
trace_id: OpenTelemetry::Trace.current_span.context.hex_trace_id
|
53
|
+
status: response_code
|
52
54
|
}
|
55
|
+
if production_like && !disable_open_telemetry
|
56
|
+
payload[:span_id] = OpenTelemetry::Trace.current_span.context.hex_span_id
|
57
|
+
payload[:trace_id] = OpenTelemetry::Trace.current_span.context.hex_trace_id
|
58
|
+
end
|
59
|
+
payload
|
53
60
|
end
|
54
61
|
config.lograge.custom_options = lambda do |event|
|
55
62
|
return if event.payload[:params].blank?
|
@@ -72,8 +79,10 @@ module Loggable
|
|
72
79
|
if Rails.env.production? || config.loggable.production_like
|
73
80
|
Delayed::Worker.logger = Loggable::Logfmt::Logger.new($stdout)
|
74
81
|
Delayed::Worker.logger.level = ActiveSupport::Logger.const_get(config.log_level.to_s.upcase || 'INFO')
|
75
|
-
|
76
|
-
|
82
|
+
unless config.loggable.disable_open_telemetry
|
83
|
+
worker_name = "#{Rails.application.class.module_parent_name.underscore.dasherize}-worker"
|
84
|
+
Loggable::OpenTelemetryConfig.configure(worker_name)
|
85
|
+
end
|
77
86
|
else
|
78
87
|
Delayed::Worker.logger = Logger.new($stdout)
|
79
88
|
Delayed::Worker.logger.level = Logger::DEBUG
|
data/lib/loggable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: researchable_loggable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Researchable
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lograge
|
@@ -109,13 +109,13 @@ files:
|
|
109
109
|
- node_modules/semantic-release-rubygem/src/__tests__/fixtures/prerelease/lib/test-gem/version.rb
|
110
110
|
- node_modules/semantic-release-rubygem/src/__tests__/fixtures/valid/lib/test-gem/version.rb
|
111
111
|
- sig/loggable.rbs
|
112
|
-
homepage: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.
|
112
|
+
homepage: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.7.0/README.md
|
113
113
|
licenses:
|
114
114
|
- MIT
|
115
115
|
metadata:
|
116
|
-
homepage_uri: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.
|
116
|
+
homepage_uri: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.7.0/README.md
|
117
117
|
source_code_uri: https://gitlab.com/researchable/general/gems/loggable
|
118
|
-
changelog_uri: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.
|
118
|
+
changelog_uri: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.7.0/CHANGELOG.md
|
119
119
|
post_install_message:
|
120
120
|
rdoc_options: []
|
121
121
|
require_paths:
|