mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Add set_custom/2, clear_custom/0 and clear_custom/1 to ejabberd_loglevel
This commit is contained in:
parent
14349890e3
commit
e1f5fb798c
@ -31,7 +31,11 @@
|
|||||||
-module(ejabberd_loglevel).
|
-module(ejabberd_loglevel).
|
||||||
-author('mickael.remond@process-one.net').
|
-author('mickael.remond@process-one.net').
|
||||||
|
|
||||||
-export([set/1, get/0]).
|
-export([set/1,
|
||||||
|
get/0,
|
||||||
|
set_custom/2,
|
||||||
|
clear_custom/0,
|
||||||
|
clear_custom/1]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
|
|
||||||
@ -82,6 +86,30 @@ set({DefaultLevel, CustomLevels}) when is_list(CustomLevels) ->
|
|||||||
set(_) ->
|
set(_) ->
|
||||||
exit("Invalid loglevel format").
|
exit("Invalid loglevel format").
|
||||||
|
|
||||||
|
set_custom(Module, Level) ->
|
||||||
|
{DefaultLevel, CustomLevels} = ejabberd_logger:get(),
|
||||||
|
case lists:keysearch(Module, 1, CustomLevels) of
|
||||||
|
{value, {Module, Level}} ->
|
||||||
|
ok;
|
||||||
|
{value, _} ->
|
||||||
|
set({DefaultLevel, lists:keyreplace(Module, 1, CustomLevels, {Module, Level})});
|
||||||
|
_ ->
|
||||||
|
set({DefaultLevel, [{Module, Level} | CustomLevels]})
|
||||||
|
end.
|
||||||
|
|
||||||
|
clear_custom() ->
|
||||||
|
{DefaultLevel, CustomLevels} = ejabberd_logger:get(),
|
||||||
|
set({DefaultLevel, []}).
|
||||||
|
|
||||||
|
clear_custom(Module) ->
|
||||||
|
{DefaultLevel, CustomLevels} = ejabberd_logger:get(),
|
||||||
|
case lists:keysearch(Module, 1, CustomLevels) of
|
||||||
|
{value, _} ->
|
||||||
|
set({DefaultLevel, lists:keydelete(Module, 1, CustomLevels)});
|
||||||
|
_ ->
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
level_to_integer(Level) when is_integer(Level) ->
|
level_to_integer(Level) when is_integer(Level) ->
|
||||||
Level;
|
Level;
|
||||||
level_to_integer({Module, Level}) ->
|
level_to_integer({Module, Level}) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user