ezlog 0.3.2 → 0.3.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
- SHA1:
3
- metadata.gz: 224d8e39821229350d6b406645432d210cc2b2e8
4
- data.tar.gz: 45d821f0923048e29c085a3a86a6104776b2dbc0
2
+ SHA256:
3
+ metadata.gz: e820d0ac516dc835494a109ac51e172f73f90be55e756ccc248a4a87fc7c890c
4
+ data.tar.gz: 83153708c674634ccbe37193a7945038d3b1758e1f114b9cd33609c937cda102
5
5
  SHA512:
6
- metadata.gz: 8ad716714f7e5cef573a434828bca5984ed5af24222a339f1e9712a9e4ccb3478f326c01219fac4f01e34afad0b25b052c550309626d4c04a861be673b2bb46b
7
- data.tar.gz: febe42af5f6d3356e644cce5c43c289bcba87cc8a1caa2ace751f9fd7d23cbc66be7ea59c5251c44cdd55436f4136fab9985ece9e41552d77b05b48a95e8dd8e
6
+ metadata.gz: c68f24ec9b95d3175d1d2140cdf1b918704fda5d6dab419cf6a2dac370137860d4c25d2ef2433af660d124e80aa152138db3be8991e09da93bde0ba5d70b2867
7
+ data.tar.gz: 0f1614756509f95871e96330aa95b2f498d91ed3be358d8b8d6b3c18699b5015511dac9c413b4e355f72ccc05f837ce86599908811572e2d928a85cacd9134b7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 0.3.3 (2019-08-10)
2
+
3
+ [Full Changelog](https://github.com/emartech/ezlog/compare/v0.3.2...v0.3.3)
4
+
5
+ * Features & enhancements
6
+ * [Sidekiq](https://github.com/mperham/sidekiq) logging respects the log level configured for the application.
7
+ * Log level can be set from an environment variable (LOG_LEVEL).
8
+
1
9
  ### 0.3.2 (2019-06-18)
2
10
 
3
11
  [Full Changelog](https://github.com/emartech/ezlog/compare/v0.3.1...v0.3.2)
data/README.md CHANGED
@@ -39,7 +39,7 @@ That's it. Everything else is automatically configured.
39
39
  * Configures [Rack::Timeout](https://github.com/heroku/rack-timeout) logging
40
40
  * Provides testing support for [RSpec](https://rspec.info/)
41
41
 
42
- #### Initializes the Logging library
42
+ ### Initializes the Logging library
43
43
 
44
44
  Ezlog sets up [Logging](https://github.com/TwP/logging)'s root logger to have an appender that writes to STDOUT.
45
45
  Any loggers created by the application will inherit this appender and will thus write their logs to STDOUT.
@@ -70,11 +70,10 @@ logger.error ex
70
70
  #=> {"logger":"App","timestamp":"2019-05-11T16:08:38+02:00","level":"ERROR","hostname":"MacbookPro.local","pid":71674,"message":"Error message","error":{"class":"StandardError","message":"Error message","backtrace":[...]}}
71
71
  ```
72
72
 
73
- #### Configures Rails logging
73
+ ### Configures Rails logging
74
74
 
75
75
  Ezlog configures the `Rails.logger` to be an instance of a [Logging](https://github.com/TwP/logging) logger by the name
76
- of `Application`, behaving as described above. The logger uses the log level set in `application.rb` if present, or
77
- INFO as a default log level.
76
+ of `Application`, behaving as described above.
78
77
 
79
78
  In addition to this, Ezlog also does the following:
80
79
  * It adds the environment (`Rails.env`) to the logger's initial context, so it will automatically be appended to all log messages
@@ -108,15 +107,25 @@ With Ezlog:
108
107
  {"logger":"AccessLog","timestamp":"2019-06-08T08:49:31+02:00","level":"INFO","hostname":"MacbookPro.local","pid":75463,"environment":"development","request_id":"9a43631b-284c-4677-9d08-9c1cc5c7d3a7","duration_sec":0.031,"message":"GET /welcome?subsession_id=34ea8596f9764f475f81158667bc2654 - 200 (OK)","remote_ip":"127.0.0.1","method":"GET","path":"/welcome?subsession_id=34ea8596f9764f475f81158667bc2654","params":{"subsession_id":"34ea8596f9764f475f81158667bc2654","controller":"pages","action":"welcome"},"response_status_code":200}
109
108
  ```
110
109
 
111
- #### Configures Sidekiq logging
110
+ #### The log level
111
+
112
+ The logger's log level is determined as follows (in order of precedence):
113
+ * the log level set in the application's configuration,
114
+ * the LOG_LEVEL environment variable, or
115
+ * `INFO` as the default log level if none of the above are set.
116
+
117
+ The following log levels are available: `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`.
118
+
119
+ ### Configures Sidekiq logging
112
120
 
113
121
  Ezlog configures the `Sidekiq.logger` to be an instance of a [Logging](https://github.com/TwP/logging) logger by the name
114
- of `Sidekiq`, behaving as described above. It also comes with its own job logger for [Sidekiq](https://github.com/mperham/sidekiq)
122
+ of `Sidekiq`, behaving as described above. The logger uses the same log level as the [Rails](https://rubyonrails.org/)
123
+ logger (see above). Ezlog also comes with its own job logger for [Sidekiq](https://github.com/mperham/sidekiq)
115
124
  which does several things that come in very handy when working with background jobs.
116
125
 
117
126
  * It emits two log messages per job run; one when the job is started and another one when the job is finished (successfully or unsuccessfuly).
118
127
  * It measures the time it took to execute the job and appends the benchmark information to the final log message.
119
- * It adds all basic information about the job (worker, queue, JID, created_at, enqueued_at) to the log context so
128
+ * It adds all basic information about the job (worker, queue, JID, created_at, enqueued_at, run_count) to the log context so
120
129
  all log messages emitted during the execution of the job will contain this information.
121
130
  * It also adds all of the job's parameters (by name) to the log context, which means that all log messages emitted
122
131
  during the execution of the job will contain this information as well.
@@ -132,18 +141,18 @@ end
132
141
 
133
142
  TestWorker.perform_async 42
134
143
 
135
- #=> {"logger":"Sidekiq","timestamp":"2019-05-12T10:38:10+02:00","level":"INFO","hostname":"MacbookPro.local","pid":75538,"jid":"abcdef1234567890","queue":"default","worker":"TestWorker","created_at":"2019-05-12 10:38:10 +0200","enqueued_at":"2019-05-12 10:38:10 +0200","customer_id":42,"message":"TestWorker started"}
136
- #=> {"logger":"Sidekiq","timestamp":"2019-05-12T10:38:10+02:00","level":"WARN","hostname":"MacbookPro.local","pid":75538,"jid":"abcdef1234567890","queue":"default","worker":"TestWorker","created_at":"2019-05-12 10:38:10 +0200","enqueued_at":"2019-05-12 10:38:10 +0200","customer_id":42,"message":"Customer not found"}
137
- #=> {"logger":"Sidekiq","timestamp":"2019-05-12T10:38:12+02:00","level":"INFO","hostname":"MacbookPro.local","pid":75538,"jid":"abcdef1234567890","queue":"default","worker":"TestWorker","created_at":"2019-05-12 10:38:10 +0200","enqueued_at":"2019-05-12 10:38:10 +0200","customer_id":42,"duration_sec":2.667,"message":"TestWorker finished"}
144
+ #=> {"logger":"Sidekiq","timestamp":"2019-05-12T10:38:10+02:00","level":"INFO","hostname":"MacbookPro.local","pid":75538,"jid":"abcdef1234567890","queue":"default","worker":"TestWorker","created_at":"2019-05-12 10:38:10 +0200","enqueued_at":"2019-05-12 10:38:10 +0200","run_count":1,"customer_id":42,"message":"TestWorker started"}
145
+ #=> {"logger":"Sidekiq","timestamp":"2019-05-12T10:38:10+02:00","level":"WARN","hostname":"MacbookPro.local","pid":75538,"jid":"abcdef1234567890","queue":"default","worker":"TestWorker","created_at":"2019-05-12 10:38:10 +0200","enqueued_at":"2019-05-12 10:38:10 +0200","run_count":1,"customer_id":42,"message":"Customer not found"}
146
+ #=> {"logger":"Sidekiq","timestamp":"2019-05-12T10:38:12+02:00","level":"INFO","hostname":"MacbookPro.local","pid":75538,"jid":"abcdef1234567890","queue":"default","worker":"TestWorker","created_at":"2019-05-12 10:38:10 +0200","enqueued_at":"2019-05-12 10:38:10 +0200","run_count":1,"customer_id":42,"duration_sec":2.667,"message":"TestWorker finished"}
138
147
  ```
139
148
 
140
- #### Configures Rack::Timeout logging
149
+ ### Configures Rack::Timeout logging
141
150
 
142
151
  [Rack::Timeout](https://github.com/heroku/rack-timeout) is a very useful tool for people running services on Heroku
143
152
  but it is way too verbose by default and all of its important messages (i.e. Timeout errors) are logged by the application
144
153
  as well. For this reason, Ezlog turns off [Rack::Timeout](https://github.com/heroku/rack-timeout) logging completely.
145
154
 
146
- #### Provides testing support for RSpec
155
+ ### Provides testing support for RSpec
147
156
 
148
157
  Ezlog comes with built-in support for testing your logging activity using [RSpec](https://rspec.info/).
149
158
  To enable spec support for Ezlog, put this line in your `spec_helper.rb` or `rails_helper.rb`:
data/lib/ezlog/railtie.rb CHANGED
@@ -5,8 +5,8 @@ module Ezlog
5
5
  ::Logging.logger.root.level = app.config.log_level
6
6
  end
7
7
 
8
- initializer 'ezlog.configure_sidekiq_logging' do
9
- initialize_sidekiq_logging if defined? ::Sidekiq
8
+ initializer 'ezlog.configure_sidekiq_logging' do |app|
9
+ initialize_sidekiq_logging(app) if defined? ::Sidekiq
10
10
  end
11
11
 
12
12
  initializer 'ezlog.configure_rack_timeout_logging' do
@@ -27,14 +27,14 @@ module Ezlog
27
27
 
28
28
  config.before_configuration do |app|
29
29
  app.config.logger = Ezlog.logger('Application')
30
- app.config.log_level = :info
30
+ app.config.log_level = ENV['LOG_LEVEL'] || :info
31
31
  end
32
32
 
33
33
  private
34
34
 
35
- def initialize_sidekiq_logging
35
+ def initialize_sidekiq_logging(app)
36
36
  ::Sidekiq.logger = Ezlog.logger('Sidekiq')
37
- ::Sidekiq.logger.level = :info
37
+ ::Sidekiq.logger.level = app.config.log_level
38
38
  ::Sidekiq.configure_server do |config|
39
39
  config.options[:job_logger] = Ezlog::Sidekiq::JobLogger
40
40
  config.error_handlers << Ezlog::Sidekiq::ErrorLogger.new
data/lib/ezlog/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ezlog
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ezlog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zoltan Ormandi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-18 00:00:00.000000000 Z
11
+ date: 2019-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -150,8 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  - !ruby/object:Gem::Version
151
151
  version: '0'
152
152
  requirements: []
153
- rubyforge_project:
154
- rubygems_version: 2.6.13
153
+ rubygems_version: 3.0.1
155
154
  signing_key:
156
155
  specification_version: 4
157
156
  summary: A zero-configuration logging solution for projects using Sidekiq, Rails,