From 838a9ad0ca5b0c3f28ec24aaa3839d4d96f7ca3d Mon Sep 17 00:00:00 2001 From: ponychicken Date: Sun, 25 Aug 2024 08:49:09 +0200 Subject: [PATCH 1/3] Enable web console logger for new projects --- installer/templates/phx_assets/app.js | 7 +++++++ installer/templates/phx_single/config/dev.exs | 1 + 2 files changed, 8 insertions(+) diff --git a/installer/templates/phx_assets/app.js b/installer/templates/phx_assets/app.js index 0d9f8cdd19..491b0d87c7 100644 --- a/installer/templates/phx_assets/app.js +++ b/installer/templates/phx_assets/app.js @@ -33,6 +33,13 @@ import "phoenix_html" <%= @live_comment %>window.addEventListener("phx:page-loading-start", _info => topbar.show(300)) <%= @live_comment %>window.addEventListener("phx:page-loading-stop", _info => topbar.hide()) +// Enable server log streaming to client. +<%= @live_comment %>window.addEventListener("phx:live_reload:attached", ({detail: reloader}) => { +<%= @live_comment %> reloader.enableServerLogs() +<%= @live_comment %> window.liveReloader = reloader +<%= @live_comment %>}) + + // connect if there are any LiveViews on the page <%= @live_comment %>liveSocket.connect() diff --git a/installer/templates/phx_single/config/dev.exs b/installer/templates/phx_single/config/dev.exs index 73deeaf344..ebc6122b87 100644 --- a/installer/templates/phx_single/config/dev.exs +++ b/installer/templates/phx_single/config/dev.exs @@ -45,6 +45,7 @@ config :<%= @app_name %>, <%= @endpoint_module %>, # Watch static and templates for browser reloading. config :<%= @app_name %>, <%= @endpoint_module %>, live_reload: [ + web_console_logger: true, patterns: [ ~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",<%= if @gettext do %> ~r"priv/gettext/.*(po)$",<% end %> From d5e427a80fd360d274b4ae4f8af4d82b31bb4925 Mon Sep 17 00:00:00 2001 From: ponychicken Date: Sat, 28 Sep 2024 13:01:24 +0200 Subject: [PATCH 2/3] Enable web_console_logger for umbrella as well --- .../templates/phx_umbrella/apps/app_name_web/config/dev.exs | 1 + 1 file changed, 1 insertion(+) diff --git a/installer/templates/phx_umbrella/apps/app_name_web/config/dev.exs b/installer/templates/phx_umbrella/apps/app_name_web/config/dev.exs index bcc1304b48..d73204be7e 100644 --- a/installer/templates/phx_umbrella/apps/app_name_web/config/dev.exs +++ b/installer/templates/phx_umbrella/apps/app_name_web/config/dev.exs @@ -45,6 +45,7 @@ config :<%= @web_app_name %>, <%= @endpoint_module %>, # Watch static and templates for browser reloading. config :<%= @web_app_name %>, <%= @endpoint_module %>, live_reload: [ + web_console_logger: true, patterns: [ ~r"priv/static/(?!uploads/).*(js|css|png|jpeg|jpg|gif|svg)$",<%= if @gettext do %> ~r"priv/gettext/.*(po)$",<% end %> From f013c2204735453a5b0140eaa8687523efed2a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 22 Oct 2024 11:02:36 +0200 Subject: [PATCH 3/3] Update installer/templates/phx_assets/app.js --- installer/templates/phx_assets/app.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/installer/templates/phx_assets/app.js b/installer/templates/phx_assets/app.js index 491b0d87c7..9ab0855a55 100644 --- a/installer/templates/phx_assets/app.js +++ b/installer/templates/phx_assets/app.js @@ -38,8 +38,6 @@ import "phoenix_html" <%= @live_comment %> reloader.enableServerLogs() <%= @live_comment %> window.liveReloader = reloader <%= @live_comment %>}) - - // connect if there are any LiveViews on the page <%= @live_comment %>liveSocket.connect()