25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Document ejabberd_loglevel using EDoc (EJAB-225)

This commit is contained in:
Badlop 2010-10-15 11:31:18 +02:00
parent 437da38342
commit 7af47b9dbe

View File

@ -62,6 +62,10 @@
#loglevel{ordinal = 5, name = debug, description = "Debug",
function = debug_msg, event_type = info_msg, msg_prefix = "D"}]).
%% @type level() = integer() | atom().
%% @spec () -> [LevelOrdinal::integer(), [{Module::atom(), LevelOrdinal::integer()}]]
%% @doc Get the default and all custom levels
get() ->
{DefaultLevel, _CustomLevels} = ejabberd_logger:get(),
case lists:keysearch(DefaultLevel, #loglevel.ordinal, ?LOG_LEVELS) of
@ -71,6 +75,9 @@ get() ->
erlang:error({no_such_loglevel, DefaultLevel})
end.
%% @spec (DefaultLevel::level() | {DefaultLevel::level(), [{Module::atom(), Level::level()]}) ->
%% {module, ejabberd_logger}
%% @doc Set the default and all custom levels
set(DefaultLevel) when is_atom(DefaultLevel) orelse is_integer(DefaultLevel) ->
set({DefaultLevel, []});
set({DefaultLevel, CustomLevels}) when is_list(CustomLevels) ->
@ -86,6 +93,8 @@ set({DefaultLevel, CustomLevels}) when is_list(CustomLevels) ->
set(_) ->
exit("Invalid loglevel format").
%% @spec (Module::atom()::atom(), CustomLevel::level()) -> ok
%% @doc Set a custom level
set_custom(Module, Level) ->
{DefaultLevel, CustomLevels} = ejabberd_logger:get(),
case lists:keysearch(Module, 1, CustomLevels) of
@ -97,10 +106,14 @@ set_custom(Module, Level) ->
set({DefaultLevel, [{Module, Level} | CustomLevels]})
end.
%% @spec () -> ok
%% @doc Clear all custom levels
clear_custom() ->
{DefaultLevel, _CustomLevels} = ejabberd_logger:get(),
set({DefaultLevel, []}).
%% @spec (Module::atom()) -> ok
%% @doc Clear a custom level
clear_custom(Module) ->
{DefaultLevel, CustomLevels} = ejabberd_logger:get(),
case lists:keysearch(Module, 1, CustomLevels) of