Skip to content

Add required conditions for Logger's metadata to be print #13777

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

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/logger/lib/logger/formatter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ defmodule Logger.Formatter do
to the current process. The user can configure the backend to choose
which metadata it wants to print and it will replace the `$metadata`
value.

> #### Disclaimer {: .warning}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> #### Disclaimer {: .warning}
> #### When is user metadata printed? {: .warning}

>
> User's metadata must meet one of the following conditions to be printed:
> * Be a string (match with the `is_binary/1` guard)
> * Be a number (either match with the `is_integer/1` or `is_float/1` guard)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> * Be a string (match with the `is_binary/1` guard)
> * Be a number (either match with the `is_integer/1` or `is_float/1` guard)
> * Be a string (`is_binary/1`)
> * Be a number (either `is_integer/1` or `is_float/1`)

> * Be a pid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> * Be a pid
> * Be a PID

> * Be an atom
> * Be a reference
> * Be a port
> * Implement the `String.Chars` protocol
> otherwise the given metadata will be discarded.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> otherwise the given metadata will be discarded.
>
> If none of the conditions above are true, the given metadata gets discarded.

"""

@type date :: {1970..10000, 1..12, 1..31}
Expand Down