This commit is contained in:
@@ -20,8 +20,7 @@ config :elixir_ai, ElixirAiWeb.Endpoint,
|
|||||||
layout: false
|
layout: false
|
||||||
],
|
],
|
||||||
pubsub_server: ElixirAi.PubSub,
|
pubsub_server: ElixirAi.PubSub,
|
||||||
live_view: [signing_salt: "4UG1IVt+"],
|
live_view: [signing_salt: "4UG1IVt+"]
|
||||||
log: false
|
|
||||||
|
|
||||||
# Configure esbuild (the version is required)
|
# Configure esbuild (the version is required)
|
||||||
config :esbuild,
|
config :esbuild,
|
||||||
|
|||||||
@@ -4,14 +4,6 @@ defmodule ElixirAi.Application do
|
|||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def start(_type, _args) do
|
def start(_type, _args) do
|
||||||
# Attach custom logger that filters health checks
|
|
||||||
:telemetry.attach(
|
|
||||||
"phoenix-endpoint-logger",
|
|
||||||
[:phoenix, :endpoint, :stop],
|
|
||||||
&__MODULE__.log_request/4,
|
|
||||||
%{}
|
|
||||||
)
|
|
||||||
|
|
||||||
children = [
|
children = [
|
||||||
ElixirAiWeb.Telemetry,
|
ElixirAiWeb.Telemetry,
|
||||||
ElixirAi.Repo,
|
ElixirAi.Repo,
|
||||||
@@ -47,32 +39,4 @@ defmodule ElixirAi.Application do
|
|||||||
ElixirAiWeb.Endpoint.config_change(changed, removed)
|
ElixirAiWeb.Endpoint.config_change(changed, removed)
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
||||||
# Custom request logger that filters health check endpoint
|
|
||||||
require Logger
|
|
||||||
|
|
||||||
def log_request(_event, measurements, %{conn: conn}, _config) do
|
|
||||||
# Skip logging for health check endpoint
|
|
||||||
if conn.request_path != "/health" do
|
|
||||||
duration = System.convert_time_unit(measurements.duration, :native, :microsecond)
|
|
||||||
|
|
||||||
Logger.info(
|
|
||||||
fn ->
|
|
||||||
[conn.method, " ", conn.request_path]
|
|
||||||
end,
|
|
||||||
request_id: conn.assigns[:request_id]
|
|
||||||
)
|
|
||||||
|
|
||||||
Logger.info(
|
|
||||||
fn ->
|
|
||||||
["Sent ", to_string(conn.status), " in ", format_duration(duration)]
|
|
||||||
end,
|
|
||||||
request_id: conn.assigns[:request_id]
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp format_duration(μs) when μs < 1000, do: "#{μs}µs"
|
|
||||||
defp format_duration(μs) when μs < 1_000_000, do: "#{div(μs, 1000)}ms"
|
|
||||||
defp format_duration(μs), do: "#{Float.round(μs / 1_000_000, 2)}s"
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ defmodule ElixirAiWeb.Router do
|
|||||||
plug :accepts, ["json"]
|
plug :accepts, ["json"]
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/", ElixirAiWeb do
|
scope "/", ElixirAiWeb, log: false do
|
||||||
pipe_through :api
|
pipe_through :api
|
||||||
|
|
||||||
get "/health", HealthController, :index
|
get "/health", HealthController, :index
|
||||||
|
|||||||
Reference in New Issue
Block a user