mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 04:30:28 +00:00
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
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user