console-adapter-sidekiq 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b2a82903d05ac6520b80c7be32d31966b0722e9baa52b257dd713217d58f8e83
4
+ data.tar.gz: 2174b91d8eb53600298fbd84e508d383ce1728ace3f7bbf0e8ded6db918b6011
5
+ SHA512:
6
+ metadata.gz: 577bba47591db55d1b3239a9c54295f14e5b774097b589cf1bf31c3200ed7238925bdb3101b573bc25fdb80c4a94c5a8b6482fa4bb145f396b7a50f67304ae5b
7
+ data.tar.gz: b55c5b2627474074e15f5848fc05174d7d10f3bf879d70f5a3750f2aae418e372c16222ece0654758dff8e6e4faa5461dbc6e33e4ce3c123ac45d454237ac01f
checksums.yaml.gz.sig ADDED
Binary file
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Samuel Williams.
5
+
6
+ require 'console'
7
+ require 'sidekiq'
8
+
9
+ module Console
10
+ module Adapter
11
+ module Sidekiq
12
+ # Custom error handler for Sidekiq.
13
+ ErrorHandler = lambda do |exception, context|
14
+ job = context[:job] || {}
15
+ Console.error(::Sidekiq, exception, **job)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Samuel Williams.
5
+
6
+ require 'console'
7
+ require 'console/compatible/logger'
8
+ require 'sidekiq'
9
+
10
+ module Console
11
+ module Adapter
12
+ module Sidekiq
13
+ # An output wrapper that adds Sidekiq context to the output.
14
+ class Wrapper
15
+ def initialize(output)
16
+ @output = output
17
+ end
18
+
19
+ def call(*arguments, **options, &block)
20
+ if (context = ::Sidekiq::Context.current)
21
+ options.update(context)
22
+ end
23
+
24
+ @output.call(*arguments, **options, &block)
25
+ end
26
+ end
27
+
28
+ # A compatible logger for sidekiq that prevents monkey patching.
29
+ class Logger < Console::Compatible::Logger
30
+ def initialize(subject, output = Console)
31
+ super(subject, Wrapper.new(output))
32
+ end
33
+
34
+ # Prevent Sidekiq from messing with internal behaviour.
35
+ # see: https://github.com/mperham/sidekiq/blob/v6.5.8/lib/sidekiq.rb#L285
36
+ def extend(*args); end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Samuel Williams.
5
+
6
+ module Console
7
+ module Adapter
8
+ module Sidekiq
9
+ VERSION = "0.1.0"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Samuel Williams.
5
+
6
+ require 'sidekiq'
7
+
8
+ require_relative 'sidekiq/error_handler'
9
+ require_relative 'sidekiq/logger'
10
+
11
+ module Console
12
+ module Adapter
13
+ module Sidekiq
14
+ def self.apply!
15
+ if ::Sidekiq.respond_to?(:default_configuration)
16
+ # Sidekiq 7+
17
+ ::Sidekiq.default_configuration.logger = Logger.new(::Sidekiq)
18
+ ::Sidekiq.default_configuration[:error_handlers] = [ErrorHandler]
19
+ else
20
+ # Sidekiq < 7
21
+ ::Sidekiq.logger = Logger.new(::Sidekiq)
22
+ ::Sidekiq.error_handlers << ErrorHandler
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
data/license.md ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright, 2023, by Samuel Williams.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/readme.md ADDED
@@ -0,0 +1,33 @@
1
+ # Console::Adapter::Sidekiq
2
+
3
+ Adapt Sidekiq event logs for `console`.
4
+
5
+ [![Development
6
+ Status](https://github.com/socketry/console-adapter-sidekiq/workflows/Test/badge.svg)](https://github.com/socketry/console-adapter-sidekiq/actions?workflow=Test)
7
+
8
+ ## Usage
9
+
10
+ Please see the [project documentation](https://github.com/socketry/console-adapter-sidekiq) for more details.
11
+
12
+ - [Getting Started](https://github.com/socketry/console-adapter-sidekiqguides/getting-started/index) - This guide
13
+ explains how to integrate the `console-adapter-sidekiq` gem into your Sidekiq application.
14
+
15
+ ## Contributing
16
+
17
+ We welcome contributions to this project.
18
+
19
+ 1. Fork it.
20
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
21
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
22
+ 4. Push to the branch (`git push origin my-new-feature`).
23
+ 5. Create new Pull Request.
24
+
25
+ ### Developer Certificate of Origin
26
+
27
+ This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this
28
+ project must agree to this document to have their contributions accepted.
29
+
30
+ ### Contributor Covenant
31
+
32
+ This project is governed by [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and
33
+ participants agree to abide by its terms.
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: console-adapter-sidekiq
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Williams
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11
14
+ ZWwud2lsbGlhbXMxHTAbBgoJkiaJk/IsZAEZFg1vcmlvbnRyYW5zZmVyMRIwEAYK
15
+ CZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJuejAeFw0yMjA4MDYwNDUz
16
+ MjRaFw0zMjA4MDMwNDUzMjRaMGExGDAWBgNVBAMMD3NhbXVlbC53aWxsaWFtczEd
17
+ MBsGCgmSJomT8ixkARkWDW9yaW9udHJhbnNmZXIxEjAQBgoJkiaJk/IsZAEZFgJj
18
+ bzESMBAGCgmSJomT8ixkARkWAm56MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIB
19
+ igKCAYEAomvSopQXQ24+9DBB6I6jxRI2auu3VVb4nOjmmHq7XWM4u3HL+pni63X2
20
+ 9qZdoq9xt7H+RPbwL28LDpDNflYQXoOhoVhQ37Pjn9YDjl8/4/9xa9+NUpl9XDIW
21
+ sGkaOY0eqsQm1pEWkHJr3zn/fxoKPZPfaJOglovdxf7dgsHz67Xgd/ka+Wo1YqoE
22
+ e5AUKRwUuvaUaumAKgPH+4E4oiLXI4T1Ff5Q7xxv6yXvHuYtlMHhYfgNn8iiW8WN
23
+ XibYXPNP7NtieSQqwR/xM6IRSoyXKuS+ZNGDPUUGk8RoiV/xvVN4LrVm9upSc0ss
24
+ RZ6qwOQmXCo/lLcDUxJAgG95cPw//sI00tZan75VgsGzSWAOdjQpFM0l4dxvKwHn
25
+ tUeT3ZsAgt0JnGqNm2Bkz81kG4A2hSyFZTFA8vZGhp+hz+8Q573tAR89y9YJBdYM
26
+ zp0FM4zwMNEUwgfRzv1tEVVUEXmoFCyhzonUUw4nE4CFu/sE3ffhjKcXcY//qiSW
27
+ xm4erY3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
28
+ BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
29
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
30
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
31
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
32
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
33
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
34
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
35
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
36
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
37
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
38
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
39
+ -----END CERTIFICATE-----
40
+ date: 2023-08-07 00:00:00.000000000 Z
41
+ dependencies:
42
+ - !ruby/object:Gem::Dependency
43
+ name: console
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.21'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.21'
56
+ - !ruby/object:Gem::Dependency
57
+ name: sidekiq
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '6.0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '6.0'
70
+ description:
71
+ email:
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/console/adapter/sidekiq.rb
77
+ - lib/console/adapter/sidekiq/error_handler.rb
78
+ - lib/console/adapter/sidekiq/logger.rb
79
+ - lib/console/adapter/sidekiq/version.rb
80
+ - license.md
81
+ - readme.md
82
+ homepage: https://github.com/socketry/console-adapter-sidekiq
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '3.0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.4.10
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Adapt Sidekiq logs and events to the console gem.
105
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ 3��sQ�2����s�\�H�����Ta�Ex�Za
2
+ !"fK��K� l�T�a}a@���q՛��s��@ �
3
+ W0�fQ/6�6�� ��~�j\ �B �暧��rm�X�-=��Y �ˇ������˧CY�P h��F��B$geY }y��1Y�}�ii�WOZu���LKl�0B*שƬ�ܴ�x��K�ei�׮\rm4���:޳���G䱘Xfj�d����'�k\���u�1z}�3�^D�;/�!����������e�+�#5�� �F�� �:�_���������q5%CF�� ��^��kΊ��