ezlog 0.8.0 → 0.9.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 +9 -0
- data/README.md +7 -1
- data/ezlog.gemspec +1 -1
- data/lib/ezlog/rails/access_log.rb +14 -8
- data/lib/ezlog/railtie.rb +17 -10
- data/lib/ezlog/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1060267c8ecacef2fc5c231f9287f09b4b36e9ad7fc536199e2458eb5f56d275
|
|
4
|
+
data.tar.gz: 4d176d6aeb4192fe42240a2a23e0ac0c1c2f4c15487ac8371a22d8907ea123e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dd779463c0f5a50955f01c7eaf6cf7c90d0668e9c4d9cc49c4b676cff5508f10cfb2e6ed3b28f922f67bd1eab38fc393052ce72ef57a7b69d3daaeb2b62cadac
|
|
7
|
+
data.tar.gz: 29acb94a878f3aaa7f96c1b806aede63473d5b5a288eece64b7b2d7082ef1d56aacfc31c10a70399152d4a4afef1338799a9a24caa5d4b82078fe65726a9548a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
### 0.9.0 (2020-05-10)
|
|
2
|
+
|
|
3
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.8.0...v0.9.0)
|
|
4
|
+
|
|
5
|
+
* Features & enhancements
|
|
6
|
+
* Ezlog now supports [Rails](https://rubyonrails.org/) 6.
|
|
7
|
+
* Added the ability to exclude certain paths from access logging. Use the `exclude_paths` configuration option to
|
|
8
|
+
add paths (strings or regexps) to exclude from your access logs.
|
|
9
|
+
|
|
1
10
|
### 0.8.0 (2020-04-07)
|
|
2
11
|
|
|
3
12
|
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.7.1...v0.8.0)
|
data/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
Ezlog is intended to be a zero-configuration structured logging setup for pure Ruby or [Ruby on Rails](https://rubyonrails.org/)
|
|
7
7
|
projects using any (or all) of the following libraries or frameworks:
|
|
8
8
|
|
|
9
|
-
* [Ruby on Rails](https://rubyonrails.org/)
|
|
9
|
+
* [Ruby on Rails](https://rubyonrails.org/) (5.x and 6.x supported)
|
|
10
10
|
* [Sidekiq](https://github.com/mperham/sidekiq)
|
|
11
11
|
* [Sequel](https://sequel.jeremyevans.net/)
|
|
12
12
|
* [Rack::Timeout](https://github.com/heroku/rack-timeout)
|
|
@@ -134,6 +134,12 @@ Using this configuration, Ezlog will only log the `action` parameter under the `
|
|
|
134
134
|
all parameters serialized into a single string under the key `params_serialized`. You won't lose any information,
|
|
135
135
|
but you can make sure that only the relevant parameters of your requests are searchable (and thus protect your logs).
|
|
136
136
|
|
|
137
|
+
Should you want to exclude certain paths (e.g. a healthcheck URL) from your access logs, you can use the following option:
|
|
138
|
+
|
|
139
|
+
```ruby
|
|
140
|
+
config.ezlog.exclude_paths = ['/healthcheck', %r(/monitoring/.*)] # default is empty so everything gets logged
|
|
141
|
+
```
|
|
142
|
+
|
|
137
143
|
#### The log level
|
|
138
144
|
|
|
139
145
|
The logger's log level is determined as follows (in order of precedence):
|
data/ezlog.gemspec
CHANGED
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
spec.add_dependency "logging", "~> 2.0"
|
|
26
26
|
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 2.0"
|
|
28
|
-
spec.add_development_dependency "rake", "
|
|
28
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
|
29
29
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
30
30
|
spec.add_development_dependency "sidekiq", ">= 5.0"
|
|
31
31
|
spec.add_development_dependency "sequel", "~> 5.0"
|
|
@@ -3,10 +3,10 @@ module Ezlog
|
|
|
3
3
|
class AccessLog
|
|
4
4
|
include LogContextHelper
|
|
5
5
|
|
|
6
|
-
def initialize(app, logger,
|
|
6
|
+
def initialize(app, logger, config)
|
|
7
7
|
@app = app
|
|
8
8
|
@logger = logger
|
|
9
|
-
@
|
|
9
|
+
@config = config
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def call(env)
|
|
@@ -29,23 +29,29 @@ module Ezlog
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def log_request(request, status)
|
|
32
|
+
return if path_ignored?(request)
|
|
33
|
+
|
|
32
34
|
message = {
|
|
33
35
|
message: '%s %s - %i (%s)' % [request.method, request.filtered_path, status, Rack::Utils::HTTP_STATUS_CODES[status]],
|
|
34
36
|
remote_ip: request.remote_ip,
|
|
35
37
|
method: request.method,
|
|
36
38
|
path: request.filtered_path,
|
|
37
|
-
params:
|
|
39
|
+
params: params_to_log(request),
|
|
38
40
|
response_status_code: status
|
|
39
41
|
}
|
|
40
|
-
message.merge! params_serialized: request.filtered_parameters.inspect if @
|
|
42
|
+
message.merge! params_serialized: request.filtered_parameters.inspect if @config.log_only_whitelisted_params
|
|
41
43
|
@logger.info message
|
|
42
44
|
end
|
|
43
45
|
|
|
44
|
-
def
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
def path_ignored?(request)
|
|
47
|
+
@config.exclude_paths.any? { |pattern| pattern.match? request.path }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def params_to_log(request)
|
|
51
|
+
if @config.log_only_whitelisted_params
|
|
52
|
+
request.filtered_parameters.slice *@config.whitelisted_params&.map(&:to_s)
|
|
47
53
|
else
|
|
48
|
-
request.filtered_parameters
|
|
54
|
+
request.filtered_parameters
|
|
49
55
|
end
|
|
50
56
|
end
|
|
51
57
|
end
|
data/lib/ezlog/railtie.rb
CHANGED
|
@@ -4,6 +4,7 @@ module Ezlog
|
|
|
4
4
|
config.ezlog.enable_sequel_logging = false
|
|
5
5
|
config.ezlog.log_only_whitelisted_params = false
|
|
6
6
|
config.ezlog.whitelisted_params = [:controller, :action]
|
|
7
|
+
config.ezlog.exclude_paths = []
|
|
7
8
|
|
|
8
9
|
initializer "ezlog.initialize" do
|
|
9
10
|
require "ezlog/rails/extensions"
|
|
@@ -29,16 +30,26 @@ module Ezlog
|
|
|
29
30
|
initializer 'ezlog.configure_rails_middlewares' do |app|
|
|
30
31
|
app.config.middleware.insert_after ::ActionDispatch::RequestId, Ezlog::Rails::RequestLogContext
|
|
31
32
|
app.config.middleware.delete ::Rails::Rack::Logger
|
|
32
|
-
app.config.middleware.insert_before ::ActionDispatch::DebugExceptions, Ezlog::Rails::AccessLog, Ezlog.logger('AccessLog'),
|
|
33
|
+
app.config.middleware.insert_before ::ActionDispatch::DebugExceptions, Ezlog::Rails::AccessLog, Ezlog.logger('AccessLog'), config.ezlog
|
|
33
34
|
app.config.middleware.insert_after ::ActionDispatch::DebugExceptions, Ezlog::Rails::LogExceptions, Ezlog.logger('Application')
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
config.after_initialize do
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
case ::Rails::VERSION::MAJOR
|
|
39
|
+
when 6
|
|
40
|
+
::ActionController::LogSubscriber.detach_from :action_controller
|
|
41
|
+
::ActionView::LogSubscriber.detach_from :action_view
|
|
42
|
+
if defined? ::ActiveRecord
|
|
43
|
+
::ActiveRecord::LogSubscriber.detach_from :active_record
|
|
44
|
+
Ezlog::Rails::LogSubscriber.attach Ezlog::Rails::ActiveRecord::LogSubscriber, :active_record
|
|
45
|
+
end
|
|
46
|
+
else
|
|
47
|
+
Ezlog::Rails::LogSubscriber.detach ::ActionController::LogSubscriber
|
|
48
|
+
Ezlog::Rails::LogSubscriber.detach ::ActionView::LogSubscriber
|
|
49
|
+
if defined? ::ActiveRecord
|
|
50
|
+
Ezlog::Rails::LogSubscriber.detach ::ActiveRecord::LogSubscriber
|
|
51
|
+
Ezlog::Rails::LogSubscriber.attach Ezlog::Rails::ActiveRecord::LogSubscriber, :active_record
|
|
52
|
+
end
|
|
42
53
|
end
|
|
43
54
|
end
|
|
44
55
|
|
|
@@ -62,9 +73,5 @@ module Ezlog
|
|
|
62
73
|
def disable_rack_timeout_logging
|
|
63
74
|
::Rack::Timeout::Logger.logger = ::Logger.new(nil)
|
|
64
75
|
end
|
|
65
|
-
|
|
66
|
-
def whitelisted_params(app)
|
|
67
|
-
app.config.ezlog.log_only_whitelisted_params ? app.config.ezlog.whitelisted_params : nil
|
|
68
|
-
end
|
|
69
76
|
end
|
|
70
77
|
end
|
data/lib/ezlog/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ezlog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Zoltan Ormandi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-05-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: logging
|
|
@@ -42,16 +42,16 @@ dependencies:
|
|
|
42
42
|
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- - "
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
47
|
+
version: 12.3.3
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- - "
|
|
52
|
+
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
54
|
+
version: 12.3.3
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: rspec
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|