Skip to content

Replacing Phoenix Live View logging #28

@skyqrose

Description

@skyqrose

I recently set up Logster (v2.0.0-rc1) to replace Phoenix logs, and it's working well. However, Phoenix Live View is still sending multi-line logs.

Example (I haven't made many changes from the phoenix app, and this is just loading /):

[info] state=sent method=GET path=/ controller=MyAppWeb.PageController action=home params={} status=200 duration=1.744
[info] action=connect state=ok socket=Phoenix.LiveView.Socket duration=0.012 transport=websocket serializer=Phoenix.Socket.V2.JSONSerializer params={"_csrf_token":"REDACTED","vsn":"2.0.0"}
[debug] MOUNT Phoenix.LiveDashboard.PageLive
  Parameters: %{"page" => "home"}
  Session: %{"_csrf_token" => "REDACTED", "allow_destructive_actions" => false, "csp_nonces" => %{script: nil, style: nil, img: nil}, "pages" => [home: {Phoenix.LiveDashboard.HomePage, %{env_keys: nil, home_app: {"Dashboard", :phoenix_live_dashboard}}}, os_mon: {Phoenix.LiveDashboard.OSMonPage, %{}}, memory_allocators: {Phoenix.LiveDashboard.MemoryAllocatorsPage, %{}}, metrics: {Phoenix.LiveDashboard.MetricsPage, %{metrics: {MyAppWeb.Telemetry, :metrics}, metrics_history: nil}}, request_logger: {Phoenix.LiveDashboard.RequestLoggerPage, %{request_logger: {"request_logger", "request_logger"}, cookie_domain: nil}}, applications: {Phoenix.LiveDashboard.ApplicationsPage, %{}}, processes: {Phoenix.LiveDashboard.ProcessesPage, %{}}, ports: {Phoenix.LiveDashboard.PortsPage, %{}}, sockets: {Phoenix.LiveDashboard.SocketsPage, %{}}, ets: {Phoenix.LiveDashboard.EtsPage, %{}}, ecto_stats: {Phoenix.LiveDashboard.EctoStatsPage, %{repos: :auto_discover, ecto_options: [ecto_psql_extras_options: [], ecto_mysql_extras_options: [], ecto_sqlite3_extras_options: []]}}], "requirements" => [application: :os_mon]}
[debug] Replied in 20ms
[debug] HANDLE PARAMS in Phoenix.LiveDashboard.PageLive
  Parameters: %{"page" => "home"}
[debug] Replied in 76µs
[debug] HANDLE EVENT "select_refresh" in Phoenix.LiveDashboard.PageLive
  Parameters: %{"_target" => ["refresh"], "refresh" => "15"}
[debug] Replied in 73µs

I see that Logster.attach_phoenix_logger() works by listening to Phoenix telemetry, and Live View also sends telemetry.

Perhaps Logster.attach_phoenix_logger() should also listen to live view events, or there should be another Logster.attach_phoenix_live_view_logger() function.

config :phoenix_live_view, logger: false works to quiet the default Live View logging. For now I'll just do that because they're just debug messages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions