From 78364132ce94d9ded24ae6e6ab44b97d256b506d Mon Sep 17 00:00:00 2001 From: Scott Emidy Date: Thu, 6 Aug 2015 15:18:04 -0500 Subject: 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 --- main/logger.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'main') diff --git a/main/logger.c b/main/logger.c index 8fd8e50f8..f64825dc8 100644 --- a/main/logger.c +++ b/main/logger.c @@ -1103,6 +1103,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; -- cgit v1.2.3