researchable_loggable 1.0.1 → 1.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/CHANGELOG.md +14 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +11 -16
- data/README.md +13 -3
- data/lib/loggable/railtie.rb +7 -1
- data/lib/loggable/version.rb +1 -1
- data/lib/{loggable.rb → researchable_loggable.rb} +1 -1
- data/node_modules/semantic-release-rubygem/src/__tests__/fixtures/valid/lib/test-gem/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a23495beab24247d68a2d16b22b47c63dc62907f5a0cd97a2bf239a697d7bae
|
4
|
+
data.tar.gz: 6da7d0c63b104be64d7ba13006db69cc2ff24610ea6494db4460db4db328620b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d169fe09836a0aaa5d9a8537590e77ccbfb2a8b8fd5998a71bd9eb1ec3913d20f84deec030274c361e20f18284ec10df825eb8d1635d17f561beb4678471eaa
|
7
|
+
data.tar.gz: 7675af41ca588f916a67dc4ac782bdd21480d0b043ef22f4412cc7dbae063d4be23eaad9bb95bf9d7d7e33abc2c265900e289c987c23787b920c7fd9238e5156
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# [1.1.0](https://gitlab.com/researchable/general/gems/loggable/compare/v1.0.2...v1.1.0) (2023-07-06)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* **config:** Support other current_user_method ([e5797ba](https://gitlab.com/researchable/general/gems/loggable/commit/e5797ba6cc7f2a3e589895cf05ba2f4a109b10e1))
|
7
|
+
|
8
|
+
## [1.0.2](https://gitlab.com/researchable/general/gems/loggable/compare/v1.0.1...v1.0.2) (2023-06-27)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* gem not being properly loaded ([7e19afd](https://gitlab.com/researchable/general/gems/loggable/commit/7e19afdfc3252303bfb363061c88f7a168ca0779))
|
14
|
+
|
1
15
|
## [1.0.1](https://gitlab.com/researchable/general/gems/loggable/compare/v1.0.0...v1.0.1) (2023-03-08)
|
2
16
|
|
3
17
|
|
data/Gemfile
CHANGED
@@ -9,8 +9,7 @@ gem 'rake', '~> 13.0'
|
|
9
9
|
|
10
10
|
gem 'rspec', '~> 3.0'
|
11
11
|
|
12
|
-
|
13
|
-
gem 'ruboguide', git: 'https://gitlab.com/researchable/general/gems/ruboguide'
|
12
|
+
gem 'ruboguide', '~> 1.0'
|
14
13
|
|
15
14
|
gem 'ecs-logging', '~> 1.0'
|
16
15
|
gem 'lograge'
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,7 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://gitlab.com/researchable/general/gems/ruboguide
|
3
|
-
revision: fd7b55c93c3ebfe63aed5cb7e5c9c38bd4a45020
|
4
|
-
specs:
|
5
|
-
ruboguide (0.1.0)
|
6
|
-
rubocop (= 1.23.0)
|
7
|
-
rubocop-performance (= 1.12.0)
|
8
|
-
rubocop-rails (= 2.12.4)
|
9
|
-
rubocop-rake (= 0.6.0)
|
10
|
-
rubocop-rspec (= 2.6.0)
|
11
|
-
|
12
1
|
PATH
|
13
2
|
remote: .
|
14
3
|
specs:
|
15
|
-
researchable_loggable (1.0.
|
4
|
+
researchable_loggable (1.0.2)
|
16
5
|
ecs-logging (~> 1.0)
|
17
6
|
lograge
|
18
7
|
logstash-event
|
@@ -61,7 +50,7 @@ GEM
|
|
61
50
|
nokogiri (1.14.1-x86_64-linux)
|
62
51
|
racc (~> 1.4)
|
63
52
|
parallel (1.22.1)
|
64
|
-
parser (3.2.1.
|
53
|
+
parser (3.2.1.1)
|
65
54
|
ast (~> 2.4.1)
|
66
55
|
racc (1.6.2)
|
67
56
|
rack (2.2.6.2)
|
@@ -107,7 +96,7 @@ GEM
|
|
107
96
|
rubocop-ast (>= 1.12.0, < 2.0)
|
108
97
|
ruby-progressbar (~> 1.7)
|
109
98
|
unicode-display_width (>= 1.4.0, < 3.0)
|
110
|
-
rubocop-ast (1.
|
99
|
+
rubocop-ast (1.27.0)
|
111
100
|
parser (>= 3.2.1.0)
|
112
101
|
rubocop-performance (1.12.0)
|
113
102
|
rubocop (>= 1.7.0, < 2.0)
|
@@ -120,7 +109,13 @@ GEM
|
|
120
109
|
rubocop (~> 1.0)
|
121
110
|
rubocop-rspec (2.6.0)
|
122
111
|
rubocop (~> 1.19)
|
123
|
-
|
112
|
+
ruboguide (1.0.0)
|
113
|
+
rubocop (= 1.23.0)
|
114
|
+
rubocop-performance (= 1.12.0)
|
115
|
+
rubocop-rails (= 2.12.4)
|
116
|
+
rubocop-rake (= 0.6.0)
|
117
|
+
rubocop-rspec (= 2.6.0)
|
118
|
+
ruby-progressbar (1.13.0)
|
124
119
|
thor (1.2.1)
|
125
120
|
tzinfo (2.0.6)
|
126
121
|
concurrent-ruby (~> 1.0)
|
@@ -137,7 +132,7 @@ DEPENDENCIES
|
|
137
132
|
rake (~> 13.0)
|
138
133
|
researchable_loggable!
|
139
134
|
rspec (~> 3.0)
|
140
|
-
ruboguide
|
135
|
+
ruboguide (~> 1.0)
|
141
136
|
|
142
137
|
BUNDLED WITH
|
143
138
|
2.4.6
|
data/README.md
CHANGED
@@ -39,9 +39,9 @@ of lograge as the message, however some of the fields in the lograge output are
|
|
39
39
|
monkey patch on the ECS gem that flattens the lograge output onto the Ecs object.
|
40
40
|
|
41
41
|
## Installation
|
42
|
-
Add this to your Gemfile
|
42
|
+
Add this to your Gemfile:
|
43
43
|
```ruby
|
44
|
-
gem '
|
44
|
+
gem 'researchable_loggable', '~> 1.0'
|
45
45
|
```
|
46
46
|
|
47
47
|
Additionally, if you want to be able to correlate logs with Elastic's APM traces, you may also add the elastic apm gem:
|
@@ -61,7 +61,11 @@ If loggable detects the presence of this gem, it will inject `transaction.id`, `
|
|
61
61
|
For a brand new Rails application, adding this gem to the Gemfile should be all the configuration that is needed. This
|
62
62
|
gem will automatically configure the Rails logger and lograge to follow the Researchable standard.
|
63
63
|
|
64
|
-
|
64
|
+
|
65
|
+
### Parameters
|
66
|
+
This are the parameters that can be configured in the `config.loggable` namespace:
|
67
|
+
|
68
|
+
`production_like`. By default loggable will only
|
65
69
|
modify how the logs look on production. This is because the format that this gem enforces is slightly less
|
66
70
|
human readable (in favour of machine readability and compatibility with the Elastic Common Schema) than the default
|
67
71
|
Rails one. For development, the more human readable format is preferred. However, if you want to override this and
|
@@ -71,6 +75,12 @@ are developing against this gem) then you may add the following to your `config/
|
|
71
75
|
config.loggable.production_like = true
|
72
76
|
```
|
73
77
|
|
78
|
+
`current_user_method`. This is the name of the method that will be called on the controller to get the current user. By default this is set to `current_user`. If you want to override this, you may add the following to your `config/application.rb` file:
|
79
|
+
```ruby
|
80
|
+
config.loggable.current_user_method = :my_current_user_method
|
81
|
+
```
|
82
|
+
This method is used for ECS logging, if the method is not found, the user.id field will be set to nil.
|
83
|
+
|
74
84
|
No other configuration options are provided because this gem seeks to enforce consistency across all applications.
|
75
85
|
|
76
86
|
For applications that already had some level of log customization, some cleanup might be needed:
|
data/lib/loggable/railtie.rb
CHANGED
@@ -9,9 +9,11 @@ module Loggable
|
|
9
9
|
# We add a new loggable namespace to the config object, to keep all the configuration related to this gem organized
|
10
10
|
config.loggable = ActiveSupport::OrderedOptions.new
|
11
11
|
config.loggable.production_like = false
|
12
|
+
config.loggable.current_user_method = :current_user
|
12
13
|
|
13
14
|
# Initializer runs before initialize_logger (found in Bootstrap) so from the very beginning we are logging using
|
14
15
|
# the ecs format, even during the initialization process
|
16
|
+
# rubocop:disable Metrics/BlockLength
|
15
17
|
initializer :loggable_web, before: :initialize_logger do
|
16
18
|
Rails.application.configure do
|
17
19
|
production_like = Rails.env.production? || config.loggable.production_like
|
@@ -25,10 +27,13 @@ module Loggable
|
|
25
27
|
config.lograge.base_controller_class = 'ApplicationController'
|
26
28
|
config.lograge.custom_payload do |controller|
|
27
29
|
response_code = controller.response.code
|
30
|
+
if controller.respond_to?(config.loggable.current_user_method)
|
31
|
+
user_id = controller.send(config.loggable.current_user_method).try(:id)
|
32
|
+
end
|
28
33
|
{
|
29
34
|
ecs: {
|
30
35
|
'source.ip': controller.request.ip,
|
31
|
-
'user.id':
|
36
|
+
'user.id': user_id,
|
32
37
|
'http.code': response_code
|
33
38
|
},
|
34
39
|
status: response_code
|
@@ -41,6 +46,7 @@ module Loggable
|
|
41
46
|
config.lograge.formatter = Loggable::Lograge::Formatter.new if production_like
|
42
47
|
end
|
43
48
|
end
|
49
|
+
# rubocop:enable Metrics/BlockLength
|
44
50
|
|
45
51
|
initializer :loggable_worker, before: :initializer_logger do
|
46
52
|
Rails.application.configure do
|
data/lib/loggable/version.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative 'loggable/railtie' if defined?(Rails::Railtie)
|
|
5
5
|
require_relative 'loggable/ecs_logging/formatter_monkey_patch'
|
6
6
|
require_relative 'loggable/lograge/formatter'
|
7
7
|
|
8
|
-
module
|
8
|
+
module ResearchableLoggable
|
9
9
|
class Error < StandardError
|
10
10
|
end
|
11
11
|
end
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Researchable
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ecs-logging
|
@@ -72,22 +72,22 @@ files:
|
|
72
72
|
- LICENSE.txt
|
73
73
|
- README.md
|
74
74
|
- Rakefile
|
75
|
-
- lib/loggable.rb
|
76
75
|
- lib/loggable/ecs_logging/formatter_monkey_patch.rb
|
77
76
|
- lib/loggable/lograge/formatter.rb
|
78
77
|
- lib/loggable/railtie.rb
|
79
78
|
- lib/loggable/version.rb
|
79
|
+
- lib/researchable_loggable.rb
|
80
80
|
- node_modules/semantic-release-rubygem/src/__tests__/fixtures/invalid-version-file/lib/test-gem/version.rb
|
81
81
|
- node_modules/semantic-release-rubygem/src/__tests__/fixtures/prerelease/lib/test-gem/version.rb
|
82
82
|
- node_modules/semantic-release-rubygem/src/__tests__/fixtures/valid/lib/test-gem/version.rb
|
83
83
|
- sig/loggable.rbs
|
84
|
-
homepage: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.0
|
84
|
+
homepage: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.1.0/README.md
|
85
85
|
licenses:
|
86
86
|
- MIT
|
87
87
|
metadata:
|
88
|
-
homepage_uri: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.0
|
88
|
+
homepage_uri: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.1.0/README.md
|
89
89
|
source_code_uri: https://gitlab.com/researchable/general/gems/loggable
|
90
|
-
changelog_uri: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.0
|
90
|
+
changelog_uri: https://gitlab.com/researchable/general/gems/loggable/-/blob/v1.1.0/CHANGELOG.md
|
91
91
|
post_install_message:
|
92
92
|
rdoc_options: []
|
93
93
|
require_paths:
|
@@ -103,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
rubygems_version: 3.
|
106
|
+
rubygems_version: 3.4.10
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Researchable's gem to standardize logging on all Rails applications.
|