Skip to content

Commit

Permalink
Only log when running in release. Closes #5372
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Mar 22, 2023
1 parent b63dcf0 commit 78f30a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/phoenix/endpoint/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 141,11 @@ defmodule Phoenix.Endpoint.Supervisor do
adapter.child_specs(mod, config)

config[:http] || config[:https] ->
Logger.info(
"Configuration :server was not enabled for #{inspect(mod)}, http/https services won't start"
)
if System.get_env("RELEASE_NAME") do
Logger.info(
"Configuration :server was not enabled for #{inspect(mod)}, http/https services won't start"
)
end

[]

Expand Down
4 changes: 3 additions & 1 deletion test/phoenix/endpoint/supervisor_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 91,10 @@ defmodule Phoenix.Endpoint.SupervisorTest do
end

import ExUnit.CaptureLog
test "logs info if :http or :https configuration is set but not :server" do
test "logs info if :http or :https configuration is set but not :server when running in release" do
Logger.configure(level: :info)
# simulate running inside release
System.put_env("RELEASE_NAME", "phoenix-test")
Application.put_env(:phoenix, ServerEndpoint, [server: false, http: [], https: []])
assert capture_log(fn ->
{:ok, {_, _children}} = Supervisor.init({:phoenix, ServerEndpoint, []})
Expand Down

1 comment on commit 78f30a6

@clarkware
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Chris! 👍

Please sign in to comment.