mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-30 16:36:29 +01:00
Merge 2426 from trunk: add get/0 API function that returns current log level (EJAB-1004).
SVN Revision: 2436
This commit is contained in:
parent
9a204593e1
commit
936b2d4188
@ -31,7 +31,7 @@
|
|||||||
-module(ejabberd_loglevel).
|
-module(ejabberd_loglevel).
|
||||||
-author('mickael.remond@process-one.net').
|
-author('mickael.remond@process-one.net').
|
||||||
|
|
||||||
-export([set/1]).
|
-export([set/1, get/0]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
|
|
||||||
@ -46,6 +46,14 @@
|
|||||||
,{5, debug, "Debug"}
|
,{5, debug, "Debug"}
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
get() ->
|
||||||
|
Level = ejabberd_logger:get(),
|
||||||
|
case lists:keysearch(Level, 1, ?LOG_LEVELS) of
|
||||||
|
{value, Result} -> Result;
|
||||||
|
_ -> erlang:error({no_such_loglevel, Level})
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
set(LogLevel) when is_atom(LogLevel) ->
|
set(LogLevel) when is_atom(LogLevel) ->
|
||||||
set(level_to_integer(LogLevel));
|
set(level_to_integer(LogLevel));
|
||||||
set(Loglevel) when is_integer(Loglevel) ->
|
set(Loglevel) when is_integer(Loglevel) ->
|
||||||
@ -67,7 +75,7 @@ level_to_integer(Level) ->
|
|||||||
%% --------------------------------------------------------------
|
%% --------------------------------------------------------------
|
||||||
%% Code of the ejabberd logger, dynamically compiled and loaded
|
%% Code of the ejabberd logger, dynamically compiled and loaded
|
||||||
%% This allows to dynamically change log level while keeping a
|
%% This allows to dynamically change log level while keeping a
|
||||||
%% very efficient code.
|
%% very efficient code.
|
||||||
ejabberd_logger_src(Loglevel) ->
|
ejabberd_logger_src(Loglevel) ->
|
||||||
L = integer_to_list(Loglevel),
|
L = integer_to_list(Loglevel),
|
||||||
"-module(ejabberd_logger).
|
"-module(ejabberd_logger).
|
||||||
@ -77,7 +85,10 @@ ejabberd_logger_src(Loglevel) ->
|
|||||||
info_msg/4,
|
info_msg/4,
|
||||||
warning_msg/4,
|
warning_msg/4,
|
||||||
error_msg/4,
|
error_msg/4,
|
||||||
critical_msg/4]).
|
critical_msg/4,
|
||||||
|
get/0]).
|
||||||
|
|
||||||
|
get() -> "++ L ++".
|
||||||
|
|
||||||
%% Helper functions
|
%% Helper functions
|
||||||
debug_msg(Module, Line, Format, Args) when " ++ L ++ " >= 5 ->
|
debug_msg(Module, Line, Format, Args) when " ++ L ++ " >= 5 ->
|
||||||
|
Loading…
Reference in New Issue
Block a user