mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 04:11:08 +00:00
Support an alternate configuration file for the 'logger reload' command.
(closes issue #17668) Reported by: tilghman Patches: 20100718__logger_reload_altconf__2.diff.txt uploaded by tilghman (license 14) Review: (by lmadsen, russell within comments on issue tracker) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@300044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -24,6 +24,8 @@ CLI Changes
|
|||||||
-----------
|
-----------
|
||||||
* New 'gtalk show settings' command showing the current settings loaded from
|
* New 'gtalk show settings' command showing the current settings loaded from
|
||||||
gtalk.conf.
|
gtalk.conf.
|
||||||
|
* The 'logger reload' command now supports an optional argument, specifying an
|
||||||
|
alternate configuration file to use.
|
||||||
|
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
--- Functionality changes from Asterisk 1.6.2 to Asterisk 1.8 ----------------
|
--- Functionality changes from Asterisk 1.6.2 to Asterisk 1.8 ----------------
|
||||||
|
@@ -283,7 +283,7 @@ static struct logchannel *make_logchannel(const char *channel, const char *compo
|
|||||||
return chan;
|
return chan;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_logger_chain(int locked)
|
static void init_logger_chain(int locked, const char *altconf)
|
||||||
{
|
{
|
||||||
struct logchannel *chan;
|
struct logchannel *chan;
|
||||||
struct ast_config *cfg;
|
struct ast_config *cfg;
|
||||||
@@ -291,7 +291,7 @@ static void init_logger_chain(int locked)
|
|||||||
const char *s;
|
const char *s;
|
||||||
struct ast_flags config_flags = { 0 };
|
struct ast_flags config_flags = { 0 };
|
||||||
|
|
||||||
if (!(cfg = ast_config_load2("logger.conf", "logger", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
|
if (!(cfg = ast_config_load2(S_OR(altconf, "logger.conf"), "logger", config_flags)) || cfg == CONFIG_STATUS_FILEINVALID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,7 +616,7 @@ static int rotate_file(const char *filename)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int reload_logger(int rotate)
|
static int reload_logger(int rotate, const char *altconf)
|
||||||
{
|
{
|
||||||
char old[PATH_MAX] = "";
|
char old[PATH_MAX] = "";
|
||||||
int queue_rotate = rotate;
|
int queue_rotate = rotate;
|
||||||
@@ -665,7 +665,7 @@ static int reload_logger(int rotate)
|
|||||||
|
|
||||||
filesize_reload_needed = 0;
|
filesize_reload_needed = 0;
|
||||||
|
|
||||||
init_logger_chain(1 /* locked */);
|
init_logger_chain(1 /* locked */, altconf);
|
||||||
|
|
||||||
if (logfiles.queue_log) {
|
if (logfiles.queue_log) {
|
||||||
do {
|
do {
|
||||||
@@ -716,7 +716,7 @@ static int reload_logger(int rotate)
|
|||||||
a full Asterisk reload) */
|
a full Asterisk reload) */
|
||||||
int logger_reload(void)
|
int logger_reload(void)
|
||||||
{
|
{
|
||||||
if (reload_logger(0)) {
|
if (reload_logger(0, NULL)) {
|
||||||
return RESULT_FAILURE;
|
return RESULT_FAILURE;
|
||||||
}
|
}
|
||||||
return RESULT_SUCCESS;
|
return RESULT_SUCCESS;
|
||||||
@@ -727,14 +727,14 @@ static char *handle_logger_reload(struct ast_cli_entry *e, int cmd, struct ast_c
|
|||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case CLI_INIT:
|
case CLI_INIT:
|
||||||
e->command = "logger reload";
|
e->command = "logger reload";
|
||||||
e->usage =
|
e->usage =
|
||||||
"Usage: logger reload\n"
|
"Usage: logger reload [<alt-conf>]\n"
|
||||||
" Reloads the logger subsystem state. Use after restarting syslogd(8) if you are using syslog logging.\n";
|
" Reloads the logger subsystem state. Use after restarting syslogd(8) if you are using syslog logging.\n";
|
||||||
return NULL;
|
return NULL;
|
||||||
case CLI_GENERATE:
|
case CLI_GENERATE:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (reload_logger(0)) {
|
if (reload_logger(0, a->argc == 3 ? a->argv[2] : NULL)) {
|
||||||
ast_cli(a->fd, "Failed to reload the logger\n");
|
ast_cli(a->fd, "Failed to reload the logger\n");
|
||||||
return CLI_FAILURE;
|
return CLI_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -753,7 +753,7 @@ static char *handle_logger_rotate(struct ast_cli_entry *e, int cmd, struct ast_c
|
|||||||
case CLI_GENERATE:
|
case CLI_GENERATE:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (reload_logger(1)) {
|
if (reload_logger(1, NULL)) {
|
||||||
ast_cli(a->fd, "Failed to reload the logger and rotate log files\n");
|
ast_cli(a->fd, "Failed to reload the logger and rotate log files\n");
|
||||||
return CLI_FAILURE;
|
return CLI_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -966,7 +966,7 @@ static void logger_print_normal(struct logmsg *logmsg)
|
|||||||
|
|
||||||
/* If we need to reload because of the file size, then do so */
|
/* If we need to reload because of the file size, then do so */
|
||||||
if (filesize_reload_needed) {
|
if (filesize_reload_needed) {
|
||||||
reload_logger(-1);
|
reload_logger(-1, NULL);
|
||||||
ast_verb(1, "Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
|
ast_verb(1, "Rotated Logs Per SIGXFSZ (Exceeded file size limit)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1048,7 +1048,7 @@ int init_logger(void)
|
|||||||
ast_mkdir(ast_config_AST_LOG_DIR, 0777);
|
ast_mkdir(ast_config_AST_LOG_DIR, 0777);
|
||||||
|
|
||||||
/* create log channels */
|
/* create log channels */
|
||||||
init_logger_chain(0 /* locked */);
|
init_logger_chain(0 /* locked */, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user