grych / drab

Remote controlled frontend framework for Phoenix.

Home Page:https://tg.pl/drab

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compact log message

jung-hunsoo opened this issue · comments

Whenever I looked through the server log, the drab log leaves too much messages. Each websocket joining leaves 19 lines, most of them are debug purpose.

How can the message be made more compact? Or do you consider replacing the log message level from info to debug?

You definitely shouldn't be running :info logging level in production I'd think. If the system gets enough connections (even without Drab) then the logger can get overwhelmed with messages and just like in any other language the logging could that start to slow the whole system down. I run with stripping at :debug and log printing enabled at :warn (which I can change at runtime if I need to see something else).

It would be nice for Drab to have a config option to disable it's info messages though. :-)

@OvermindDL1 - hmm I don't recall any Drab's info messages, can you describe one?

@jung-hunsoo you may try to supress Phonix channel debug, with :phoenix_channel_options config option. See https://hexdocs.pm/drab/Drab.Config.html#content, for example: [log_handle_in: false]

@OvermindDL1 - hmm I don't recall any Drab's info messages, can you describe one?

I think he's talking about the whole this kind of thing:

    Started Drab for __drab:same_path:/blah, handling events in Bloop.Web.BlahCommander
    You may debug Drab functions in IEx by copy/paste the following:
import Drab.{Modal, Element, Live, Core}
socket = Drab.get_socket(pid("0.13789.4"))

You know, I'd love to enable these in production for, say, the next 10 seconds or something via some call like setting an Application.put_env/3 or so. :-)

Oh I see, but this message comes only in IEx?

if IEx.started?() do

nobody runs the server on production in IEx :)

But right, it should be a possibility to turn it off. I will add it.

One of captured image is,
log_drab

@jung-hunsoo so you are running your server in IEx?

Production should definitely be run via distillery. Running it via iex means that there is no preloading of modules, no tool interfacing, no init system management, etc...

It's build and packaged by distillery v2.0, including ERTS. IEx is only used in my dev env for debug purpose.

I think it's better turn off the :info level logs in phoenix config. (haven't tried yet.)

Now the Websocket logs are suppressed by setting use Phoenix.Socket, log: :debug and use Drab.Socket, log: :debug.

Unfortunately Channel logs are not muted yet, though use Phoenix.Channel, log_join: :info, log_handle_in: false and phoenix_channel_options: [log_handle_in: false] are given.

Not logs are like this:

 1월 12 08:43:19 nohogu1 nohogu[833]: 08:43:19.828 [info] GET /tips/products/26/edit
 1월 12 08:43:19 nohogu1 nohogu[833]: 08:43:19.979 [info] Sent 200 in 151ms
 1월 12 08:43:22 nohogu1 nohogu[833]: 08:43:22.994 [info] JOIN "__drab:same_path:/tips/products/26/edit" to Drab.Channel
 1월 12 08:43:22 nohogu1 nohogu[833]:   Transport:  :websocket
 1월 12 08:43:22 nohogu1 nohogu[833]:   Serializer: Phoenix.Socket.V2.JSONSerializer
 1월 12 08:43:22 nohogu1 nohogu[833]:   Parameters: %{}
 1월 12 08:43:22 nohogu1 nohogu[833]: 08:43:22.995 [info] Replied __drab:same_path:/tips/products/26/edit :ok
 1월 12 08:43:23 nohogu1 nohogu[833]:     Started Drab for __drab:same_path:/tips/products/26/edit, handling events in NohoguWeb.Tips.ProductCommander
 1월 12 08:43:23 nohogu1 nohogu[833]:     You may debug Drab functions in IEx by copy/paste the following:
 1월 12 08:43:23 nohogu1 nohogu[833]: import Drab.{Modal, Element, Live, Core}
 1월 12 08:43:23 nohogu1 nohogu[833]: socket = Drab.get_socket(pid("0.2766.0"))
 1월 12 08:43:23 nohogu1 nohogu[833]:     Examples:
 1월 12 08:43:23 nohogu1 nohogu[833]: socket |> alert("Title", "Sure?", buttons: [ok: "Azaliż", cancel: "Poniechaj"])
 1월 12 08:43:23 nohogu1 nohogu[833]: socket |> set_style("body", backgroundColor: "red")
 1월 12 08:43:23 nohogu1 nohogu[833]: socket |> poke(text: "This assign has been drabbed!")
 1월 12 08:43:23 nohogu1 nohogu[833]: socket |> exec_js("alert('hello from IEx!')")

Thanks for the advice. Now I use :warn in prod.

This is definitely weird. Even the log level is :warn, example messages are logged like this.

I don't think this is a warning message.

drab_messages

Production should definitely be run via distillery. Running it via iex means that there is no preloading of modules, no tool interfacing, no init system management, etc...

Firstly, that's not helpful at all. Secondly, you're wrong with the assumption that would help at all. Distillery intentionally includes IEx so the console command could work.

@jung-hunsoo That's because it's not a log message. It's being printed using IO.puts