From 7af47b9dbedb192eedd17d6ddedb92958b181d6a 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ejabberd_loglevel.erl b/src/ejabberd_loglevel.erl index b56f665e2..0e033324d 100644 --- a/src/ejabberd_loglevel.erl +++ b/src/ejabberd_loglevel.erl @@ -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