phoenixframework / phoenix_live_reload

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

Handle more log types (ie notice) #150

Closed joshamb closed 6 months ago

joshamb commented 6 months ago

Whilst giving the latest web console logger a spin, I was receiving console errors from the log js function for our 'notice' logs.

I simplified the levelColor variable, but alternatively it could be more like below to keep with the current style, but i'm sure their is probably a better way still

{
    debug: "cyan", 
    info: "inherit", 
    notice: "inherit", 
    warning: "inherit", 
    error: "inherit", 
    critical: "inherit", 
    alert: "inherit", 
    emergency: "inherit"
}[level]
SteffenDE commented 6 months ago

Not related to your PR, but I have to say that I find the cyan quite hard to read. Maybe we should use another color?

Related to your PR we could probably do a mapping from the Elixir log levels to the console functions:

We could also just handle all server logs the same and always use the default console.log function. But Chris has probably had some reasons to do it the way it is currently done?

I'd wait and see what other say first.

josevalim commented 6 months ago

Oh, mapping from colors to console functions would be neat. :+1:

chrismccord commented 6 months ago

We could also just handle all server logs the same and always use the default console.log function. But Chris has probably had some reasons to do it the way it is currently done?

I'm fine either way, but the color distinction is nice for the same reason a Logger.debug is visually distinct from regular logs in the terminal, so a simple mapping gets my vote if things remain readable for folks.

chrismccord commented 6 months ago

❤️❤️❤️🐥🔥