summaryrefslogtreecommitdiff
path: root/res/ari/resource_asterisk.c
diff options
context:
space:
mode:
authorBenjamin Ford <bford@digium.com>2015-07-29 14:17:09 -0500
committerBenjamin Ford <bford@digium.com>2015-07-31 11:43:47 -0500
commit1ae762634c317fbcbd98a8c34d2474f7d4b654ed (patch)
tree84127e860a5d60a43d64d4a589546dfba157d323 /res/ari/resource_asterisk.c
parentf78a4b52b8ed7b5b367c3465652a7ce98fe9175d (diff)
ARI: Rotate log channels.
An http request can be sent to rotate a specified log channel. If the channel does not exist, an error response will be returned. The command "curl -v -u user:pass -X PUT 'http://localhost:8088 /ari/asterisk/logging/logChannelName/rotate'" can be run in the terminal to access this new functionality. * Added the ability to rotate log files through ARI ASTERISK-25252 Change-Id: Iaefa21cbbc1b29effb33004ee3d89c977e76ab01
Diffstat (limited to 'res/ari/resource_asterisk.c')
-rw-r--r--res/ari/resource_asterisk.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/res/ari/resource_asterisk.c b/res/ari/resource_asterisk.c
index 2b6b6bc6e..e227951e2 100644
--- a/res/ari/resource_asterisk.c
+++ b/res/ari/resource_asterisk.c
@@ -33,6 +33,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/ast_version.h"
#include "asterisk/buildinfo.h"
+#include "asterisk/logger.h"
#include "asterisk/module.h"
#include "asterisk/paths.h"
#include "asterisk/pbx.h"
@@ -627,6 +628,31 @@ void ast_ari_asterisk_reload_module(struct ast_variable *headers,
ast_ari_response_no_content(response);
}
+void ast_ari_asterisk_rotate_log(struct ast_variable *headers,
+ struct ast_ari_asterisk_rotate_log_args *args,
+ struct ast_ari_response *response)
+{
+ int success;
+
+ ast_assert(response != NULL);
+
+ success = ast_logger_rotate_channel(args->log_channel_name);
+
+ if (success == 0) {
+ ast_ari_response_error(
+ response, 404, "Not Found",
+ "Log channel does not exist");
+ return;
+ } else if (success == -1) {
+ ast_ari_response_error(
+ response, 500, "Internal Server Error",
+ "Allocation failed");
+ return;
+ }
+
+ ast_ari_response_no_content(response);
+}
+
void ast_ari_asterisk_get_global_var(struct ast_variable *headers,
struct ast_ari_asterisk_get_global_var_args *args,
struct ast_ari_response *response)