sidekiq_parameters_logging 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3c00a97157720bf54c57efbe1277aaf0efdc93e1
4
+ data.tar.gz: 7dc5e35a22ade77a08d71c604817ecbca957de0c
5
+ SHA512:
6
+ metadata.gz: e39f667827656f8d8a6884abe78a02742497a18e496a822d39bbe694b91aeeb66202f9249a5480f7e6e0d5760db7b349a4c0e34b0e6a37c17a189e3a5ca470da
7
+ data.tar.gz: ad3116cd6f699a22e58d71a821060439f85b4b04d65bc0c057c32ac78e93b6b7bcaab8d183a65aad6f57ff1d697d33f5e1eaae89d28c14b39dffd5019b0eca9d
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 Teng Siong Ong
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.markdown ADDED
@@ -0,0 +1,43 @@
1
+ # Sidekiq::Parameters::Logging
2
+
3
+ `Sidekiq::Parameters::Logging` is a middleware for Sidekiq to log all the parameters that you pass to your worker. For example:
4
+
5
+ ```ruby
6
+ class Worker
7
+ include Sidekiq::Worker
8
+
9
+ def perform(*args)
10
+ # do something
11
+ end
12
+ end
13
+ ```
14
+
15
+ When you run sidekiq, you see this:
16
+
17
+ ```
18
+ # without Sidekiq::Parameters::Logging
19
+ Worker JID-ae4889cc009b554132fed3a0 INFO: start
20
+ Worker JID-ae4889cc009b554132fed3a0 INFO: done: 3.363 sec
21
+
22
+ # with Sidekiq::Parameters::Logging
23
+ Worker JID-ae4889cc009b554132fed3a0 INFO: start
24
+ Worker JID-ae4889cc009b554132fed3a0 INFO: parameters: #{args.inspect}
25
+ Worker JID-ae4889cc009b554132fed3a0 INFO: done: 3.363 sec
26
+
27
+ ```
28
+
29
+ ## Notes
30
+
31
+ `Sidekiq::Parameters::Logging` replaces the standard `Sidekiq::Middleware::Server::Logging`.
32
+
33
+ ## License
34
+
35
+ (The MIT License)
36
+
37
+ Copyright (c) 2013 Teng Siong Ong
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
40
+
41
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,28 @@
1
+ module Sidekiq
2
+ class Parameters
3
+ class Logging
4
+ def call(worker, item, queue)
5
+ Sidekiq::Logging.with_context("#{worker.class.to_s} JID-#{item['jid']}") do
6
+ begin
7
+ start = Time.now
8
+ logger.info { "start" }
9
+ logger.info { "parameters: #{item['args'].inspect}" }
10
+ yield
11
+ logger.info { "done: #{elapsed(start)} sec" }
12
+ rescue Exception
13
+ logger.info { "fail: #{elapsed(start)} sec" }
14
+ raise
15
+ end
16
+ end
17
+ end
18
+
19
+ def elapsed(start)
20
+ (Time.now - start).to_f.round(3)
21
+ end
22
+
23
+ def logger
24
+ Sidekiq.logger
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ require 'sidekiq/parameters/logging'
2
+
3
+ Sidekiq.configure_server do |config|
4
+ config.server_middleware do |chain|
5
+ chain.remove Sidekiq::Middleware::Server::Logging
6
+ chain.add Sidekiq::Parameters::Logging
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sidekiq_parameters_logging
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Teng Siong Ong
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sidekiq
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
27
+ description: Sidekiq::Paramters::Logging middleware to log parameters passsed to each
28
+ worker.
29
+ email:
30
+ - siong1987@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - lib/sidekiq/parameters/logging.rb
36
+ - lib/sidekiq_parameters_logging.rb
37
+ - MIT-LICENSE
38
+ - README.markdown
39
+ homepage: https://github.com/siong1987/sidekiq_parameters_logging
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.0.3
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Sidekiq::Paramters::Logging middleware to log parameters passsed to each
63
+ worker.
64
+ test_files: []