logjoy 0.3.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -2
- data/README.md +71 -30
- data/lib/logjoy/version.rb +1 -1
- data/lib/logjoy.rb +1 -1
- data/logjoy.gemspec +8 -8
- metadata +20 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8465ed2ff48074e8353f4502bc13b563bdd63ce1c35e1651536b12b51ce1b2e4
|
4
|
+
data.tar.gz: 80644fc030801240e16486e66ff163ab079b0670ac6b1098fdf8546e7dba4cf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c14f59ce816476068423c31b321974909adb9c3efd7e89b6ba1e34edda462d6b0984cad287a849ed2f6a34e2c41877f37fd0a8da14f752220970fd38bd2ab71
|
7
|
+
data.tar.gz: 2cacd55977b12fda7e4edccd14efe7be349b6faf55460b55e15128f32647c9167311a0069b7c489a33bb72f7109468e8cb27ca74d9cc314e1705647eb313e9ec
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Logjoy
|
2
2
|
|
3
|
+
## Overview
|
4
|
+
|
3
5
|
Logjoy makes some changes to Rails default `ActiveSupport::LogSubscriber`s in order
|
4
6
|
to provide streamlined request logs for use in production.
|
5
7
|
|
@@ -7,27 +9,9 @@ The name is an homage to the [lograge gem](https://github.com/roidrage/lograge)
|
|
7
9
|
which is no longer maintained and which this gem is intended to replace.
|
8
10
|
|
9
11
|
See
|
10
|
-
[LOGRAGE_README](https://github.com/
|
12
|
+
[LOGRAGE_README](https://github.com/DogParkLabs/logjoy/blob/main/LOGRAGE_README.md)
|
11
13
|
for more information about the differences between this gem and lograge.
|
12
14
|
|
13
|
-
```json
|
14
|
-
{
|
15
|
-
"controller": "PagesController",
|
16
|
-
"action": "index",
|
17
|
-
"format": "html",
|
18
|
-
"method": "GET",
|
19
|
-
"path": "/",
|
20
|
-
"status": 200,
|
21
|
-
"view_runtime": 123.456,
|
22
|
-
"db_runtime": 123.456,
|
23
|
-
"duration": 1234.567,
|
24
|
-
"params": {},
|
25
|
-
"request_id": "95cb397a-df23-4548-b641-ae8eef9d3a4e",
|
26
|
-
"event": "process_action.action_controller",
|
27
|
-
"allocations": 123456
|
28
|
-
}
|
29
|
-
```
|
30
|
-
|
31
15
|
## Installation
|
32
16
|
|
33
17
|
Add this line to your application's Gemfile:
|
@@ -40,10 +24,42 @@ And then execute:
|
|
40
24
|
|
41
25
|
$ bundle install
|
42
26
|
|
43
|
-
##
|
27
|
+
## Configuration
|
44
28
|
|
45
29
|
Logjoy can be configured with the following options:
|
46
30
|
|
31
|
+
### enabled
|
32
|
+
|
33
|
+
`config.logjoy.enabled = true`
|
34
|
+
|
35
|
+
You will likely only want to enable Logjoy in production, e.g. `config.logjoy.enabled = Rails.env.production?`
|
36
|
+
|
37
|
+
### customizer
|
38
|
+
|
39
|
+
You can provide a lambda:
|
40
|
+
|
41
|
+
`config.logjoy.customizer = ->(event) { ... }`
|
42
|
+
|
43
|
+
or a class that implements a `.call` method:
|
44
|
+
|
45
|
+
`config.logjoy.customizer = CustomizerClass`
|
46
|
+
|
47
|
+
The customizer will receive an `ActiveSupport::Notification` event for the
|
48
|
+
`process_action.action_controller` event.
|
49
|
+
It should return a hash that will be added to the log message.
|
50
|
+
|
51
|
+
More documentation about this event can be found here:
|
52
|
+
https://guides.rubyonrails.org/active_support_instrumentation.html#process-action-action-controller
|
53
|
+
|
54
|
+
### filters
|
55
|
+
|
56
|
+
`config.logjoy.filters = ['/paths', '/to', '/ignore']`
|
57
|
+
|
58
|
+
The filters configuration can be used to ignore requests with the given path to
|
59
|
+
reduce log noise from things like health checks.
|
60
|
+
|
61
|
+
### Example of full configuration
|
62
|
+
|
47
63
|
`config/initializers/logjoy.rb`
|
48
64
|
|
49
65
|
```ruby
|
@@ -58,16 +74,41 @@ Rails.application.configure do |config|
|
|
58
74
|
end
|
59
75
|
```
|
60
76
|
|
61
|
-
|
62
|
-
The customizer will receive an `ActiveSupport::Notification` event for the
|
63
|
-
`process_action.action_controller` event.
|
64
|
-
It should return a hash that will be added to the log in a `:custom` field.
|
77
|
+
## Log Format
|
65
78
|
|
66
|
-
|
67
|
-
https://guides.rubyonrails.org/active_support_instrumentation.html#process-action-action-controller
|
79
|
+
Log messages are JSON formatted.
|
68
80
|
|
69
|
-
|
70
|
-
|
81
|
+
```json
|
82
|
+
{
|
83
|
+
"controller": "PagesController",
|
84
|
+
"action": "index",
|
85
|
+
"format": "html",
|
86
|
+
"method": "GET",
|
87
|
+
"path": "/",
|
88
|
+
"status": 200,
|
89
|
+
"view_runtime": 123.456,
|
90
|
+
"db_runtime": 123.456,
|
91
|
+
"duration": 1234.567,
|
92
|
+
"params": {},
|
93
|
+
"request_id": "95cb397a-df23-4548-b641-ae8eef9d3a4e",
|
94
|
+
"event": "process_action.action_controller",
|
95
|
+
"allocations": 123456
|
96
|
+
}
|
97
|
+
```
|
98
|
+
|
99
|
+
If you are using `Logger::Formatter` to format your logs the output should look something like:
|
100
|
+
|
101
|
+
`I, [timestamp] INFO -- : [request_id] {"controller":"PagesController", ...}`
|
102
|
+
|
103
|
+
If you define your own formatter keep in mind that `msg` is already JSON formatted in the `#call` method that you will define:
|
104
|
+
|
105
|
+
```
|
106
|
+
class MyFormatter < Logger::Formatter
|
107
|
+
def call(severity, time, progname, msg)
|
108
|
+
# msg is a JSON string
|
109
|
+
end
|
110
|
+
end
|
111
|
+
```
|
71
112
|
|
72
113
|
## Development
|
73
114
|
|
@@ -84,10 +125,10 @@ git commits and the created tag, and push the `.gem` file to
|
|
84
125
|
## Contributing
|
85
126
|
|
86
127
|
Bug reports and pull requests are welcome on GitHub at
|
87
|
-
https://github.com/
|
128
|
+
https://github.com/DogParkLabs/logjoy. This project is intended to be a safe,
|
88
129
|
welcoming space for collaboration, and contributors are expected to adhere to
|
89
130
|
the [code of
|
90
|
-
conduct](https://github.com/
|
131
|
+
conduct](https://github.com/DogParkLabs/logjoy/blob/master/CODE_OF_CONDUCT.md).
|
91
132
|
|
92
133
|
## License
|
93
134
|
|
data/lib/logjoy/version.rb
CHANGED
data/lib/logjoy.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'active_support/core_ext/string/inflections'
|
3
4
|
require 'action_view/log_subscriber'
|
4
5
|
require 'action_controller/log_subscriber'
|
5
6
|
require 'action_mailer/log_subscriber'
|
6
7
|
require 'active_storage/log_subscriber'
|
7
|
-
require 'active_support/core_ext/string/inflections'
|
8
8
|
|
9
9
|
require_relative 'logjoy/version'
|
10
10
|
require_relative 'logjoy/log_subscribers/action_controller'
|
data/logjoy.gemspec
CHANGED
@@ -6,10 +6,10 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'logjoy'
|
7
7
|
spec.version = Logjoy::VERSION
|
8
8
|
spec.authors = ['Pat McGee']
|
9
|
-
spec.email = ['
|
9
|
+
spec.email = ['pat@gooddog.com']
|
10
10
|
|
11
11
|
spec.summary = 'Alternative set of LogSubscriber classes for Rails for more structured JSON logs'
|
12
|
-
spec.homepage = 'https://github.com/
|
12
|
+
spec.homepage = 'https://github.com/DogParkLabs/logjoy'
|
13
13
|
spec.license = 'MIT'
|
14
14
|
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
15
15
|
|
@@ -24,10 +24,10 @@ Gem::Specification.new do |spec|
|
|
24
24
|
end
|
25
25
|
spec.require_paths = ['lib']
|
26
26
|
|
27
|
-
spec.add_runtime_dependency 'actionmailer', '
|
28
|
-
spec.add_runtime_dependency 'actionpack', '
|
29
|
-
spec.add_runtime_dependency 'actionview', '
|
30
|
-
spec.add_runtime_dependency 'activestorage', '
|
31
|
-
spec.add_runtime_dependency 'activesupport', '
|
32
|
-
spec.add_runtime_dependency 'railties', '
|
27
|
+
spec.add_runtime_dependency 'actionmailer', '>= 6'
|
28
|
+
spec.add_runtime_dependency 'actionpack', '>= 6'
|
29
|
+
spec.add_runtime_dependency 'actionview', '>= 6'
|
30
|
+
spec.add_runtime_dependency 'activestorage', '>= 6'
|
31
|
+
spec.add_runtime_dependency 'activesupport', '>= 6'
|
32
|
+
spec.add_runtime_dependency 'railties', '>= 6'
|
33
33
|
end
|
metadata
CHANGED
@@ -1,102 +1,102 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logjoy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat McGee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionmailer
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: actionview
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '6'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '6'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activestorage
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '6'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '6'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: activesupport
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '6'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '6'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: railties
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '6'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '6'
|
97
97
|
description:
|
98
98
|
email:
|
99
|
-
-
|
99
|
+
- pat@gooddog.com
|
100
100
|
executables: []
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
@@ -118,13 +118,13 @@ files:
|
|
118
118
|
- lib/logjoy/railtie.rb
|
119
119
|
- lib/logjoy/version.rb
|
120
120
|
- logjoy.gemspec
|
121
|
-
homepage: https://github.com/
|
121
|
+
homepage: https://github.com/DogParkLabs/logjoy
|
122
122
|
licenses:
|
123
123
|
- MIT
|
124
124
|
metadata:
|
125
|
-
homepage_uri: https://github.com/
|
126
|
-
source_code_uri: https://github.com/
|
127
|
-
changelog_uri: https://github.com/
|
125
|
+
homepage_uri: https://github.com/DogParkLabs/logjoy
|
126
|
+
source_code_uri: https://github.com/DogParkLabs/logjoy
|
127
|
+
changelog_uri: https://github.com/DogParkLabs/logjoy/blob/main/CHANGELOG.md
|
128
128
|
post_install_message:
|
129
129
|
rdoc_options: []
|
130
130
|
require_paths:
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.2.32
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Alternative set of LogSubscriber classes for Rails for more structured JSON
|