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
This commit is contained in:
Scott Emidy
2015-08-06 15:18:04 -05:00
parent c07fa843ec
commit 78364132ce
8 changed files with 218 additions and 12 deletions

View File

@@ -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;