-
Notifications
You must be signed in to change notification settings - Fork 455
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 logs for code evaluation #2880
Conversation
lib/livebook/session.ex
Outdated
""" | ||
Evaluating code | ||
Session mode: #{state.data.mode} | ||
Code: #{inspect(cell.source, printable_limit: :infinity)}\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively we could interpolate it directly, but printing the new lines would make it much more verbose.
Uffizzi Preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nitpick!
into: %{} | ||
end | ||
|
||
[users: inspect(list)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing the inspection here is problematic because if we have JSON logging in the future, then it will be sent as a string instead of a lists of objects in JSON. Maybe we can cross this bridge later but we may need a custom data structure here, so we can implement both JSON and String.Chars protocols.
Co-authored-by: José Valim <jose.valim@dashbit.co>
@josevalim I also added metadata for plug and lv :) |
This adds extra logs whenever code is evaluated, showing the code. The metadata includes people connected to the session (or in case of app previews, the person who deployed the app).
When running Livebook with new env vars
LIVEBOOK_LOG_LEVEL=info LIVEBOOK_LOG_METADATA=request_id,users
, the log looks like this:The user information includes id, name and email (if available), so it's best combined with an identity provider.