logjoy 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56329a258274b0bd9cfb93908a2c0eabd282d997199df65338754f2bf21553bc
4
- data.tar.gz: c9f0fe2944b7fd218492a8e71e6381bed4815afef1fd54606b29091a074d095a
3
+ metadata.gz: 4da07c8943cc57684a2c27c541726b4f6545e82ec3581e50193ca4f9334dfce9
4
+ data.tar.gz: 856d0f47719d071519550dadaec792ab10e117046b13770d4d7dc198ab2fbc65
5
5
  SHA512:
6
- metadata.gz: 692adfc536f2bd584fe5cbf0c2037f3489d3b874e83d0e8d4dc286c61a4f96a6284beb770d03653f92464b2d881243f3b475ce9e576cd59a2a984fc1ec834034
7
- data.tar.gz: '09bd6e67e9ce7f7bcf8a026ce93a748a50e96d3cc135b7fffb2493fd970ae37a5ad38a052f240a6b20763bad3f8175e845ab1cf750e9edb0aa9770e027cc68f7'
6
+ metadata.gz: 91bcc54414715010cf08c114c6fdf27ff4999bf3de2ed6b78e538f1a67adbf45b5ae858d707a8daf8a720ca31aa0ce880db60eff66b7e76931c427e42b42b538
7
+ data.tar.gz: 4fd305c8b89ae177cb7884eab52a24904430ff3ffb5c8912a04f33ed2f1c3f9b2afcf6178f3281ee4eae2bbfac3a6054623a6ef04be7e66786e5b41f4e336313
data/Gemfile CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- # Specify your gem's dependencies in logjoy.gemspec
6
5
  gemspec
7
6
 
8
7
  gem 'minitest', '5.14.4'
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/pathouse/logjoy/blob/main/LOGRAGE_README.md)
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
- ## Usage
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
- The customizer configuration may be a class that implements a `.call` method, or a lambda.
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
- More documentation about this event can be found here:
67
- https://guides.rubyonrails.org/active_support_instrumentation.html#process-action-action-controller
79
+ Log messages are JSON formatted.
68
80
 
69
- The filters configuration can be used to ignore requests with the given path to
70
- reduce log noise from things like health checks.
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/pathouse/logjoy. This project is intended to be a safe,
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/[USERNAME]/logjoy/blob/master/CODE_OF_CONDUCT.md).
131
+ conduct](https://github.com/DogParkLabs/logjoy/blob/master/CODE_OF_CONDUCT.md).
91
132
 
92
133
  ## License
93
134
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Logjoy
4
- VERSION = '0.3.4'
4
+ VERSION = '0.3.5'
5
5
  end
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 = ['patmcgee331@gmail.com']
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/pathouse/logjoy'
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
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logjoy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat McGee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-01 00:00:00.000000000 Z
11
+ date: 2021-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -96,7 +96,7 @@ dependencies:
96
96
  version: '6'
97
97
  description:
98
98
  email:
99
- - patmcgee331@gmail.com
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/pathouse/logjoy
121
+ homepage: https://github.com/DogParkLabs/logjoy
122
122
  licenses:
123
123
  - MIT
124
124
  metadata:
125
- homepage_uri: https://github.com/pathouse/logjoy
126
- source_code_uri: https://github.com/pathouse/logjoy
127
- changelog_uri: https://github.com/pathouse/logjoy/blob/main/CHANGELOG.md
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: