Skip to content

Commit

Permalink
Merge pull request #2300 from alexeevit/feature/change-log-tcp-to-http
Browse files Browse the repository at this point in the history
WIP Log binding on http:// for TCP bindings to make it clickable
  • Loading branch information
nateberkopec committed Jul 6, 2020
2 parents a72c68b + eff4691 commit e2b4193
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -29,6 +29,7 @@
* Daemonization has been removed without replacement. (#2170)
* Changed #connected_port to #connected_ports (#2076)
* Configuration: `environment` is read from `RAILS_ENV`, if `RACK_ENV` can't be found (#2022)
* Log binding on http:// for TCP bindings to make it clickable

* Bugfixes
* Close client http connections made to an ssl server with TLSv1.3 (#2116)
Expand Down
2 changes: 1 addition & 1 deletion lib/puma/binder.rb
Expand Up @@ -114,7 +114,7 @@ def parse(binds, logger, log_msg = 'Listening')
i.local_address.ip_unpack.join(':')
end

logger.log "* #{log_msg} on tcp://#{addr}"
logger.log "* #{log_msg} on http://#{addr}"
end
end

Expand Down
12 changes: 8 additions & 4 deletions test/test_binder.rb
Expand Up @@ -72,7 +72,7 @@ def test_home_alters_listeners_for_ssl_addresses
def test_correct_zero_port
@binder.parse ["tcp://localhost:0"], @events

m = %r!tcp://127.0.0.1:(\d+)!.match(@events.stdout.string)
m = %r!http://127.0.0.1:(\d+)!.match(@events.stdout.string)
port = m[1].to_i

refute_equal 0, port
Expand All @@ -92,9 +92,9 @@ def test_correct_zero_port_ssl
def test_logs_all_localhost_bindings
@binder.parse ["tcp://localhost:0"], @events

assert_match %r!tcp://127.0.0.1:(\d+)!, @events.stdout.string
assert_match %r!http://127.0.0.1:(\d+)!, @events.stdout.string
if Socket.ip_address_list.any? {|i| i.ipv6_loopback? }
assert_match %r!tcp://\[::1\]:(\d+)!, @events.stdout.string
assert_match %r!http://\[::1\]:(\d+)!, @events.stdout.string
end
end

Expand Down Expand Up @@ -351,13 +351,17 @@ def assert_parsing_logs_uri(order = [:unix, :tcp])
unix: "unix://test/#{name}_server.sock"
}

expected_logs = prepared_paths.dup.tap do |logs|
logs[:tcp] = logs[:tcp].gsub('tcp://', 'http://')
end

tested_paths = [prepared_paths[order[0]], prepared_paths[order[1]]]

@binder.parse tested_paths, @events
stdout = @events.stdout.string

order.each do |prot|
assert_match prepared_paths[prot], stdout
assert_match expected_logs[prot], stdout
end
ensure
@binder.close_listeners if order.include?(:unix) && UNIX_SKT_EXIST
Expand Down

0 comments on commit e2b4193

Please sign in to comment.