summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2015-08-07 10:41:22 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2015-08-07 10:41:22 -0500
commitcf272003919f04c1aaf3d0e921a0385be1e45e4b (patch)
treeaa34515cc0a9d6c18778bebde3c0bd2082e5f3f3 /main
parent4b1bd40d7ed639d884a62c2b70129d0fee32fa08 (diff)
parent78364132ce94d9ded24ae6e6ab44b97d256b506d (diff)
Merge "ARI: Deleting log channels" into 13
Diffstat (limited to 'main')
-rw-r--r--main/logger.c35
1 files changed, 35 insertions, 0 deletions
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;