phoenixframework / phoenix_live_reload

Provides live-reload functionality for Phoenix
MIT License
315 stars 90 forks source link

Using `web_console_logger` in a staging environment #161

Closed DaTrader closed 4 months ago

DaTrader commented 4 months ago

Thanks to @chrismccord 's article (https://fly.io/phoenix-files/phoenix-dev-blog-server-logs-in-the-browser-console/), we have managed to use this new feature successfully in our staging environment (as an alternative to digging deep into a Kubernetes console).

Unless there's a good reason for why this practice should not be recommended and should instead be reserved solely for the dev environment, I suggest the following changes:

  1. Mention this possibility in the docs. Currently, the following changes are required in a staging.exs config file to support the feature (assuming it's otherwise a copy of the prod.exs):

Add:

config :my_app_web, MyApp.Endpoint,
  code_reloader: true,
  live_reload: [
    web_console_logger: true,
    patterns: [~r"^fake_file$"]
  ]

Remove:

config :logger, level: :info
  1. Decouple the web_console_logger config from the patterns config so we don't need to specify otherwise non-existent file(s) just for the sake of the feature to work. Also, decouple it from the code_reloader config as it can be treated a completely separate feature,
josevalim commented 4 months ago

I have decoupled it from patterns in main but we plan to keep it as part of the live reloader for now. I also don't think we need a comment or a mention in the docs, users are welcome to try if they are aware of the implications. Thanks!