Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Metrics/AbcSize:

Metrics/BlockLength:
Exclude:
- spec/**/*_spec.rb
- spec/**/*.rb

Style/BlockDelimiters:
Enabled: false
Expand Down
2 changes: 2 additions & 0 deletions lib/lograge/formatters/key_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def parse_value(key, value)
# a single quote
return "'#{value}'" if key == :error
return Kernel.format('%.2f', value) if value.is_a? Float
# Surround values with a space in them in quotes
return value.inspect if value.is_a?(String) && value.include?(' ')

value
end
Expand Down
12 changes: 11 additions & 1 deletion spec/support/examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
method: 'GET',
path: '/',
controller: 'welcome',
action: 'index'
action: 'index',
custom_sentence: 'Hello world',
custom_sentence_with_quotes: "I'm a \"test value\""
}
end

Expand All @@ -29,4 +31,12 @@
it "includes the 'custom' key/value" do
expect(subject).to include('custom=data')
end

it "includes the 'custom_sentence' key/value" do
expect(subject).to include('custom_sentence="Hello world"')
end

it "includes the 'custom_sentence_with_quotes' key/value" do
expect(subject).to include('custom_sentence_with_quotes="I\'m a \"test value\"')
end
end