Skip to content

Commit

Permalink
Enable web console logger for new projects (#5910)
Browse files Browse the repository at this point in the history
* Enable web console logger for new projects

* Enable web_console_logger for umbrella as well

* Update installer/templates/phx_assets/app.js

---------

Co-authored-by: José Valim <[email protected]>
  • Loading branch information
ponychicken and josevalim authored Nov 26, 2024
1 parent b4b0645 commit f586988
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions installer/templates/phx_assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ 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()

Expand Down
1 change: 1 addition & 0 deletions installer/templates/phx_single/config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down

0 comments on commit f586988

Please sign in to comment.