diff options
author | Scott Emidy <jemidy@digium.com> | 2015-08-07 11:14:06 -0500 |
---|---|---|
committer | Scott Emidy <jemidy@digium.com> | 2015-08-07 11:15:08 -0500 |
commit | e9f1bc08cbda7759707c30b8883b266555d0fefc (patch) | |
tree | 0a2ff61c1f4b4d8d6ae0c426be73ef66dffc35ae /main/logger.c | |
parent | cf272003919f04c1aaf3d0e921a0385be1e45e4b (diff) |
ARI: Creating log channels
An http request can be sent to create a log channel
in Asterisk.
The command "curl -v -u user:pass -X POST
'http://localhost:088/ari/asterisk/logging/mylog?
configuration=notice,warning'" can be run in the terminal
to access the newly implemented functionality for ARI.
* Ability to create log channels using ARI
ASTERISK-25252
Change-Id: I9a20e5c75716dfbb6b62fd3474faf55be20bd782
Diffstat (limited to 'main/logger.c')
-rw-r--r-- | main/logger.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/main/logger.c b/main/logger.c index f64825dc8..c856e7209 100644 --- a/main/logger.c +++ b/main/logger.c @@ -1054,6 +1054,44 @@ static char *handle_logger_show_channels(struct ast_cli_entry *e, int cmd, struc return CLI_SUCCESS; } +int ast_logger_create_channel(const char *log_channel, const char *components) +{ + struct logchannel *chan; + struct ast_str *filename = ast_str_create(64); + int chan_exists = AST_LOGGER_SUCCESS; + + if (ast_strlen_zero(components)) { + return AST_LOGGER_DECLINE; + } + + 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(&logchannels, chan, list) { + if (!strcmp(ast_str_buffer(filename), chan->filename)) { + chan_exists = AST_LOGGER_FAILURE; + break; + } + } + + if (!chan_exists) { + chan = make_logchannel(log_channel, components, 0, 1); + if (chan) { + AST_RWLIST_INSERT_HEAD(&logchannels, chan, list); + global_logmask |= chan->logmask; + chan_exists = AST_LOGGER_SUCCESS; + } + } + AST_RWLIST_UNLOCK(&logchannels); + + return chan_exists; +} + static char *handle_logger_add_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { struct logchannel *chan; |