minimal_logging 0.0.2
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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +2 -0
- data/lib/minimal_logging.rb +8 -0
- data/lib/minimal_logging/rails_extensions/action_view_log_subscriber_extension.rb +9 -0
- data/lib/minimal_logging/rails_extensions/filter_parameters_extension.rb +11 -0
- data/lib/minimal_logging/rails_extensions/log_subscriber_extension.rb +51 -0
- data/lib/minimal_logging/rails_extensions/logger_extension.rb +28 -0
- data/lib/minimal_logging/version.rb +3 -0
- data/minimal_logging.gemspec +25 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 55431b1bb65d9a99f021344c52de7cbbaf6175b1
|
4
|
+
data.tar.gz: 13bcf815affa8c4dad249b23cc99d6a170ade478
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 89ab232def3bff9bffc36eb8ba4550a8b5fdbbe6c3236ea4e948eaaf1463b093f5054d55744f39aa4c948d3f889e397b50c7079efeae88f6afad80a89f7cf1be
|
7
|
+
data.tar.gz: fddf7aff04f38861e3cbb7231c168573148c1a49f9b55619bd44360813a9424d4d2978a956dfe225eb35030bc38c8ab23cce80a24f9e13ca51fa9e20f620fcc3
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Scott Nelson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# MinimalLogging
|
2
|
+
|
3
|
+
Minimal Logging removes some of the noise from the Rails Server log so you can focus on the most important events. It also formats parameters and actions in a more readable way to quickly see what's going on.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'minimal_logging'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install minimal_logging
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
For best results I also recommend:
|
24
|
+
1. Installing the [quiet assets gem](https://github.com/evrone/quiet_assets) to remove noisy logging from your assets.
|
25
|
+
2. Setting your log_level to `:info`
|
26
|
+
In config/environments/development.rb
|
27
|
+
```ruby
|
28
|
+
config.log_level = :info
|
29
|
+
```
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it ( https://github.com/[my-github-username]/minimal_logging/fork )
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require "minimal_logging/version"
|
2
|
+
require "minimal_logging/rails_extensions/action_view_log_subscriber_extension.rb"
|
3
|
+
require "minimal_logging/rails_extensions/filter_parameters_extension.rb"
|
4
|
+
require "minimal_logging/rails_extensions/log_subscriber_extension.rb"
|
5
|
+
require "minimal_logging/rails_extensions/logger_extension.rb"
|
6
|
+
|
7
|
+
module MinimalLogging
|
8
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'action_controller/log_subscriber'
|
2
|
+
require 'colorize'
|
3
|
+
require 'awesome_print'
|
4
|
+
|
5
|
+
class ActionController::LogSubscriber
|
6
|
+
def start_processing(event)
|
7
|
+
return unless logger.info?
|
8
|
+
|
9
|
+
payload = event.payload
|
10
|
+
params = payload[:params].except(*INTERNAL_PARAMS)
|
11
|
+
format = payload[:format]
|
12
|
+
format = format.to_s.upcase if format.is_a?(Symbol)
|
13
|
+
|
14
|
+
info "#{payload[:action]}".upcase.colorize(:red) + " #{payload[:controller]}".colorize(:red)
|
15
|
+
|
16
|
+
unless params.empty?
|
17
|
+
info " Params: ".colorize(:blue)
|
18
|
+
ap params
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def process_action(event)
|
23
|
+
return unless logger.info?
|
24
|
+
|
25
|
+
payload = event.payload
|
26
|
+
additions = ActionController::Base.log_process_action(payload)
|
27
|
+
|
28
|
+
status = payload[:status]
|
29
|
+
if status.nil? && payload[:exception].present?
|
30
|
+
exception_class_name = payload[:exception].first
|
31
|
+
status = ActionDispatch::ExceptionWrapper.status_code_for_exception(exception_class_name)
|
32
|
+
end
|
33
|
+
message = format_message(status)
|
34
|
+
|
35
|
+
info(message)
|
36
|
+
end
|
37
|
+
|
38
|
+
def format_message(status)
|
39
|
+
if status < 300
|
40
|
+
status.to_s.colorize(:green)
|
41
|
+
elsif status < 400
|
42
|
+
status.to_s.colorize(:yellow)
|
43
|
+
elsif status < 500
|
44
|
+
status.to_s.colorize(:red)
|
45
|
+
elsif status < 600
|
46
|
+
status.to_s.colorize(:light_red)
|
47
|
+
else
|
48
|
+
status
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
Rails::Rack::Logger.class_eval do
|
4
|
+
|
5
|
+
protected
|
6
|
+
|
7
|
+
def call_app(request, env)
|
8
|
+
instrumenter = ActiveSupport::Notifications.instrumenter
|
9
|
+
instrumenter.start 'request.action_dispatch', request: request
|
10
|
+
logger.info ''
|
11
|
+
logger.info started_request_message(request)
|
12
|
+
resp = @app.call(env)
|
13
|
+
resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }
|
14
|
+
resp
|
15
|
+
rescue
|
16
|
+
finish(request)
|
17
|
+
raise
|
18
|
+
ensure
|
19
|
+
ActiveSupport::LogSubscriber.flush_all!
|
20
|
+
end
|
21
|
+
|
22
|
+
# GET "/session/new"
|
23
|
+
def started_request_message(request)
|
24
|
+
method = request.request_method.colorize(:blue)
|
25
|
+
path = request.filtered_path.colorize(:magenta)
|
26
|
+
output = method + " " + path
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'minimal_logging/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "minimal_logging"
|
8
|
+
spec.version = MinimalLogging::VERSION
|
9
|
+
spec.authors = ["Scott Nelson"]
|
10
|
+
spec.email = ["Scott.D.Nelson@dartmouth.edu"]
|
11
|
+
spec.summary = %q{Replace the default Rails Server log with shorter and more readable output.}
|
12
|
+
spec.description = %q{Replace the default Rails Server log with shorter and more readable output.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_dependency "awesome_print", "~> 1.6"
|
24
|
+
spec.add_dependency "colorize", "~> 0.7"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minimal_logging
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Nelson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: awesome_print
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: colorize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.7'
|
69
|
+
description: Replace the default Rails Server log with shorter and more readable output.
|
70
|
+
email:
|
71
|
+
- Scott.D.Nelson@dartmouth.edu
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/minimal_logging.rb
|
82
|
+
- lib/minimal_logging/rails_extensions/action_view_log_subscriber_extension.rb
|
83
|
+
- lib/minimal_logging/rails_extensions/filter_parameters_extension.rb
|
84
|
+
- lib/minimal_logging/rails_extensions/log_subscriber_extension.rb
|
85
|
+
- lib/minimal_logging/rails_extensions/logger_extension.rb
|
86
|
+
- lib/minimal_logging/version.rb
|
87
|
+
- minimal_logging.gemspec
|
88
|
+
homepage: ''
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.4.5
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Replace the default Rails Server log with shorter and more readable output.
|
112
|
+
test_files: []
|