-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Use Elixir Logger and improve formatting of requests #235
Comments
What we have today to start the discussion:
|
I've been working on a audit logging project at work. I think what ever data is available to the logs should be extendable by the user. Possibly a map that can have custom key-values merged into a custom struct where the output can be customized via a protocol? I haven't dug into the |
There is no need for Phoenix to provide a new backend because Logger supports metadata (i.e. you can add whatever you want to logs). |
@scrogson Elixir Logger allows any backend you'd like and any format you'd like. We'd be defining a custom format for phoenix and which metadata to send. |
Ah, sorry. I think I meant |
@scrogson default backend flushes to stdout. Custom backends can send to file or logstash or syslog etc. Format is what it logs to those sources. |
Yep. Got it. Thanks for the clarity. |
Ok. I am going to setup the goals here:
One of the first things we need to do is to add a # config.exs
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:user_id, :request_id]
# prod.exs
config :logger, :level, :info We added If we want to share information with plug, it means we need to segregate which information is available to Plug and what is available for Phoenix. It is also important to figure out what is info and what is debug data, here is my proposal:
The first and last messages would be handled by a logger plug provided by Plug. The request_id will be added by this plug too. |
@josevalim Would we log each chunk as its sent as well? Or just when the chunked connection is closed? |
Yes.
I would log just start. Each chunk would definitely be too much and when the chunked connection is closed is hard to specify. |
@josevalim so plug would create the request id and send it with the conn. And it would also probably setup a before_send closure with the current_timestamp to log before it was sent. Got it. |
@jeregrine the request_id will be set by calling |
Makes sense to me! |
So I am going to do two pr's one for plug, and one for this. I will reference the two to this. |
No description provided.
The text was updated successfully, but these errors were encountered: