Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
undefined_functions
]}.

{profiles, [
{test, []},
{gha, [{erl_opts, [{d, 'GITHUBEXCLUDE'}]}]}
]}.

{alias, [
{check, [xref, dialyzer]}
]}.
Binary file added rebar3
Binary file not shown.
21 changes: 20 additions & 1 deletion src/riak_logger.erl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
filter_p/2,
filter_ps/2,
filter_r/2,
filter_s/2
filter_s/2,
filter_t/2
]).

-compile([
Expand All @@ -69,6 +70,7 @@

-type f_action() :: log | stop.
-type f_result() :: logger:filter_return().
-type f_type() :: backend|aae|metric.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this should be atom(), or even term() - the filter, as implemented, doesn't care about the type or value.


%% ===================================================================
%% Filters
Expand Down Expand Up @@ -192,6 +194,23 @@ filter_s(#{meta := #{domain := [otp, sasl | _]}} = Event, Action) ->
filter_s(_Event, _Action) ->
ignore.

-spec filter_t(
Event :: logger:log_event(),
{Action :: f_action(), LogTypes :: list(f_type())})
-> f_result().
%% @doc Filter out logs with specific log_types, e.g. such as the backend log
%% type used in leveled

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add a head for the most common case?

filter_t(#{meta := #{log_type := LogType}} = Event, {Action, [LogType]}) ->
    filter_match(Event, Action);

filter_t(#{meta := #{log_type := LogType}} = Event, {Action, LogTypes}) ->
case lists:member(LogType, LogTypes) of
true ->
filter_match(Event, Action);
false ->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Change false to _ - generates less code.

ignore
end;
filter_t(_Event, {_Action, _LogTypes}) ->
ignore.


%% ===================================================================
%% Internal
%% ===================================================================
Expand Down
Loading