dclog 0.1.0 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 234c6cbf8a91c2db908d2dcfc7d1ebd26a4190b6aeeb65304ff751a081cd3277
4
- data.tar.gz: 2bcdaa72564ab32acffce6b41d3c09e8ffce1a8872123dcb1c7eb43c84768c30
3
+ metadata.gz: ee9d53ab78011fdc8e755825e2fbdb43204800c765686a2fdb9d5c6744065b53
4
+ data.tar.gz: e85ae2c88f45b46c56fbe104db22790e2aa33a5b50dde9118eed86077398c8b5
5
5
  SHA512:
6
- metadata.gz: 750c2d7ceda983d659185f8d4057bcb1cacc7ebb26335fe9365a0f14bb36a22cc1253d61456028b7746dd72d7a9c055f71fe081413c569fc471655893ba5da46
7
- data.tar.gz: 250e98740b03fccb80b9b8d1a6358e682b767ff4e5139e50a08917f6f96b0cf98a3ece5e91a8521654e53cf8c28c08ed7c83de94167b52ae8d6d61166a752430
6
+ metadata.gz: 989fde408ff44bd9c86658dae311434fc2a0ab381452058dc7947ce16b32b967865f459c3ae8277d2021b47e94dab235c442cc5f10cda74ac66013edefce76f4
7
+ data.tar.gz: e474783df280fe5375bc1025b8d3a63f0be0259fbbd7150a0dd1c8bdd4c9d6a138dc0798da8349e58e0124b93be2fd973554633efc70e37efeeaa06b92e83961
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,92 @@
1
+ # Contributing
2
+
3
+ When contributing to this repository, please first discuss the change you wish to make via issue,
4
+ email, or any other method with the owners of this repository before making a change.
5
+
6
+ Please note we have a code of conduct, please follow it in all your interactions with the project.
7
+
8
+ ## Pull Request Process
9
+
10
+ 1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11
+ build.
12
+ 2. Update the README.md with details of changes to the interface, this includes new environment
13
+ variables, exposed ports, useful file locations and container parameters.
14
+ 3. Increase the version numbers in any examples files and the README.md to the new version that this
15
+ Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
16
+ 4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
17
+ do not have permission to do that, you may request the second reviewer to merge it for you.
18
+
19
+ ## Code of Conduct
20
+
21
+ ### Our Pledge
22
+
23
+ In the interest of fostering an open and welcoming environment, we as
24
+ contributors and maintainers pledge to making participation in our project and
25
+ our community a harassment-free experience for everyone, regardless of age, body
26
+ size, disability, ethnicity, gender identity and expression, level of experience,
27
+ nationality, personal appearance, race, religion, or sexual identity and
28
+ orientation.
29
+
30
+ ### Our Standards
31
+
32
+ Examples of behavior that contributes to creating a positive environment
33
+ include:
34
+
35
+ * Using welcoming and inclusive language
36
+ * Being respectful of differing viewpoints and experiences
37
+ * Gracefully accepting constructive criticism
38
+ * Focusing on what is best for the community
39
+ * Showing empathy towards other community members
40
+
41
+ Examples of unacceptable behavior by participants include:
42
+
43
+ * The use of sexualized language or imagery and unwelcome sexual attention or
44
+ advances
45
+ * Trolling, insulting/derogatory comments, and personal or political attacks
46
+ * Public or private harassment
47
+ * Publishing others' private information, such as a physical or electronic
48
+ address, without explicit permission
49
+ * Other conduct which could reasonably be considered inappropriate in a
50
+ professional setting
51
+
52
+ ### Our Responsibilities
53
+
54
+ Project maintainers are responsible for clarifying the standards of acceptable
55
+ behavior and are expected to take appropriate and fair corrective action in
56
+ response to any instances of unacceptable behavior.
57
+
58
+ Project maintainers have the right and responsibility to remove, edit, or
59
+ reject comments, commits, code, wiki edits, issues, and other contributions
60
+ that are not aligned to this Code of Conduct, or to ban temporarily or
61
+ permanently any contributor for other behaviors that they deem inappropriate,
62
+ threatening, offensive, or harmful.
63
+
64
+ ### Scope
65
+
66
+ This Code of Conduct applies both within project spaces and in public spaces
67
+ when an individual is representing the project or its community. Examples of
68
+ representing a project or community include using an official project e-mail
69
+ address, posting via an official social media account, or acting as an appointed
70
+ representative at an online or offline event. Representation of a project may be
71
+ further defined and clarified by project maintainers.
72
+
73
+ ### Enforcement
74
+
75
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
76
+ reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
77
+ complaints will be reviewed and investigated and will result in a response that
78
+ is deemed necessary and appropriate to the circumstances. The project team is
79
+ obligated to maintain confidentiality with regard to the reporter of an incident.
80
+ Further details of specific enforcement policies may be posted separately.
81
+
82
+ Project maintainers who do not follow or enforce the Code of Conduct in good
83
+ faith may face temporary or permanent repercussions as determined by other
84
+ members of the project's leadership.
85
+
86
+ ### Attribution
87
+
88
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
89
+ available at [http://contributor-covenant.org/version/1/4][version]
90
+
91
+ [homepage]: http://contributor-covenant.org
92
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile.lock CHANGED
@@ -1,67 +1,66 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dclog (0.1.0)
4
+ dclog (0.2.3)
5
5
  rails (>= 5.0.0)
6
- sidekiq (>= 5.0.0)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- actioncable (6.1.3.2)
12
- actionpack (= 6.1.3.2)
13
- activesupport (= 6.1.3.2)
10
+ actioncable (6.1.4.1)
11
+ actionpack (= 6.1.4.1)
12
+ activesupport (= 6.1.4.1)
14
13
  nio4r (~> 2.0)
15
14
  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)
15
+ actionmailbox (6.1.4.1)
16
+ actionpack (= 6.1.4.1)
17
+ activejob (= 6.1.4.1)
18
+ activerecord (= 6.1.4.1)
19
+ activestorage (= 6.1.4.1)
20
+ activesupport (= 6.1.4.1)
22
21
  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)
22
+ actionmailer (6.1.4.1)
23
+ actionpack (= 6.1.4.1)
24
+ actionview (= 6.1.4.1)
25
+ activejob (= 6.1.4.1)
26
+ activesupport (= 6.1.4.1)
28
27
  mail (~> 2.5, >= 2.5.4)
29
28
  rails-dom-testing (~> 2.0)
30
- actionpack (6.1.3.2)
31
- actionview (= 6.1.3.2)
32
- activesupport (= 6.1.3.2)
29
+ actionpack (6.1.4.1)
30
+ actionview (= 6.1.4.1)
31
+ activesupport (= 6.1.4.1)
33
32
  rack (~> 2.0, >= 2.0.9)
34
33
  rack-test (>= 0.6.3)
35
34
  rails-dom-testing (~> 2.0)
36
35
  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)
36
+ actiontext (6.1.4.1)
37
+ actionpack (= 6.1.4.1)
38
+ activerecord (= 6.1.4.1)
39
+ activestorage (= 6.1.4.1)
40
+ activesupport (= 6.1.4.1)
42
41
  nokogiri (>= 1.8.5)
43
- actionview (6.1.3.2)
44
- activesupport (= 6.1.3.2)
42
+ actionview (6.1.4.1)
43
+ activesupport (= 6.1.4.1)
45
44
  builder (~> 3.1)
46
45
  erubi (~> 1.4)
47
46
  rails-dom-testing (~> 2.0)
48
47
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
49
- activejob (6.1.3.2)
50
- activesupport (= 6.1.3.2)
48
+ activejob (6.1.4.1)
49
+ activesupport (= 6.1.4.1)
51
50
  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)
51
+ activemodel (6.1.4.1)
52
+ activesupport (= 6.1.4.1)
53
+ activerecord (6.1.4.1)
54
+ activemodel (= 6.1.4.1)
55
+ activesupport (= 6.1.4.1)
56
+ activestorage (6.1.4.1)
57
+ actionpack (= 6.1.4.1)
58
+ activejob (= 6.1.4.1)
59
+ activerecord (= 6.1.4.1)
60
+ activesupport (= 6.1.4.1)
62
61
  marcel (~> 1.0.0)
63
- mini_mime (~> 1.0.2)
64
- activesupport (6.1.3.2)
62
+ mini_mime (>= 1.1.0)
63
+ activesupport (6.1.4.1)
65
64
  concurrent-ruby (~> 1.0, >= 1.0.2)
66
65
  i18n (>= 1.6, < 2)
67
66
  minitest (>= 5.1)
@@ -70,28 +69,27 @@ GEM
70
69
  ast (2.4.2)
71
70
  builder (3.2.4)
72
71
  concurrent-ruby (1.1.9)
73
- connection_pool (2.2.5)
74
72
  crass (1.0.6)
75
73
  diff-lcs (1.4.4)
76
74
  docile (1.4.0)
77
75
  erubi (1.10.0)
78
- globalid (0.4.2)
79
- activesupport (>= 4.2.0)
76
+ globalid (0.5.2)
77
+ activesupport (>= 5.0)
80
78
  i18n (1.8.10)
81
79
  concurrent-ruby (~> 1.0)
82
- loofah (2.10.0)
80
+ loofah (2.12.0)
83
81
  crass (~> 1.0.2)
84
82
  nokogiri (>= 1.5.9)
85
83
  mail (2.7.1)
86
84
  mini_mime (>= 0.1.1)
87
- marcel (1.0.1)
85
+ marcel (1.0.2)
88
86
  method_source (1.0.0)
89
- mini_mime (1.0.3)
90
- mini_portile2 (2.5.3)
87
+ mini_mime (1.1.1)
88
+ mini_portile2 (2.6.1)
91
89
  minitest (5.14.4)
92
- nio4r (2.5.7)
93
- nokogiri (1.11.7)
94
- mini_portile2 (~> 2.5.0)
90
+ nio4r (2.5.8)
91
+ nokogiri (1.12.5)
92
+ mini_portile2 (~> 2.6.1)
95
93
  racc (~> 1.4)
96
94
  parallel (1.20.1)
97
95
  parser (3.0.1.1)
@@ -100,35 +98,34 @@ GEM
100
98
  rack (2.2.3)
101
99
  rack-test (1.1.0)
102
100
  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)
101
+ rails (6.1.4.1)
102
+ actioncable (= 6.1.4.1)
103
+ actionmailbox (= 6.1.4.1)
104
+ actionmailer (= 6.1.4.1)
105
+ actionpack (= 6.1.4.1)
106
+ actiontext (= 6.1.4.1)
107
+ actionview (= 6.1.4.1)
108
+ activejob (= 6.1.4.1)
109
+ activemodel (= 6.1.4.1)
110
+ activerecord (= 6.1.4.1)
111
+ activestorage (= 6.1.4.1)
112
+ activesupport (= 6.1.4.1)
115
113
  bundler (>= 1.15.0)
116
- railties (= 6.1.3.2)
114
+ railties (= 6.1.4.1)
117
115
  sprockets-rails (>= 2.0.0)
118
116
  rails-dom-testing (2.0.3)
119
117
  activesupport (>= 4.2.0)
120
118
  nokogiri (>= 1.6)
121
- rails-html-sanitizer (1.3.0)
119
+ rails-html-sanitizer (1.4.2)
122
120
  loofah (~> 2.3)
123
- railties (6.1.3.2)
124
- actionpack (= 6.1.3.2)
125
- activesupport (= 6.1.3.2)
121
+ railties (6.1.4.1)
122
+ actionpack (= 6.1.4.1)
123
+ activesupport (= 6.1.4.1)
126
124
  method_source
127
- rake (>= 0.8.7)
125
+ rake (>= 0.13)
128
126
  thor (~> 1.0)
129
127
  rainbow (3.0.0)
130
128
  rake (13.0.3)
131
- redis (4.3.1)
132
129
  regexp_parser (2.1.1)
133
130
  rexml (3.2.5)
134
131
  rspec (3.10.0)
@@ -156,10 +153,6 @@ GEM
156
153
  rubocop-ast (1.7.0)
157
154
  parser (>= 3.0.1.1)
158
155
  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
156
  simplecov (0.21.2)
164
157
  docile (~> 1.1)
165
158
  simplecov-html (~> 0.11)
data/README.md CHANGED
@@ -30,11 +30,16 @@ Rails.application.configure do
30
30
 
31
31
  logger = ActiveSupport::Logger.new($stdout)
32
32
  logger.formatter = proc do |severity, datetime, progname, message|
33
+ msg_regex = message.match(Dclog::LOG_REGEX)
34
+ request_id = msg_regex.nil? ? nil : msg_regex[1]
35
+ msg = msg_regex.nil? ? message : msg_regex[2]
36
+
33
37
  "#{JSON.dump(
34
38
  severity: severity,
35
39
  date: datetime.strftime('%Y-%m-%d %H:%M:%S'),
36
40
  caller: progname,
37
- message: message
41
+ request_id: request_id,
42
+ message: msg
38
43
  )}\n"
39
44
  end
40
45
  config.logger = ActiveSupport::TaggedLogging.new(logger)
data/dclog.gemspec CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.name = 'dclog'
7
7
  spec.version = Dclog::VERSION
8
8
  spec.authors = ['Jairo Junior', 'Matheus Acosta', 'Vinicius Machado']
9
- spec.email = ['jairo.junior@deliverycenter.com', 'matheus.martins@deliverycenter.com',
9
+ spec.email = ['jairo.junior@deliverycenter.com', 'matheusthebr@gmail.com',
10
10
  'vinicius.santana@deliverycenter.com']
11
11
 
12
12
  spec.summary = 'A logger'
@@ -33,5 +33,4 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'simplecov'
34
34
 
35
35
  spec.add_dependency 'rails', '>= 5.0.0'
36
- spec.add_dependency 'sidekiq', '>= 5.0.0'
37
36
  end
data/lib/dclog/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dclog
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.3'
5
5
  end
data/lib/dclog.rb CHANGED
@@ -1,10 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rails'
4
- require 'sidekiq'
5
4
  require_relative 'dclog/version'
6
5
 
6
+ begin
7
+ require 'sidekiq'
8
+ rescue LoadError
9
+ puts 'The Sidekiq gem is not installed'
10
+ end
11
+
7
12
  module Dclog
13
+ LOG_REGEX = /^\[([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})\]\s+(.+)$/.freeze
14
+
8
15
  class << self
9
16
  def method_missing(method, *args)
10
17
  caller = caller_locations.first.label
@@ -24,13 +31,13 @@ module Dclog
24
31
  end
25
32
 
26
33
  def raise_no_method_error!(severity)
27
- raise NoMethodError, "undefined method '#{severity}' for Log:Class"
34
+ raise NoMethodError, "undefined method '#{severity}' for Dclog:Class"
28
35
  end
29
36
 
30
37
  def log_to_stdout(severity, caller, message)
31
38
  raise_no_method_error!(severity) unless valid_level?(severity)
32
39
 
33
- Sidekiq.logger.send(severity, caller) { message }
40
+ Sidekiq.logger.send(severity, caller) { message } if defined?(Sidekiq)
34
41
  Rails.logger.send(severity, caller) { message }
35
42
  end
36
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dclog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jairo Junior
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-08-13 00:00:00.000000000 Z
13
+ date: 2021-10-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -68,25 +68,11 @@ dependencies:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
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
71
  description: A gem to format logs to json, and run one commando to log into sidekiq
86
72
  and rails
87
73
  email:
88
74
  - jairo.junior@deliverycenter.com
89
- - matheus.martins@deliverycenter.com
75
+ - matheusthebr@gmail.com
90
76
  - vinicius.santana@deliverycenter.com
91
77
  executables: []
92
78
  extensions: []
@@ -96,6 +82,7 @@ files:
96
82
  - ".gitignore"
97
83
  - ".rspec"
98
84
  - ".rubocop.yml"
85
+ - CONTRIBUTING.md
99
86
  - Gemfile
100
87
  - Gemfile.lock
101
88
  - LICENSE.txt