summaryrefslogtreecommitdiff
path: root/main/logger.c
diff options
context:
space:
mode:
authorScott Emidy <jemidy@digium.com>2015-08-06 15:18:04 -0500
committerScott Emidy <jemidy@digium.com>2015-08-06 17:43:49 -0500
commitf19c4930c2bd11e8b75ad2c6b4e5ff9d5304edb8 (patch)
treed606ce2af41912f99e3e957884313b228ca6b850 /main/logger.c
parentca84a4b2351966c20d2fc8cf24157f2e3d6db643 (diff)
ARI: Deleting log channels
An http request can be sent to delete a log channel in Asterisk. The command "curl -v -u user:pass -X DELETE 'http://localhost:8088 /ari/asterisk/logging/mylog'" can be run in the terminal to access the newly implemented functionally for ARI. * Able to delete log channels using ARI ASTERISK-25252 Change-Id: Id6eeb54ebcc511595f0418d586ff55914bc3aae6
Diffstat (limited to 'main/logger.c')
-rw-r--r--main/logger.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/main/logger.c b/main/logger.c
index 607755b58..cea9530e2 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -1095,6 +1095,41 @@ static char *handle_logger_add_channel(struct ast_cli_entry *e, int cmd, struct
return CLI_FAILURE;
}
+int ast_logger_remove_channel(const char *log_channel)
+{
+ struct logchannel *chan;
+ struct ast_str *filename = ast_str_create(64);
+
+ if (!filename) {
+ return AST_LOGGER_ALLOC_ERROR;
+ }
+
+ ast_str_append(&filename, 0, "%s/%s", ast_config_AST_LOG_DIR, log_channel);
+
+ AST_RWLIST_WRLOCK(&logchannels);
+ AST_RWLIST_TRAVERSE_SAFE_BEGIN(&logchannels, chan, list) {
+ if (chan->dynamic && !strcmp(chan->filename, ast_str_buffer(filename))) {
+ AST_RWLIST_REMOVE_CURRENT(list);
+ break;
+ }
+ }
+ AST_RWLIST_TRAVERSE_SAFE_END;
+ AST_RWLIST_UNLOCK(&logchannels);
+
+ if (!chan) {
+ return AST_LOGGER_FAILURE;
+ }
+
+ if (chan->fileptr) {
+ fclose(chan->fileptr);
+ chan->fileptr = NULL;
+ }
+ ast_free(chan);
+ chan = NULL;
+
+ return AST_LOGGER_SUCCESS;
+}
+
static char *handle_logger_remove_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct logchannel *chan;