mirror of
https://github.com/samsonjs/grape_logging.git
synced 2026-04-27 14:57:40 +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
|
## [2.0.1] - Unreleased
|
||||||
|
|
||||||
### Changed or Fixed or Added
|
## Added
|
||||||
* Your contribution here.
|
- [#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
|
[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]
|
## [Next Release]
|
||||||
|
|
||||||
### Changed or Fixed or Added
|
### Changed or Fixed or Added
|
||||||
* Your contribution here.
|
- Your contribution here.
|
||||||
```
|
```
|
||||||
|
|
||||||
Commit your changes.
|
Commit your changes.
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,8 @@ module GrapeLogging
|
||||||
method: request.request_method,
|
method: request.request_method,
|
||||||
path: request.path,
|
path: request.path,
|
||||||
params: request.params,
|
params: request.params,
|
||||||
host: request.host
|
host: request.host,
|
||||||
|
request_id: env['action_dispatch.request_id'],
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ require 'spec_helper'
|
||||||
require 'rack'
|
require 'rack'
|
||||||
|
|
||||||
describe GrapeLogging::Middleware::RequestLogger do
|
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(:app) { proc{ [status, {} , ['response body']] } }
|
||||||
let(:stack) { described_class.new app, options }
|
let(:stack) { described_class.new app, options }
|
||||||
let(:request) { Rack::MockRequest.new(stack) }
|
let(:request) { Rack::MockRequest.new(stack) }
|
||||||
|
|
@ -18,6 +19,7 @@ describe GrapeLogging::Middleware::RequestLogger do
|
||||||
expect(arguments[:method]).to eq 'GET'
|
expect(arguments[:method]).to eq 'GET'
|
||||||
expect(arguments[:params]).to be_empty
|
expect(arguments[:params]).to be_empty
|
||||||
expect(arguments[:host]).to eq 'example.org'
|
expect(arguments[:host]).to eq 'example.org'
|
||||||
|
expect(arguments[:request_id]).to eq 'request-abc123'
|
||||||
expect(arguments).to have_key :time
|
expect(arguments).to have_key :time
|
||||||
expect(arguments[:time]).to have_key :total
|
expect(arguments[:time]).to have_key :total
|
||||||
expect(arguments[:time]).to have_key :db
|
expect(arguments[:time]).to have_key :db
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue