Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Round benchmark time in compact mode #71

Merged
merged 1 commit into from
May 10, 2019
Merged
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 lib/httplog/http_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def log_data(data)
def log_compact(method, uri, status, seconds)
return unless config.compact_log
status = Rack::Utils.status_code(status) unless status == /\d{3}/
log("#{method.to_s.upcase} #{uri} completed with status code #{status} in #{seconds} seconds")
log("#{method.to_s.upcase} #{uri} completed with status code #{status} in #{seconds.to_f.round(6)} seconds")
end

def log_json(data = {})
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/http_log_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def configure

context 'with compact config' do
let(:compact_log) { true }
it { is_expected.to match(%r{\[httplog\] GET http://#{host}:#{port}#{path}(\?.*)? completed with status code \d{3} in (\d|\.)+}) }
it { is_expected.to match(%r{\[httplog\] GET http://#{host}:#{port}#{path}(\?.*)? completed with status code \d{3} in \d+\.\d{1,6} }) }
it { is_expected.to_not include("Connecting: #{host}:#{port}") }
it { is_expected.to_not include('Response:') }
it { is_expected.to_not include('Data:') }
Expand Down