rest-client-logger 0.0.1
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.
- data/MIT-LICENSE +20 -0
- data/README.md +31 -0
- data/lib/rest-client-logger.rb +8 -0
- data/lib/rest_client/request.rb +12 -0
- data/lib/rest_client_logger/rest_client_log_subscriber.rb +11 -0
- data/lib/rest_client_logger/version.rb +3 -0
- metadata +83 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# RestClientLogger
|
2
|
+
|
3
|
+
Instruments the [RestClient](https://github.com/rest-client/rest-client) gem and logs requests made with RestClient to the Rails development log.
|
4
|
+
|
5
|
+
Started GET "/" for 127.0.0.1 at 2014-05-02 17:09:49 +0100
|
6
|
+
Processing by WelcomeController#index as HTML
|
7
|
+
RestClient GET (45.7ms) http://www.google.com?q=vikings {"User-Agent"=>"A browser"}
|
8
|
+
Rendered text template (0.0ms)
|
9
|
+
Completed 200 OK in 47ms (Views: 0.6ms | ActiveRecord: 0.0ms)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your Rails application's Gemfile:
|
14
|
+
|
15
|
+
gem 'rest-client-logger'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install rest-client-logger
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module RestClient
|
2
|
+
class Request
|
3
|
+
|
4
|
+
def execute_with_instrumentation(& block)
|
5
|
+
ActiveSupport::Notifications.instrument('log.restclient', url: url, method: method, headers: headers) do
|
6
|
+
execute_without_instrumentation &block
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
alias_method_chain :execute, :instrumentation
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class RestClientLogSubscriber < ActiveSupport::LogSubscriber
|
2
|
+
def log(event)
|
3
|
+
return unless logger.debug?
|
4
|
+
method = (event.payload[:method] || "").upcase
|
5
|
+
headers = event.payload[:headers]
|
6
|
+
name = 'RestClient %s (%.1fms)' % [method, event.duration]
|
7
|
+
debug " #{color(name, GREEN, true)} #{color(event.payload[:url], BOLD, true)} #{headers.inspect if headers.present?}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
RestClientLogSubscriber.attach_to :restclient
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rest-client-logger
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jason Neylon
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-01-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.1'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rest-client
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.6'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.6'
|
46
|
+
description: Adds logging of the RestClient requests to the Rails debug log
|
47
|
+
email:
|
48
|
+
- jason.neylon@uswitch.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- lib/rest-client-logger.rb
|
54
|
+
- lib/rest_client/request.rb
|
55
|
+
- lib/rest_client_logger/rest_client_log_subscriber.rb
|
56
|
+
- lib/rest_client_logger/version.rb
|
57
|
+
- MIT-LICENSE
|
58
|
+
- README.md
|
59
|
+
homepage: http://github.com/uswitch/rest-client-logger
|
60
|
+
licenses: []
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.8.23
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Adds logging of the RestClient requests to the Rails debug log
|
83
|
+
test_files: []
|