Allow logging of specified environment variables.#48
Open
unixmonkey wants to merge 3 commits intonoahd1:masterfrom
Open
Allow logging of specified environment variables.#48unixmonkey wants to merge 3 commits intonoahd1:masterfrom
unixmonkey wants to merge 3 commits intonoahd1:masterfrom
Conversation
houndci-bot
reviewed
Jan 29, 2018
lib/oink/middleware.rb
Outdated
| return if @env_vars.empty? | ||
| env_message = @env_vars.map { |key| | ||
| value = env[key] | ||
| "#{key.inspect}: #{value.inspect if value && value.respond_to?(:inspect)}" |
lib/oink/middleware.rb
Outdated
|
|
||
| def log_environment(env) | ||
| return if @env_vars.empty? | ||
| env_message = @env_vars.map { |key| |
There was a problem hiding this comment.
Avoid using {...} for multi-line blocks.
houndci-bot
reviewed
Jan 30, 2018
|
|
||
| it "includes specified environment variables" do | ||
| get "/no_pigs", {}, {"action_dispatch.request_id" => "4cc822f8-0d85-4d80-bcae-d94a4567e06c"} | ||
| log_output.string.should include('Environment: {"action_dispatch.request_id": "4cc822f8-0d85-4d80-bcae-d94a4567e06c"}') |
| end | ||
|
|
||
| it "includes specified environment variables" do | ||
| get "/no_pigs", {}, {"action_dispatch.request_id" => "4cc822f8-0d85-4d80-bcae-d94a4567e06c"} |
There was a problem hiding this comment.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
Space inside { missing.
Redundant curly braces around a hash parameter.
Line is too long. [98/80]
Space inside } missing.
| Oink::Middleware.new(SampleApplication.new, :logger => logger, :env_vars => ['action_dispatch.request_id']) | ||
| end | ||
|
|
||
| it "includes specified environment variables" do |
There was a problem hiding this comment.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
|
|
||
| context "include specified environment variables in the oink log" do | ||
| let(:app) do | ||
| Oink::Middleware.new(SampleApplication.new, :logger => logger, :env_vars => ['action_dispatch.request_id']) |
There was a problem hiding this comment.
Use the new Ruby 1.9 hash syntax.
Line is too long. [113/80]
| end | ||
| end | ||
|
|
||
| context "include specified environment variables in the oink log" do |
There was a problem hiding this comment.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR allows users to log extra environment information to the oink.log, if environment keys are specified.
If an optional
env_varsarray is passed to the middleware, the logs will have an additionalEnvironment:line with specified environment keys and values:This is especially useful for logging the request ID, since logs may be distributed among multiple app servers, and timestamps don't always line up exactly.