mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 02:57:23 +00:00
logger: Add custom logging capabilities
Adds the ability for users to log to custom log levels by providing custom log level names in logger.conf. Also adds a logger show levels CLI command. ASTERISK-29529 Change-Id: If082703cf81a436ae5a565c75225fa8c0554b702
This commit is contained in:
committed by
Kevin Harwell
parent
dce142baa4
commit
a65bb134f5
@@ -33,6 +33,7 @@
|
||||
#include "asterisk/module.h"
|
||||
#include "asterisk/app.h"
|
||||
#include "asterisk/channel.h"
|
||||
#include "asterisk/logger.h"
|
||||
|
||||
static char *app_verbose = "Verbose";
|
||||
static char *app_log = "Log";
|
||||
@@ -61,7 +62,8 @@ static char *app_log = "Log";
|
||||
<syntax>
|
||||
<parameter name="level" required="true">
|
||||
<para>Level must be one of <literal>ERROR</literal>, <literal>WARNING</literal>, <literal>NOTICE</literal>,
|
||||
<literal>DEBUG</literal>, <literal>VERBOSE</literal> or <literal>DTMF</literal>.</para>
|
||||
<literal>DEBUG</literal>, <literal>VERBOSE</literal>, <literal>DTMF</literal>, or
|
||||
the name of a custom dynamic logging level.</para>
|
||||
</parameter>
|
||||
<parameter name="message" required="true">
|
||||
<para>Output text message.</para>
|
||||
@@ -135,7 +137,7 @@ static int log_exec(struct ast_channel *chan, const char *data)
|
||||
} else if (!strcasecmp(args.level, "DTMF")) {
|
||||
lnum = __LOG_DTMF;
|
||||
} else {
|
||||
ast_log(LOG_ERROR, "Unknown log level: '%s'\n", args.level);
|
||||
lnum = ast_logger_get_dynamic_level(args.level);
|
||||
}
|
||||
|
||||
if (lnum > -1) {
|
||||
@@ -143,6 +145,9 @@ static int log_exec(struct ast_channel *chan, const char *data)
|
||||
snprintf(extension, sizeof(extension), "Ext. %s", ast_channel_exten(chan));
|
||||
|
||||
ast_log(lnum, extension, ast_channel_priority(chan), context, "%s\n", args.msg);
|
||||
} else {
|
||||
ast_log(LOG_ERROR, "Unknown log level: '%s'\n", args.level);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user