[svn-commits] jrose: trunk r416848 - in /trunk: ./ include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jun 20 15:29:53 CDT 2014


Author: jrose
Date: Fri Jun 20 15:29:45 2014
New Revision: 416848

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416848
Log:
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/

Modified:
    trunk/CHANGES
    trunk/include/asterisk/logger.h
    trunk/main/logger.c
    trunk/main/manager.c

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=416848&r1=416847&r2=416848
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Fri Jun 20 15:29:45 2014
@@ -19,6 +19,9 @@
    occurs. The events are controlled by res_manager_device_state.so and
    res_manager_presence_state.so. If the high frequency of these events is
    problematic for you, do not load these modules.
+
+ * New AMI action LoggerRotate reloads and rotates logger in the same manner
+   as CLI command 'logger rotate'
 
 chan_dahdi
 ------------------

Modified: trunk/include/asterisk/logger.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/logger.h?view=diff&rev=416848&r1=416847&r2=416848
==============================================================================
--- trunk/include/asterisk/logger.h (original)
+++ trunk/include/asterisk/logger.h Fri Jun 20 15:29:45 2014
@@ -88,6 +88,9 @@
 /*! \brief Reload logger without rotating log files */
 int logger_reload(void);
 
+/*! \brief Reload logger while rotating log files */
+int ast_logger_rotate(void);
+
 void __attribute__((format(printf, 5, 6))) ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...);
 
 /*!

Modified: trunk/main/logger.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/logger.c?view=diff&rev=416848&r1=416847&r2=416848
==============================================================================
--- trunk/main/logger.c (original)
+++ trunk/main/logger.c Fri Jun 20 15:29:45 2014
@@ -928,6 +928,11 @@
 	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;

Modified: trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=416848&r1=416847&r2=416848
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Fri Jun 20 15:29:45 2014
@@ -800,6 +800,17 @@
 		</syntax>
 		<description>
 			<para>List currently defined channels and some information about them.</para>
+		</description>
+	</manager>
+	<manager name="LoggerRotate" language="en_US">
+		<synopsis>
+			Reload and rotate the Asterisk logger.
+		</synopsis>
+		<syntax>
+			<xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" />
+		</syntax>
+		<description>
+			<para>Reload and rotate the logger. Analogous to the CLI command 'logger rotate'.</para>
 		</description>
 	</manager>
 	<manager name="ModuleLoad" language="en_US">
@@ -5444,6 +5455,19 @@
 	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 @@
 	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 @@
 		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);




More information about the svn-commits mailing list