mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
* src/ejabberd_loglevel.erl: add get/0 API function that returns current log level (EJAB-1004).
SVN Revision: 2426
This commit is contained in:
parent
95239baf85
commit
0cc9d8f8a0
@ -31,7 +31,7 @@
|
||||
-module(ejabberd_loglevel).
|
||||
-author('mickael.remond@process-one.net').
|
||||
|
||||
-export([set/1]).
|
||||
-export([set/1, get/0]).
|
||||
|
||||
-include("ejabberd.hrl").
|
||||
|
||||
@ -46,6 +46,14 @@
|
||||
,{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(level_to_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
|
||||
%% This allows to dynamically change log level while keeping a
|
||||
%% very efficient code.
|
||||
%% very efficient code.
|
||||
ejabberd_logger_src(Loglevel) ->
|
||||
L = integer_to_list(Loglevel),
|
||||
"-module(ejabberd_logger).
|
||||
@ -77,7 +85,10 @@ ejabberd_logger_src(Loglevel) ->
|
||||
info_msg/4,
|
||||
warning_msg/4,
|
||||
error_msg/4,
|
||||
critical_msg/4]).
|
||||
critical_msg/4,
|
||||
get/0]).
|
||||
|
||||
get() -> "++ L ++".
|
||||
|
||||
%% Helper functions
|
||||
debug_msg(Module, Line, Format, Args) when " ++ L ++ " >= 5 ->
|
||||
|
Loading…
Reference in New Issue
Block a user