Wed Apr 6 11:29:51 2011

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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .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 183 of file app_verbose.c.

static void __unreg_module ( void   )  [static]

Definition at line 183 of file app_verbose.c.

static int load_module ( void   )  [static]

Definition at line 173 of file app_verbose.c.

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

00174 {
00175    int res;
00176 
00177    res = ast_register_application_xml(app_log, log_exec);
00178    res |= ast_register_application_xml(app_verbose, verbose_exec);
00179 
00180    return res;
00181 }

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

Definition at line 121 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().

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

static int unload_module ( void   )  [static]

Definition at line 163 of file app_verbose.c.

References ast_unregister_application().

00164 {
00165    int res;
00166 
00167    res = ast_unregister_application(app_verbose);
00168    res |= ast_unregister_application(app_log);
00169 
00170    return res; 
00171 }

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

Definition at line 75 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().

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


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 = "8586c2a7d357cb591cc3a6607a8f62d1" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, } [static]

Definition at line 183 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 183 of file app_verbose.c.


Generated on Wed Apr 6 11:29:51 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7