25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-30 16:36:29 +01:00

Don't let "reopen_log" rotate files (EJAB-1243)

Make sure the "reopen_log" command really just reopens log files without
also rotating them.  For rotating log files, the new "rotate_log"
command can be used.
This commit is contained in:
Holger Weiss 2015-12-08 22:48:04 +01:00
parent 325c17f277
commit 07baf2d973
2 changed files with 18 additions and 2 deletions

View File

@ -28,7 +28,7 @@
-export([start/0, stop/0, -export([start/0, stop/0,
%% Server %% Server
status/0, reopen_log/0, status/0, reopen_log/0, rotate_log/0,
set_loglevel/1, set_loglevel/1,
stop_kindly/2, send_service_message_all_mucs/2, stop_kindly/2, send_service_message_all_mucs/2,
registered_vhosts/0, registered_vhosts/0,
@ -88,6 +88,10 @@ commands() ->
desc = "Reopen the log files", desc = "Reopen the log files",
module = ?MODULE, function = reopen_log, module = ?MODULE, function = reopen_log,
args = [], result = {res, rescode}}, args = [], result = {res, rescode}},
#ejabberd_commands{name = rotate_log, tags = [logs, server],
desc = "Rotate the log files",
module = ?MODULE, function = rotate_log,
args = [], result = {res, rescode}},
#ejabberd_commands{name = stop_kindly, tags = [server], #ejabberd_commands{name = stop_kindly, tags = [server],
desc = "Inform users and rooms, wait, and stop the server", desc = "Inform users and rooms, wait, and stop the server",
longdesc = "Provide the delay in seconds, and the " longdesc = "Provide the delay in seconds, and the "
@ -276,6 +280,9 @@ reopen_log() ->
ejabberd_hooks:run(reopen_log_hook, []), ejabberd_hooks:run(reopen_log_hook, []),
ejabberd_logger:reopen_log(). ejabberd_logger:reopen_log().
rotate_log() ->
ejabberd_hooks:run(rotate_log_hook, []),
ejabberd_logger:rotate_log().
set_loglevel(LogLevel) -> set_loglevel(LogLevel) ->
{module, Module} = ejabberd_logger:set(LogLevel), {module, Module} = ejabberd_logger:set(LogLevel),

View File

@ -27,7 +27,7 @@
-behaviour(ejabberd_config). -behaviour(ejabberd_config).
%% API %% API
-export([start/0, reopen_log/0, get/0, set/1, get_log_path/0, opt_type/1]). -export([start/0, reopen_log/0, rotate_log/0, get/0, set/1, get_log_path/0, opt_type/1]).
-include("ejabberd.hrl"). -include("ejabberd.hrl").
@ -36,6 +36,7 @@
-spec start() -> ok. -spec start() -> ok.
-spec get_log_path() -> string(). -spec get_log_path() -> string().
-spec reopen_log() -> ok. -spec reopen_log() -> ok.
-spec rotate_log() -> ok.
-spec get() -> {loglevel(), atom(), string()}. -spec get() -> {loglevel(), atom(), string()}.
-spec set(loglevel() | {loglevel(), list()}) -> {module, module()}. -spec set(loglevel() | {loglevel(), list()}) -> {module, module()}.
@ -128,6 +129,10 @@ start() ->
ok. ok.
reopen_log() -> reopen_log() ->
%% Lager detects external log rotation automatically.
ok.
rotate_log() ->
lager_crash_log ! rotate, lager_crash_log ! rotate,
lists:foreach( lists:foreach(
fun({lager_file_backend, File}) -> fun({lager_file_backend, File}) ->
@ -191,6 +196,10 @@ reopen_log() ->
p1_logger_h:reopen_log(), p1_logger_h:reopen_log(),
reopen_sasl_log(). reopen_sasl_log().
rotate_log() ->
%% Not implemented.
ok.
get() -> get() ->
p1_loglevel:get(). p1_loglevel:get().