Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional minimum log level to send to client #154

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

joshamb
Copy link
Contributor

@joshamb joshamb commented Mar 12, 2024

This is a new feature! Our logging is fairly extensive and I'm only really interested on seeing when things are breaking (ie a LiveView screen I've butchered) and not all the noise in-between in my web console.

The variable name could probably be better, but i've added a web_console_logger_min_log_level option for dev.exs where it compares the log level of the log (or defaults to the current behaviour, showing all logs)

I've also added a test, its essentially sends logs for web console only when enabled test but slightly repurposed, it might need some improving. Im a total test rookie so apologies in advanced if this came across as lazy.

@chrismccord
Copy link
Member

Let’s filter on the client instead via the enableServerLogs method. This way you can control what you get in real time from your app js or on the browser console itself. Then there is no config required

@joshamb
Copy link
Contributor Author

joshamb commented Mar 12, 2024

I think I instinctively did it on the server to reduce unnecessary logs being sent down the channel, but I agree its probably best having it on the client to be able to change it in real-time.

The only think I dislike about this is that I now have a elixirLogLevels variable, which is effectively a copy and paste of the elixir/erlang log levels.

I could send down the log levels on the socket 'join', but it would still be a hardcoded list, as in elixir 1.16 levels() is returned in an incorrect order. It could be ordered by comparing all the levels with each other - but seems a bit excessive?

And looking back to pre 1.16, there is no such levels() function.

Heres how it would look (untested): joshamb@fc61192#diff-74e0d6ac64bd822b5fddb3c26cfbfa24e9b3ca6dc6b99ba041d933bf90bb2de6

@chrismccord
Copy link
Member

The hardcoded list is fine. We can include the min log level on the enableServerLogs() and ditch the extra public interface, iereloader.enableServerLogs("error")

@joshamb
Copy link
Contributor Author

joshamb commented Mar 12, 2024

Sorry you did mention that, done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants