mirror of
https://github.com/samsonjs/grape_logging.git
synced 2026-03-25 08:55:47 +00:00
Add ActionDispatch request ID to logger arguments hash
This commit is contained in:
parent
a4f6088a17
commit
71c1adf3eb
4 changed files with 10 additions and 5 deletions
|
|
@ -2,8 +2,10 @@
|
|||
|
||||
## [2.0.1] - Unreleased
|
||||
|
||||
### Changed or Fixed or Added
|
||||
* Your contribution here.
|
||||
## Added
|
||||
- [#91](https://github.com/aserafin/grape_logging/pull/91) Add ActionDispatch request ID to logger arguments hash as `:request_id` - [@samsonjs](https://github.com/samsonjs).
|
||||
|
||||
- Your contribution here.
|
||||
|
||||
[2.0.1]: https://github.com/aserafin/grape_logging/compare/v2.0.0...master
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ Add the next release to [CHANGELOG.md](https://github.com/aserafin/grape_logging
|
|||
## [Next Release]
|
||||
|
||||
### Changed or Fixed or Added
|
||||
* Your contribution here.
|
||||
- Your contribution here.
|
||||
```
|
||||
|
||||
Commit your changes.
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@ module GrapeLogging
|
|||
method: request.request_method,
|
||||
path: request.path,
|
||||
params: request.params,
|
||||
host: request.host
|
||||
host: request.host,
|
||||
request_id: env['action_dispatch.request_id'],
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ require 'spec_helper'
|
|||
require 'rack'
|
||||
|
||||
describe GrapeLogging::Middleware::RequestLogger do
|
||||
let(:subject) { request.send(request_method, path) }
|
||||
let(:env) { { 'action_dispatch.request_id' => 'request-abc123' } }
|
||||
let(:subject) { request.send(request_method, path, env) }
|
||||
let(:app) { proc{ [status, {} , ['response body']] } }
|
||||
let(:stack) { described_class.new app, options }
|
||||
let(:request) { Rack::MockRequest.new(stack) }
|
||||
|
|
@ -18,6 +19,7 @@ describe GrapeLogging::Middleware::RequestLogger do
|
|||
expect(arguments[:method]).to eq 'GET'
|
||||
expect(arguments[:params]).to be_empty
|
||||
expect(arguments[:host]).to eq 'example.org'
|
||||
expect(arguments[:request_id]).to eq 'request-abc123'
|
||||
expect(arguments).to have_key :time
|
||||
expect(arguments[:time]).to have_key :total
|
||||
expect(arguments[:time]).to have_key :db
|
||||
|
|
|
|||
Loading…
Reference in a new issue