Verbose logging application. More...
#include "asterisk.h"#include "asterisk/module.h"#include "asterisk/app.h"#include "asterisk/channel.h"
Go to the source code of this file.
Functions | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | load_module (void) |
| static int | log_exec (struct ast_channel *chan, void *data) |
| static int | unload_module (void) |
| static int | verbose_exec (struct ast_channel *chan, void *data) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Send verbose output" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } |
| static char * | app_log = "Log" |
| static char * | app_verbose = "Verbose" |
| static struct ast_module_info * | ast_module_info = &__mod_info |
Verbose logging application.
Definition in file app_verbose.c.
| static void __reg_module | ( | void | ) | [static] |
Definition at line 185 of file app_verbose.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 185 of file app_verbose.c.
| static int load_module | ( | void | ) | [static] |
Definition at line 175 of file app_verbose.c.
References ast_register_application_xml, log_exec(), and verbose_exec().
{
int res;
res = ast_register_application_xml(app_log, log_exec);
res |= ast_register_application_xml(app_verbose, verbose_exec);
return res;
}
| static int log_exec | ( | struct ast_channel * | chan, |
| void * | data | ||
| ) | [static] |
Definition at line 121 of file app_verbose.c.
References __LOG_DEBUG, __LOG_DTMF, __LOG_ERROR, __LOG_EVENT, __LOG_NOTICE, __LOG_VERBOSE, __LOG_WARNING, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_MAX_EXTENSION, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_channel::context, context, ast_channel::exten, LOG_ERROR, msg, parse(), and ast_channel::priority.
Referenced by load_module().
{
char *parse;
int lnum = -1;
char extension[AST_MAX_EXTENSION + 5], context[AST_MAX_EXTENSION + 2];
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(level);
AST_APP_ARG(msg);
);
if (ast_strlen_zero(data))
return 0;
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
if (!strcasecmp(args.level, "ERROR")) {
lnum = __LOG_ERROR;
} else if (!strcasecmp(args.level, "WARNING")) {
lnum = __LOG_WARNING;
} else if (!strcasecmp(args.level, "NOTICE")) {
lnum = __LOG_NOTICE;
} else if (!strcasecmp(args.level, "DEBUG")) {
lnum = __LOG_DEBUG;
} else if (!strcasecmp(args.level, "VERBOSE")) {
lnum = __LOG_VERBOSE;
} else if (!strcasecmp(args.level, "DTMF")) {
lnum = __LOG_DTMF;
} else if (!strcasecmp(args.level, "EVENT")) {
lnum = __LOG_EVENT;
} else {
ast_log(LOG_ERROR, "Unknown log level: '%s'\n", args.level);
}
if (lnum > -1) {
snprintf(context, sizeof(context), "@ %s", chan->context);
snprintf(extension, sizeof(extension), "Ext. %s", chan->exten);
ast_log(lnum, extension, chan->priority, context, "%s\n", args.msg);
}
return 0;
}
| static int unload_module | ( | void | ) | [static] |
Definition at line 165 of file app_verbose.c.
References ast_unregister_application().
{
int res;
res = ast_unregister_application(app_verbose);
res |= ast_unregister_application(app_log);
return res;
}
| static int verbose_exec | ( | struct ast_channel * | chan, |
| void * | data | ||
| ) | [static] |
Definition at line 75 of file app_verbose.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_verbose(), LOG_WARNING, msg, option_verbose, parse(), VERBOSE_PREFIX_1, VERBOSE_PREFIX_2, VERBOSE_PREFIX_3, and VERBOSE_PREFIX_4.
Referenced by load_module().
{
int vsize;
char *parse;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(level);
AST_APP_ARG(msg);
);
if (ast_strlen_zero(data)) {
return 0;
}
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
if (args.argc == 1) {
args.msg = args.level;
args.level = "0";
}
if (sscanf(args.level, "%30d", &vsize) != 1) {
vsize = 0;
ast_log(LOG_WARNING, "'%s' is not a verboser number\n", args.level);
}
if (option_verbose >= vsize) {
switch (vsize) {
case 0:
ast_verbose("%s\n", args.msg);
break;
case 1:
ast_verbose(VERBOSE_PREFIX_1 "%s\n", args.msg);
break;
case 2:
ast_verbose(VERBOSE_PREFIX_2 "%s\n", args.msg);
break;
case 3:
ast_verbose(VERBOSE_PREFIX_3 "%s\n", args.msg);
break;
default:
ast_verbose(VERBOSE_PREFIX_4 "%s\n", args.msg);
}
}
return 0;
}
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Send verbose output" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, } [static] |
Definition at line 185 of file app_verbose.c.
char* app_log = "Log" [static] |
Definition at line 36 of file app_verbose.c.
char* app_verbose = "Verbose" [static] |
Definition at line 35 of file app_verbose.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 185 of file app_verbose.c.