-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Emit notice logs in :console backend #11304
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
Changes from all commits
cc55a82
f434078
3a3a304
7df3574
3a59e1d
80ba8cf
6278877
f2aa3e4
dda2092
502c2af
58b3383
d1eb8cd
1cc427a
0bfbf84
fd3bb45
5ee8aad
f67af5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,8 @@ defmodule Logger.Backends.Console do | |
def handle_event({level, _gl, {Logger, msg, ts, md}}, state) do | ||
%{level: log_level, ref: ref, buffer_size: buffer_size, max_buffer: max_buffer} = state | ||
|
||
{:erl_level, level} = List.keyfind(md, :erl_level, 0, {:erl_level, level}) | ||
|
||
cond do | ||
not meet_level?(level, log_level) -> | ||
{:ok, state} | ||
|
@@ -232,10 +234,14 @@ defmodule Logger.Backends.Console do | |
colors = Keyword.get(config, :colors, []) | ||
|
||
%{ | ||
debug: Keyword.get(colors, :debug, :cyan), | ||
info: Keyword.get(colors, :info, :normal), | ||
warn: Keyword.get(colors, :warn, :yellow), | ||
emergency: Keyword.get(colors, :error, :red), | ||
alert: Keyword.get(colors, :error, :red), | ||
critical: Keyword.get(colors, :error, :red), | ||
error: Keyword.get(colors, :error, :red), | ||
warning: Keyword.get(colors, :warn, :yellow), | ||
notice: Keyword.get(colors, :info, :normal), | ||
info: Keyword.get(colors, :info, :normal), | ||
debug: Keyword.get(colors, :debug, :cyan), | ||
enabled: Keyword.get(colors, :enabled, IO.ANSI.enabled?()) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Order of the keys in this map is now weird. Earlier it was in decreasing verbosity, and now it is "whatever". |
||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,10 +163,10 @@ defmodule Logger.Formatter do | |
defp output(:levelpad, level, _, _, _), do: levelpad(level) | ||
defp output(other, _, _, _, _), do: other | ||
|
||
defp levelpad(:debug), do: "" | ||
# TODO: Deprecate me on Elixir v1.13+ or later | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. levelpad is not very useful now when one of the levels is "critical". There will be just too much padding on something like "info" (4 chars to be more precise). |
||
defp levelpad(:info), do: " " | ||
defp levelpad(:warn), do: " " | ||
defp levelpad(:error), do: "" | ||
defp levelpad(_), do: "" | ||
|
||
defp metadata([{key, value} | metadata]) do | ||
if formatted = metadata(key, value) do | ||
|
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.
md
is defined to be keyword list, so why useList.keyfind/4
instead ofKeyword.get/3
?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.
Both are fine. List.keyfind can be a tiny bit more efficient.