ezlog 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +45 -3
- data/lib/ezlog/railtie.rb +1 -1
- data/lib/ezlog/sidekiq.rb +1 -0
- data/lib/ezlog/sidekiq/logger_extension.rb +11 -0
- data/lib/ezlog/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbc2b416fa5e9ad9fc27808ed7466061d9598d7d72cfa954111fd649c0140bac
|
4
|
+
data.tar.gz: eeeeb620f0e1e621e6e87004fc4d1ea764eb1192e22ce20a71ba460ea705fc13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b4c04947195d99f7570586ebd28e5f11206950076f9f2f0a55cdbc392afa1855db5c8fdec9e6f7cedbe8b5d57d50348b21cf965dbc0efc9323a7db1762fd81d
|
7
|
+
data.tar.gz: 67567839defa31877a6d5df9600835d89bd45ae485d50e633f0ca7e3fa4f3bc27a30700a64fdf3c816c6f27a70083fe97e36520f999e11a698e4600f5d9b23f9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
### 0.5.2 (2019-09-27)
|
2
|
+
|
3
|
+
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.5.1...v0.5.2)
|
4
|
+
|
5
|
+
* Bug fixes
|
6
|
+
* Sidekiq logger now supports the Sidekiq 6 logger interface which includes the method `with_context`. This is
|
7
|
+
important because other gems (notably [sidekiq-unique-jobs](https://github.com/mhenrixon/sidekiq-unique-jobs))
|
8
|
+
depend on this method and might break if it's not present.
|
9
|
+
|
1
10
|
### 0.5.1 (2019-09-16)
|
2
11
|
|
3
12
|
[Full Changelog](https://github.com/emartech/ezlog/compare/v0.5.0...v0.5.1)
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ projects using any (or all) of the following libraries or frameworks:
|
|
11
11
|
* [Sequel](https://sequel.jeremyevans.net/)
|
12
12
|
* [Rack::Timeout](https://github.com/heroku/rack-timeout)
|
13
13
|
|
14
|
-
It uses Tim Pease's wonderful [Logging](https://github.com/TwP/logging) gem for an all-purpose structured logging solution.
|
14
|
+
It uses Tim Pease's wonderful [Logging](https://github.com/TwP/logging) gem under the hood for an all-purpose structured logging solution.
|
15
15
|
|
16
16
|
Ezlog's purpose is threefold:
|
17
17
|
1. Make sure that our applications are logging in a concise and sensible manner; emitting no unnecessary "noise" but
|
@@ -21,7 +21,7 @@ Ezlog's purpose is threefold:
|
|
21
21
|
|
22
22
|
## Installation
|
23
23
|
|
24
|
-
|
24
|
+
### Rails
|
25
25
|
|
26
26
|
Add this line to your application's Gemfile:
|
27
27
|
|
@@ -29,7 +29,17 @@ Add this line to your application's Gemfile:
|
|
29
29
|
gem 'ezlog'
|
30
30
|
```
|
31
31
|
|
32
|
-
|
32
|
+
Although Ezlog sets up sensible defaults for all logging configuration settings, it leaves you the option to override these
|
33
|
+
settings manually in the way you're used to; via [Rails](https://rubyonrails.org/)'s configuration mechanism. Unfortunately
|
34
|
+
the [Rails](https://rubyonrails.org/) new project generator automatically generates code for the production environment
|
35
|
+
configuration that overrides these settings.
|
36
|
+
|
37
|
+
For Ezlog to work properly, you also need to delete the logging configuration options in the
|
38
|
+
`config/environments/production.rb` generated file.
|
39
|
+
|
40
|
+
### Non-Rails applications
|
41
|
+
|
42
|
+
At the moment Ezlog only support [Rails](https://rubyonrails.org/) apps. Non-Rails support is planned.
|
33
43
|
|
34
44
|
## What it does
|
35
45
|
|
@@ -37,6 +47,7 @@ That's it. Everything else is automatically configured.
|
|
37
47
|
* Configures [Rails](https://rubyonrails.org/)'s logging
|
38
48
|
* Configures [Sidekiq](https://github.com/mperham/sidekiq) logging
|
39
49
|
* Configures [Rack::Timeout](https://github.com/heroku/rack-timeout) logging
|
50
|
+
* Provides support for adding context information to log messages
|
40
51
|
* Provides testing support for [RSpec](https://rspec.info/)
|
41
52
|
|
42
53
|
### Initializes the Logging library
|
@@ -152,6 +163,37 @@ TestWorker.perform_async 42
|
|
152
163
|
but it is way too verbose by default and all of its important messages (i.e. Timeout errors) are logged by the application
|
153
164
|
as well. For this reason, Ezlog turns off [Rack::Timeout](https://github.com/heroku/rack-timeout) logging completely.
|
154
165
|
|
166
|
+
### Provides support for adding context information to log messages
|
167
|
+
|
168
|
+
Ezlog provides two helper methods which can be used to add context information to log messages:
|
169
|
+
|
170
|
+
* `within_log_context(context)`: Starts a new log context initialized with `context` and executes the provided block
|
171
|
+
within that context. Once execution is finished, the log context is cleaned up and the previous context (if any) is
|
172
|
+
reinstated. In practice, this means that every time we log something (within the block), the log message will include
|
173
|
+
the information that's in the current context. This can be useful for storing request-specific information
|
174
|
+
(request ID, user ID, ...) in the log context early on (for example in a middleware) and not have to worry about
|
175
|
+
including it every time we want to log a message.
|
176
|
+
|
177
|
+
Example:
|
178
|
+
|
179
|
+
```ruby
|
180
|
+
within_log_context customer_id: 1234 do
|
181
|
+
Rails.logger.info 'test 1'
|
182
|
+
end
|
183
|
+
Rails.logger.info 'test 2'
|
184
|
+
|
185
|
+
#=> {...,"level":"INFO","customer_id":1234,"message":"test 1"}
|
186
|
+
#=> {...,"level":"INFO","message":"test 2"}
|
187
|
+
```
|
188
|
+
|
189
|
+
* `add_to_log_context(context)`: Adds the provided `context` to the current log context but provides no mechanism for
|
190
|
+
removing it later. Only use this method if you are sure that you're working within a specific log context and that it
|
191
|
+
will be cleaned up later (e.g. by only using this method in a block passed to the previously explained
|
192
|
+
`within_log_context` method).
|
193
|
+
|
194
|
+
You can access these methods either in the global scope by calling them via `Ezlog.within_log_context` and
|
195
|
+
`Ezlog.add_to_log_context` or locally by including the `Ezlog::LogContextHelper` module into your class/module.
|
196
|
+
|
155
197
|
### Provides testing support for RSpec
|
156
198
|
|
157
199
|
Ezlog comes with built-in support for testing your logging activity using [RSpec](https://rspec.info/).
|
data/lib/ezlog/railtie.rb
CHANGED
@@ -45,7 +45,7 @@ module Ezlog
|
|
45
45
|
private
|
46
46
|
|
47
47
|
def initialize_sidekiq_logging(app)
|
48
|
-
::Sidekiq.logger = Ezlog.logger('Sidekiq')
|
48
|
+
::Sidekiq.logger = Ezlog.logger('Sidekiq').extend Ezlog::Sidekiq::LoggerExtension
|
49
49
|
::Sidekiq.logger.level = app.config.log_level
|
50
50
|
::Sidekiq.configure_server do |config|
|
51
51
|
config.options[:job_logger] = Ezlog::Sidekiq::JobLogger
|
data/lib/ezlog/sidekiq.rb
CHANGED
data/lib/ezlog/version.rb
CHANGED
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.5.
|
4
|
+
version: 0.5.2
|
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-09-
|
11
|
+
date: 2019-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- lib/ezlog/sidekiq/error_logger.rb
|
160
160
|
- lib/ezlog/sidekiq/job_context.rb
|
161
161
|
- lib/ezlog/sidekiq/job_logger.rb
|
162
|
+
- lib/ezlog/sidekiq/logger_extension.rb
|
162
163
|
- lib/ezlog/version.rb
|
163
164
|
- lib/sequel/extensions/ezlog_logging.rb
|
164
165
|
homepage: https://github.com/emartech/ezlog
|
@@ -181,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
182
|
- !ruby/object:Gem::Version
|
182
183
|
version: '0'
|
183
184
|
requirements: []
|
184
|
-
rubygems_version: 3.0.
|
185
|
+
rubygems_version: 3.0.3
|
185
186
|
signing_key:
|
186
187
|
specification_version: 4
|
187
188
|
summary: A zero-configuration logging solution for projects using Sidekiq, Rails,
|