summaryrefslogtreecommitdiff
path: root/main/logger.c
diff options
context:
space:
mode:
authorScott Emidy <jemidy@digium.com>2015-08-07 11:14:06 -0500
committerScott Emidy <jemidy@digium.com>2015-08-07 11:18:13 -0500
commitb91ca7ba49ce74152139309fd0ae1a66df695cc0 (patch)
tree9d96113e70f17b03115ca14de207cba74ff61dc5 /main/logger.c
parentecd4cde521d0b5fc43312aed500e1bcff181209c (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.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/main/logger.c b/main/logger.c
index cea9530e2..c516ec07d 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -1046,6 +1046,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;