maiha-request_id 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 [name of plugin creator]
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 ADDED
@@ -0,0 +1,23 @@
1
+ RequestId
2
+ =========
3
+
4
+ Rails plugin that adds a new method (Controller#request_id) to distinguish requests
5
+
6
+
7
+ Methods
8
+ =======
9
+
10
+ ActionController::Base#request_id
11
+
12
+
13
+ Log
14
+ ===
15
+
16
+ Processing UserController#index (for 127.0.0.1 at 2008-11-16 21:30:00) [GET]
17
+ Request ID: 1 (port:3000)
18
+ Session ID: 2e324cf7ff9737194a07911cdbf323b0
19
+ Parameters: {"action"=>"index", "controller"=>"user"}
20
+
21
+
22
+
23
+ Copyright (c) 2008 maiha@wota.jp, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the request_id plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Generate documentation for the request_id plugin.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'RequestId'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ ActionController::Base.send :include, RequestId
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
data/lib/request_id.rb ADDED
@@ -0,0 +1,49 @@
1
+ module RequestId
2
+ def self.included(base)
3
+ instance_methods = rails22?(base) ? Rails22 : Rails21
4
+ base.class_eval do
5
+ cattr_accessor :max_request_id
6
+ include instance_methods
7
+ end
8
+ end
9
+
10
+ def self.rails22?(base)
11
+ base.instance_methods.include?("log_processing_for_request_id")
12
+ end
13
+
14
+ module Rails21
15
+ def self.included(base)
16
+ base.class_eval do
17
+ alias_method_chain :log_processing, :request_id
18
+ end
19
+ end
20
+
21
+ private
22
+ def request_id
23
+ @request_id ||= (self.class.max_request_id = self.class.max_request_id.to_i + 1)
24
+ end
25
+
26
+ def log_processing_with_request_id
27
+ if logger
28
+ logger.info "\n\nProcessing #{controller_class_name}\##{action_name} (for #{request_origin}) [#{request.method.to_s.upcase}]"
29
+ logger.info " Request ID: #{request_id} (port:#{request.port})"
30
+ logger.info " Session ID: #{@_session.session_id}" if @_session and @_session.respond_to?(:session_id)
31
+ logger.info " Parameters: #{respond_to?(:filter_parameters) ? filter_parameters(params).inspect : params.inspect}"
32
+ end
33
+ end
34
+ end
35
+
36
+ module Rails22
37
+ def self.included(base)
38
+ base.class_eval do
39
+ alias_method_chain :log_processing_for_request_id, :request_id
40
+ end
41
+ end
42
+
43
+ private
44
+ def log_processing_for_request_id_with_request_id
45
+ log_processing_for_request_id_without_request_id
46
+ logger.info " Request ID: #{request_id} (port:#{request.port})"
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :request_id do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ require 'test/unit'
2
+
3
+ class RequestIdTest < Test::Unit::TestCase
4
+ # Replace this with your real tests.
5
+ def test_this_plugin
6
+ flunk
7
+ end
8
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maiha-request_id
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - maiha
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-16 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: ""
17
+ email: maiha@wota.jp
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - MIT-LICENSE
26
+ - README
27
+ - Rakefile
28
+ - init.rb
29
+ - install.rb
30
+ - lib/request_id.rb
31
+ - tasks/request_id_tasks.rake
32
+ - test/request_id_test.rb
33
+ - uninstall.rb
34
+ has_rdoc: true
35
+ homepage: http://github.com/maiha/request_id
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ requirements: []
54
+
55
+ rubyforge_project:
56
+ rubygems_version: 1.2.0
57
+ signing_key:
58
+ specification_version: 2
59
+ summary: ""
60
+ test_files: []
61
+