From 864b0ec149b1cdb192087b0f73abb3822df184be Mon Sep 17 00:00:00 2001 From: Badlop Date: Fri, 15 Oct 2010 11:31:18 +0200 Subject: [PATCH] Document ejabberd_loglevel using EDoc (EJAB-225) --- src/ejabberd_loglevel.erl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ejabberd_loglevel.erl b/src/ejabberd_loglevel.erl index 67328689b..c8ed9e713 100644 --- a/src/ejabberd_loglevel.erl +++ b/src/ejabberd_loglevel.erl @@ -63,9 +63,15 @@ #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() -> ejabberd_logger:get(). +%% @spec () -> {Ordinal::integer(), Name::atom(), Description::string()} +%% @doc Get the default level get_default() -> {DefaultLevel, _CustomLevels} = ejabberd_logger:get(), case lists:keysearch(DefaultLevel, #loglevel.ordinal, ?LOG_LEVELS) of @@ -75,6 +81,9 @@ get_default() -> 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) -> @@ -90,6 +99,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 @@ -101,10 +112,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