Mon Mar 19 11:30:34 2012

Asterisk developer's documentation


app_verbose.c File Reference

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, const char *data)
static int unload_module (void)
static int verbose_exec (struct ast_channel *chan, const char *data)

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .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 = "88eaa8f5c1bd988bedd71113385e0886" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static char * app_log = "Log"
static char * app_verbose = "Verbose"
static struct ast_module_infoast_module_info = &__mod_info


Detailed Description

Verbose logging application.

Author:
Tilghman Lesher <app_verbose_v001@the-tilghman.com>

Definition in file app_verbose.c.


Function Documentation

static void __reg_module ( void   )  [static]

Definition at line 187 of file app_verbose.c.

static void __unreg_module ( void   )  [static]

Definition at line 187 of file app_verbose.c.

static int load_module ( void   )  [static]

Definition at line 177 of file app_verbose.c.

References ast_register_application_xml, log_exec(), and verbose_exec().

00178 {
00179    int res;
00180 
00181    res = ast_register_application_xml(app_log, log_exec);
00182    res |= ast_register_application_xml(app_verbose, verbose_exec);
00183 
00184    return res;
00185 }

static int log_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 125 of file app_verbose.c.

References __LOG_DEBUG, __LOG_DTMF, __LOG_ERROR, __LOG_NOTICE, __LOG_VERBOSE, __LOG_WARNING, args, 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, parse(), and ast_channel::priority.

Referenced by load_module().

00126 {
00127    char *parse;
00128    int lnum = -1;
00129    char extension[AST_MAX_EXTENSION + 5], context[AST_MAX_EXTENSION + 2];
00130    AST_DECLARE_APP_ARGS(args,
00131       AST_APP_ARG(level);
00132       AST_APP_ARG(msg);
00133    );
00134 
00135    if (ast_strlen_zero(data))
00136       return 0;
00137 
00138    parse = ast_strdupa(data);
00139    AST_STANDARD_APP_ARGS(args, parse);
00140 
00141    if (!strcasecmp(args.level, "ERROR")) {
00142       lnum = __LOG_ERROR;
00143    } else if (!strcasecmp(args.level, "WARNING")) {
00144       lnum = __LOG_WARNING;
00145    } else if (!strcasecmp(args.level, "NOTICE")) {
00146       lnum = __LOG_NOTICE;
00147    } else if (!strcasecmp(args.level, "DEBUG")) {
00148       lnum = __LOG_DEBUG;
00149    } else if (!strcasecmp(args.level, "VERBOSE")) {
00150       lnum = __LOG_VERBOSE;
00151    } else if (!strcasecmp(args.level, "DTMF")) {
00152       lnum = __LOG_DTMF;
00153    } else {
00154       ast_log(LOG_ERROR, "Unknown log level: '%s'\n", args.level);
00155    }
00156 
00157    if (lnum > -1) {
00158       snprintf(context, sizeof(context), "@ %s", chan->context);
00159       snprintf(extension, sizeof(extension), "Ext. %s", chan->exten);
00160 
00161       ast_log(lnum, extension, chan->priority, context, "%s\n", args.msg);
00162    }
00163 
00164    return 0;
00165 }

static int unload_module ( void   )  [static]

Definition at line 167 of file app_verbose.c.

References ast_unregister_application().

00168 {
00169    int res;
00170 
00171    res = ast_unregister_application(app_verbose);
00172    res |= ast_unregister_application(app_log);
00173 
00174    return res; 
00175 }

static int verbose_exec ( struct ast_channel chan,
const char *  data 
) [static]

Definition at line 79 of file app_verbose.c.

References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_verbose, LOG_WARNING, option_verbose, parse(), VERBOSE_PREFIX_1, VERBOSE_PREFIX_2, VERBOSE_PREFIX_3, and VERBOSE_PREFIX_4.

Referenced by load_module().

00080 {
00081    int vsize;
00082    char *parse;
00083    AST_DECLARE_APP_ARGS(args,
00084       AST_APP_ARG(level);
00085       AST_APP_ARG(msg);
00086    );
00087 
00088    if (ast_strlen_zero(data)) {
00089       return 0;
00090    }
00091 
00092    parse = ast_strdupa(data);
00093    AST_STANDARD_APP_ARGS(args, parse);
00094    if (args.argc == 1) {
00095       args.msg = args.level;
00096       args.level = "0";
00097    }
00098 
00099    if (sscanf(args.level, "%30d", &vsize) != 1) {
00100       vsize = 0;
00101       ast_log(LOG_WARNING, "'%s' is not a verboser number\n", args.level);
00102    }
00103    if (option_verbose >= vsize) {
00104       switch (vsize) {
00105       case 0:
00106          ast_verbose("%s\n", args.msg);
00107          break;
00108       case 1:
00109          ast_verbose(VERBOSE_PREFIX_1 "%s\n", args.msg);
00110          break;
00111       case 2:
00112          ast_verbose(VERBOSE_PREFIX_2 "%s\n", args.msg);
00113          break;
00114       case 3:
00115          ast_verbose(VERBOSE_PREFIX_3 "%s\n", args.msg);
00116          break;
00117       default:
00118          ast_verbose(VERBOSE_PREFIX_4 "%s\n", args.msg);
00119       }
00120    }
00121 
00122    return 0;
00123 }


Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .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 = "88eaa8f5c1bd988bedd71113385e0886" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static]

Definition at line 187 of file app_verbose.c.

char* app_log = "Log" [static]

Definition at line 40 of file app_verbose.c.

char* app_verbose = "Verbose" [static]

Definition at line 39 of file app_verbose.c.

struct ast_module_info* ast_module_info = &__mod_info [static]

Definition at line 187 of file app_verbose.c.


Generated on Mon Mar 19 11:30:34 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7