From e087ae0c022a307e358fe9339b0a58323aa3d28a Mon Sep 17 00:00:00 2001 From: Jonathan Rose Date: Fri, 20 Jun 2014 20:29:45 +0000 Subject: Logger: Add manager command 'LoggerRotate' to rotate logger Part of a series of AMI command equivalents to existing CLI commands Review: https://reviewboard.asterisk.org/r/3651/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416848 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/logger.c | 5 +++++ main/manager.c | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'main') diff --git a/main/logger.c b/main/logger.c index c58b97c97..86cd0d4a6 100644 --- a/main/logger.c +++ b/main/logger.c @@ -928,6 +928,11 @@ static char *handle_logger_rotate(struct ast_cli_entry *e, int cmd, struct ast_c return CLI_SUCCESS; } +int ast_logger_rotate() +{ + return reload_logger(1, NULL); +} + static char *handle_logger_set_level(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { int x; diff --git a/main/manager.c b/main/manager.c index 6e056a163..253517d96 100644 --- a/main/manager.c +++ b/main/manager.c @@ -802,6 +802,17 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") List currently defined channels and some information about them. + + + Reload and rotate the Asterisk logger. + + + + + + Reload and rotate the logger. Analogous to the CLI command 'logger rotate'. + + Module management. @@ -5444,6 +5455,19 @@ static int action_coreshowchannels(struct mansession *s, const struct message *m return 0; } +/*! \brief Manager command "LoggerRotate" - reloads and rotates the logger in + * the same manner as the CLI command 'logger rotate'. */ +static int action_loggerrotate(struct mansession *s, const struct message *m) +{ + if (ast_logger_rotate()) { + astman_send_error(s, m, "Failed to reload the logger and rotate log files"); + return 0; + } + + astman_send_ack(s, m, "Reloaded the logger and rotated log files"); + return 0; +} + /*! \brief Manager function to check if module is loaded */ static int manager_modulecheck(struct mansession *s, const struct message *m) { @@ -7930,6 +7954,7 @@ static void manager_shutdown(void) ast_manager_unregister("CoreSettings"); ast_manager_unregister("CoreStatus"); ast_manager_unregister("Reload"); + ast_manager_unregister("LoggerRotate"); ast_manager_unregister("CoreShowChannels"); ast_manager_unregister("ModuleLoad"); ast_manager_unregister("ModuleCheck"); @@ -8126,6 +8151,7 @@ static int __init_manager(int reload, int by_external_config) ast_manager_register_xml_core("CoreSettings", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, action_coresettings); ast_manager_register_xml_core("CoreStatus", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, action_corestatus); ast_manager_register_xml_core("Reload", EVENT_FLAG_CONFIG | EVENT_FLAG_SYSTEM, action_reload); + ast_manager_register_xml_core("LoggerRotate", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, action_loggerrotate); ast_manager_register_xml_core("CoreShowChannels", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, action_coreshowchannels); ast_manager_register_xml_core("ModuleLoad", EVENT_FLAG_SYSTEM, manager_moduleload); ast_manager_register_xml_core("ModuleCheck", EVENT_FLAG_SYSTEM, manager_modulecheck); -- cgit v1.2.3