dclog 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 +7 -0
- data/.github/workflows/main.yml +19 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +25 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +198 -0
- data/LICENSE.txt +21 -0
- data/README.md +86 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/dclog.gemspec +37 -0
- data/lib/dclog.rb +37 -0
- data/lib/dclog/version.rb +5 -0
- metadata +135 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 234c6cbf8a91c2db908d2dcfc7d1ebd26a4190b6aeeb65304ff751a081cd3277
|
|
4
|
+
data.tar.gz: 2bcdaa72564ab32acffce6b41d3c09e8ffce1a8872123dcb1c7eb43c84768c30
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 750c2d7ceda983d659185f8d4057bcb1cacc7ebb26335fe9365a0f14bb36a22cc1253d61456028b7746dd72d7a9c055f71fe081413c569fc471655893ba5da46
|
|
7
|
+
data.tar.gz: 250e98740b03fccb80b9b8d1a6358e682b767ff4e5139e50a08917f6f96b0cf98a3ece5e91a8521654e53cf8c28c08ed7c83de94167b52ae8d6d61166a752430
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: Ruby
|
|
2
|
+
|
|
3
|
+
on: [push,pull_request]
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
build:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@v2
|
|
10
|
+
- name: Set up Ruby
|
|
11
|
+
uses: ruby/setup-ruby@v1
|
|
12
|
+
with:
|
|
13
|
+
ruby-version: 2.5.3
|
|
14
|
+
- name: Run tests
|
|
15
|
+
run: |
|
|
16
|
+
gem install bundler -v 2.2.13
|
|
17
|
+
bundle install
|
|
18
|
+
bundle exec rubocop
|
|
19
|
+
bundle exec rspec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.5
|
|
3
|
+
|
|
4
|
+
Style/StringLiterals:
|
|
5
|
+
Enabled: true
|
|
6
|
+
EnforcedStyle: single_quotes
|
|
7
|
+
|
|
8
|
+
Style/StringLiteralsInInterpolation:
|
|
9
|
+
Enabled: true
|
|
10
|
+
EnforcedStyle: double_quotes
|
|
11
|
+
|
|
12
|
+
Layout/LineLength:
|
|
13
|
+
Max: 120
|
|
14
|
+
|
|
15
|
+
Style/Documentation:
|
|
16
|
+
Enabled: false
|
|
17
|
+
|
|
18
|
+
Metrics/MethodLength:
|
|
19
|
+
Max: 20
|
|
20
|
+
|
|
21
|
+
Metrics/BlockLength:
|
|
22
|
+
Enabled: false
|
|
23
|
+
|
|
24
|
+
Style/StringConcatenation:
|
|
25
|
+
Enabled: false
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
dclog (0.1.0)
|
|
5
|
+
rails (>= 5.0.0)
|
|
6
|
+
sidekiq (>= 5.0.0)
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
actioncable (6.1.3.2)
|
|
12
|
+
actionpack (= 6.1.3.2)
|
|
13
|
+
activesupport (= 6.1.3.2)
|
|
14
|
+
nio4r (~> 2.0)
|
|
15
|
+
websocket-driver (>= 0.6.1)
|
|
16
|
+
actionmailbox (6.1.3.2)
|
|
17
|
+
actionpack (= 6.1.3.2)
|
|
18
|
+
activejob (= 6.1.3.2)
|
|
19
|
+
activerecord (= 6.1.3.2)
|
|
20
|
+
activestorage (= 6.1.3.2)
|
|
21
|
+
activesupport (= 6.1.3.2)
|
|
22
|
+
mail (>= 2.7.1)
|
|
23
|
+
actionmailer (6.1.3.2)
|
|
24
|
+
actionpack (= 6.1.3.2)
|
|
25
|
+
actionview (= 6.1.3.2)
|
|
26
|
+
activejob (= 6.1.3.2)
|
|
27
|
+
activesupport (= 6.1.3.2)
|
|
28
|
+
mail (~> 2.5, >= 2.5.4)
|
|
29
|
+
rails-dom-testing (~> 2.0)
|
|
30
|
+
actionpack (6.1.3.2)
|
|
31
|
+
actionview (= 6.1.3.2)
|
|
32
|
+
activesupport (= 6.1.3.2)
|
|
33
|
+
rack (~> 2.0, >= 2.0.9)
|
|
34
|
+
rack-test (>= 0.6.3)
|
|
35
|
+
rails-dom-testing (~> 2.0)
|
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
37
|
+
actiontext (6.1.3.2)
|
|
38
|
+
actionpack (= 6.1.3.2)
|
|
39
|
+
activerecord (= 6.1.3.2)
|
|
40
|
+
activestorage (= 6.1.3.2)
|
|
41
|
+
activesupport (= 6.1.3.2)
|
|
42
|
+
nokogiri (>= 1.8.5)
|
|
43
|
+
actionview (6.1.3.2)
|
|
44
|
+
activesupport (= 6.1.3.2)
|
|
45
|
+
builder (~> 3.1)
|
|
46
|
+
erubi (~> 1.4)
|
|
47
|
+
rails-dom-testing (~> 2.0)
|
|
48
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
49
|
+
activejob (6.1.3.2)
|
|
50
|
+
activesupport (= 6.1.3.2)
|
|
51
|
+
globalid (>= 0.3.6)
|
|
52
|
+
activemodel (6.1.3.2)
|
|
53
|
+
activesupport (= 6.1.3.2)
|
|
54
|
+
activerecord (6.1.3.2)
|
|
55
|
+
activemodel (= 6.1.3.2)
|
|
56
|
+
activesupport (= 6.1.3.2)
|
|
57
|
+
activestorage (6.1.3.2)
|
|
58
|
+
actionpack (= 6.1.3.2)
|
|
59
|
+
activejob (= 6.1.3.2)
|
|
60
|
+
activerecord (= 6.1.3.2)
|
|
61
|
+
activesupport (= 6.1.3.2)
|
|
62
|
+
marcel (~> 1.0.0)
|
|
63
|
+
mini_mime (~> 1.0.2)
|
|
64
|
+
activesupport (6.1.3.2)
|
|
65
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
66
|
+
i18n (>= 1.6, < 2)
|
|
67
|
+
minitest (>= 5.1)
|
|
68
|
+
tzinfo (~> 2.0)
|
|
69
|
+
zeitwerk (~> 2.3)
|
|
70
|
+
ast (2.4.2)
|
|
71
|
+
builder (3.2.4)
|
|
72
|
+
concurrent-ruby (1.1.9)
|
|
73
|
+
connection_pool (2.2.5)
|
|
74
|
+
crass (1.0.6)
|
|
75
|
+
diff-lcs (1.4.4)
|
|
76
|
+
docile (1.4.0)
|
|
77
|
+
erubi (1.10.0)
|
|
78
|
+
globalid (0.4.2)
|
|
79
|
+
activesupport (>= 4.2.0)
|
|
80
|
+
i18n (1.8.10)
|
|
81
|
+
concurrent-ruby (~> 1.0)
|
|
82
|
+
loofah (2.10.0)
|
|
83
|
+
crass (~> 1.0.2)
|
|
84
|
+
nokogiri (>= 1.5.9)
|
|
85
|
+
mail (2.7.1)
|
|
86
|
+
mini_mime (>= 0.1.1)
|
|
87
|
+
marcel (1.0.1)
|
|
88
|
+
method_source (1.0.0)
|
|
89
|
+
mini_mime (1.0.3)
|
|
90
|
+
mini_portile2 (2.5.3)
|
|
91
|
+
minitest (5.14.4)
|
|
92
|
+
nio4r (2.5.7)
|
|
93
|
+
nokogiri (1.11.7)
|
|
94
|
+
mini_portile2 (~> 2.5.0)
|
|
95
|
+
racc (~> 1.4)
|
|
96
|
+
parallel (1.20.1)
|
|
97
|
+
parser (3.0.1.1)
|
|
98
|
+
ast (~> 2.4.1)
|
|
99
|
+
racc (1.5.2)
|
|
100
|
+
rack (2.2.3)
|
|
101
|
+
rack-test (1.1.0)
|
|
102
|
+
rack (>= 1.0, < 3)
|
|
103
|
+
rails (6.1.3.2)
|
|
104
|
+
actioncable (= 6.1.3.2)
|
|
105
|
+
actionmailbox (= 6.1.3.2)
|
|
106
|
+
actionmailer (= 6.1.3.2)
|
|
107
|
+
actionpack (= 6.1.3.2)
|
|
108
|
+
actiontext (= 6.1.3.2)
|
|
109
|
+
actionview (= 6.1.3.2)
|
|
110
|
+
activejob (= 6.1.3.2)
|
|
111
|
+
activemodel (= 6.1.3.2)
|
|
112
|
+
activerecord (= 6.1.3.2)
|
|
113
|
+
activestorage (= 6.1.3.2)
|
|
114
|
+
activesupport (= 6.1.3.2)
|
|
115
|
+
bundler (>= 1.15.0)
|
|
116
|
+
railties (= 6.1.3.2)
|
|
117
|
+
sprockets-rails (>= 2.0.0)
|
|
118
|
+
rails-dom-testing (2.0.3)
|
|
119
|
+
activesupport (>= 4.2.0)
|
|
120
|
+
nokogiri (>= 1.6)
|
|
121
|
+
rails-html-sanitizer (1.3.0)
|
|
122
|
+
loofah (~> 2.3)
|
|
123
|
+
railties (6.1.3.2)
|
|
124
|
+
actionpack (= 6.1.3.2)
|
|
125
|
+
activesupport (= 6.1.3.2)
|
|
126
|
+
method_source
|
|
127
|
+
rake (>= 0.8.7)
|
|
128
|
+
thor (~> 1.0)
|
|
129
|
+
rainbow (3.0.0)
|
|
130
|
+
rake (13.0.3)
|
|
131
|
+
redis (4.3.1)
|
|
132
|
+
regexp_parser (2.1.1)
|
|
133
|
+
rexml (3.2.5)
|
|
134
|
+
rspec (3.10.0)
|
|
135
|
+
rspec-core (~> 3.10.0)
|
|
136
|
+
rspec-expectations (~> 3.10.0)
|
|
137
|
+
rspec-mocks (~> 3.10.0)
|
|
138
|
+
rspec-core (3.10.1)
|
|
139
|
+
rspec-support (~> 3.10.0)
|
|
140
|
+
rspec-expectations (3.10.1)
|
|
141
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
142
|
+
rspec-support (~> 3.10.0)
|
|
143
|
+
rspec-mocks (3.10.2)
|
|
144
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
145
|
+
rspec-support (~> 3.10.0)
|
|
146
|
+
rspec-support (3.10.2)
|
|
147
|
+
rubocop (1.17.0)
|
|
148
|
+
parallel (~> 1.10)
|
|
149
|
+
parser (>= 3.0.0.0)
|
|
150
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
151
|
+
regexp_parser (>= 1.8, < 3.0)
|
|
152
|
+
rexml
|
|
153
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
|
154
|
+
ruby-progressbar (~> 1.7)
|
|
155
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
|
156
|
+
rubocop-ast (1.7.0)
|
|
157
|
+
parser (>= 3.0.1.1)
|
|
158
|
+
ruby-progressbar (1.11.0)
|
|
159
|
+
sidekiq (6.2.1)
|
|
160
|
+
connection_pool (>= 2.2.2)
|
|
161
|
+
rack (~> 2.0)
|
|
162
|
+
redis (>= 4.2.0)
|
|
163
|
+
simplecov (0.21.2)
|
|
164
|
+
docile (~> 1.1)
|
|
165
|
+
simplecov-html (~> 0.11)
|
|
166
|
+
simplecov_json_formatter (~> 0.1)
|
|
167
|
+
simplecov-html (0.12.3)
|
|
168
|
+
simplecov_json_formatter (0.1.3)
|
|
169
|
+
sprockets (4.0.2)
|
|
170
|
+
concurrent-ruby (~> 1.0)
|
|
171
|
+
rack (> 1, < 3)
|
|
172
|
+
sprockets-rails (3.2.2)
|
|
173
|
+
actionpack (>= 4.0)
|
|
174
|
+
activesupport (>= 4.0)
|
|
175
|
+
sprockets (>= 3.0.0)
|
|
176
|
+
thor (1.1.0)
|
|
177
|
+
tzinfo (2.0.4)
|
|
178
|
+
concurrent-ruby (~> 1.0)
|
|
179
|
+
unicode-display_width (2.0.0)
|
|
180
|
+
websocket-driver (0.7.5)
|
|
181
|
+
websocket-extensions (>= 0.1.0)
|
|
182
|
+
websocket-extensions (0.1.5)
|
|
183
|
+
zeitwerk (2.4.2)
|
|
184
|
+
|
|
185
|
+
PLATFORMS
|
|
186
|
+
ruby
|
|
187
|
+
x86_64-darwin-19
|
|
188
|
+
x86_64-linux
|
|
189
|
+
|
|
190
|
+
DEPENDENCIES
|
|
191
|
+
dclog!
|
|
192
|
+
rake (~> 13.0)
|
|
193
|
+
rspec
|
|
194
|
+
rubocop
|
|
195
|
+
simplecov
|
|
196
|
+
|
|
197
|
+
BUNDLED WITH
|
|
198
|
+
2.2.20
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Jairo Aguiar
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# DcLog
|
|
2
|
+
|
|
3
|
+
## About
|
|
4
|
+
|
|
5
|
+
This gem provides you a garantee of logging stdout and stderr in both Rails and Sidekiq.
|
|
6
|
+
|
|
7
|
+
It creates a friendly interface to both Rails and Sidekiq loggers, trying to throw in the called function and considerably reducing code line size.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'dclog'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
And then execute:
|
|
18
|
+
|
|
19
|
+
$ bundle install
|
|
20
|
+
|
|
21
|
+
By configuring environment.rb, you can create a standard log to all environments. You can also set it up only in production.rb, but we recomemend that you create a standard in order to avoid overwriting environments.
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
# config/environment.rb
|
|
25
|
+
|
|
26
|
+
require_relative 'application'
|
|
27
|
+
|
|
28
|
+
Rails.application.configure do
|
|
29
|
+
...
|
|
30
|
+
|
|
31
|
+
logger = ActiveSupport::Logger.new($stdout)
|
|
32
|
+
logger.formatter = proc do |severity, datetime, progname, message|
|
|
33
|
+
"#{JSON.dump(
|
|
34
|
+
severity: severity,
|
|
35
|
+
date: datetime.strftime('%Y-%m-%d %H:%M:%S'),
|
|
36
|
+
caller: progname,
|
|
37
|
+
message: message
|
|
38
|
+
)}\n"
|
|
39
|
+
end
|
|
40
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
|
41
|
+
level = ENV.fetch('LOG_LEVEL', 'info')
|
|
42
|
+
config.log_level = Rails.env.test? ? :warn : level.underscore.to_sym
|
|
43
|
+
config.log_tags = [:request_id]
|
|
44
|
+
|
|
45
|
+
...
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
Rails.application.initialize!
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Usage
|
|
52
|
+
|
|
53
|
+
Call gem + severity level and it automatically searches the methods name.
|
|
54
|
+
|
|
55
|
+
```ruby
|
|
56
|
+
# info severity
|
|
57
|
+
Dclog.info('Information is key')
|
|
58
|
+
|
|
59
|
+
# warn severity
|
|
60
|
+
Dclog.warn('Beware of warning')
|
|
61
|
+
|
|
62
|
+
# error severity
|
|
63
|
+
Dclog.error('Another one bites the dust')
|
|
64
|
+
|
|
65
|
+
# fatal severity
|
|
66
|
+
Dclog.fatal('FATALITY')
|
|
67
|
+
|
|
68
|
+
# debug severity
|
|
69
|
+
Dclog.debug('Rubber duck time')
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
You should consider the possibility of replacing all log calls to only use Dclog in order to create a standard and avoid confusion.
|
|
73
|
+
|
|
74
|
+
## Development
|
|
75
|
+
|
|
76
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
77
|
+
|
|
78
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
79
|
+
|
|
80
|
+
## Contributing
|
|
81
|
+
|
|
82
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dclog.
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require 'bundler/setup'
|
|
5
|
+
require 'dclog'
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require 'irb'
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/dclog.gemspec
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/dclog/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'dclog'
|
|
7
|
+
spec.version = Dclog::VERSION
|
|
8
|
+
spec.authors = ['Jairo Junior', 'Matheus Acosta', 'Vinicius Machado']
|
|
9
|
+
spec.email = ['jairo.junior@deliverycenter.com', 'matheus.martins@deliverycenter.com',
|
|
10
|
+
'vinicius.santana@deliverycenter.com']
|
|
11
|
+
|
|
12
|
+
spec.summary = 'A logger'
|
|
13
|
+
spec.description = 'A gem to format logs to json, and run one commando to log into sidekiq and rails'
|
|
14
|
+
spec.homepage = 'https://github.com/deliverycenter/dclog'
|
|
15
|
+
spec.license = 'MIT'
|
|
16
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
|
|
17
|
+
|
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
19
|
+
spec.metadata['source_code_uri'] = 'https://github.com/deliverycenter/dclog'
|
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/deliverycenter/dclog'
|
|
21
|
+
|
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
|
26
|
+
end
|
|
27
|
+
spec.bindir = 'exe'
|
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
29
|
+
spec.require_paths = ['lib']
|
|
30
|
+
|
|
31
|
+
spec.add_development_dependency 'rspec'
|
|
32
|
+
spec.add_development_dependency 'rubocop'
|
|
33
|
+
spec.add_development_dependency 'simplecov'
|
|
34
|
+
|
|
35
|
+
spec.add_dependency 'rails', '>= 5.0.0'
|
|
36
|
+
spec.add_dependency 'sidekiq', '>= 5.0.0'
|
|
37
|
+
end
|
data/lib/dclog.rb
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails'
|
|
4
|
+
require 'sidekiq'
|
|
5
|
+
require_relative 'dclog/version'
|
|
6
|
+
|
|
7
|
+
module Dclog
|
|
8
|
+
class << self
|
|
9
|
+
def method_missing(method, *args)
|
|
10
|
+
caller = caller_locations.first.label
|
|
11
|
+
message = args[0]
|
|
12
|
+
|
|
13
|
+
log_to_stdout(method, caller, message)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def respond_to_missing?(method, include_private = false)
|
|
17
|
+
valid_level?(method) || super
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def valid_level?(severity)
|
|
23
|
+
%i[info warn error fatal debug].include?(severity)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def raise_no_method_error!(severity)
|
|
27
|
+
raise NoMethodError, "undefined method '#{severity}' for Log:Class"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def log_to_stdout(severity, caller, message)
|
|
31
|
+
raise_no_method_error!(severity) unless valid_level?(severity)
|
|
32
|
+
|
|
33
|
+
Sidekiq.logger.send(severity, caller) { message }
|
|
34
|
+
Rails.logger.send(severity, caller) { message }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: dclog
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Jairo Junior
|
|
8
|
+
- Matheus Acosta
|
|
9
|
+
- Vinicius Machado
|
|
10
|
+
autorequire:
|
|
11
|
+
bindir: exe
|
|
12
|
+
cert_chain: []
|
|
13
|
+
date: 2021-08-13 00:00:00.000000000 Z
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: rspec
|
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
|
18
|
+
requirements:
|
|
19
|
+
- - ">="
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '0'
|
|
29
|
+
- !ruby/object:Gem::Dependency
|
|
30
|
+
name: rubocop
|
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '0'
|
|
36
|
+
type: :development
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0'
|
|
43
|
+
- !ruby/object:Gem::Dependency
|
|
44
|
+
name: simplecov
|
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
type: :development
|
|
51
|
+
prerelease: false
|
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
57
|
+
- !ruby/object:Gem::Dependency
|
|
58
|
+
name: rails
|
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: 5.0.0
|
|
64
|
+
type: :runtime
|
|
65
|
+
prerelease: false
|
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
67
|
+
requirements:
|
|
68
|
+
- - ">="
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
version: 5.0.0
|
|
71
|
+
- !ruby/object:Gem::Dependency
|
|
72
|
+
name: sidekiq
|
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
|
74
|
+
requirements:
|
|
75
|
+
- - ">="
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: 5.0.0
|
|
78
|
+
type: :runtime
|
|
79
|
+
prerelease: false
|
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
81
|
+
requirements:
|
|
82
|
+
- - ">="
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: 5.0.0
|
|
85
|
+
description: A gem to format logs to json, and run one commando to log into sidekiq
|
|
86
|
+
and rails
|
|
87
|
+
email:
|
|
88
|
+
- jairo.junior@deliverycenter.com
|
|
89
|
+
- matheus.martins@deliverycenter.com
|
|
90
|
+
- vinicius.santana@deliverycenter.com
|
|
91
|
+
executables: []
|
|
92
|
+
extensions: []
|
|
93
|
+
extra_rdoc_files: []
|
|
94
|
+
files:
|
|
95
|
+
- ".github/workflows/main.yml"
|
|
96
|
+
- ".gitignore"
|
|
97
|
+
- ".rspec"
|
|
98
|
+
- ".rubocop.yml"
|
|
99
|
+
- Gemfile
|
|
100
|
+
- Gemfile.lock
|
|
101
|
+
- LICENSE.txt
|
|
102
|
+
- README.md
|
|
103
|
+
- Rakefile
|
|
104
|
+
- bin/console
|
|
105
|
+
- bin/setup
|
|
106
|
+
- dclog.gemspec
|
|
107
|
+
- lib/dclog.rb
|
|
108
|
+
- lib/dclog/version.rb
|
|
109
|
+
homepage: https://github.com/deliverycenter/dclog
|
|
110
|
+
licenses:
|
|
111
|
+
- MIT
|
|
112
|
+
metadata:
|
|
113
|
+
homepage_uri: https://github.com/deliverycenter/dclog
|
|
114
|
+
source_code_uri: https://github.com/deliverycenter/dclog
|
|
115
|
+
changelog_uri: https://github.com/deliverycenter/dclog
|
|
116
|
+
post_install_message:
|
|
117
|
+
rdoc_options: []
|
|
118
|
+
require_paths:
|
|
119
|
+
- lib
|
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 2.5.0
|
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: '0'
|
|
130
|
+
requirements: []
|
|
131
|
+
rubygems_version: 3.1.2
|
|
132
|
+
signing_key:
|
|
133
|
+
specification_version: 4
|
|
134
|
+
summary: A logger
|
|
135
|
+
test_files: []
|