Tue Aug 24 20:35:04 2010

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"
Include dependency graph for app_verbose.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Send verbose output")
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 char * app_log = "Log"
static char * app_verbose = "Verbose"

Detailed Description

Verbose logging application.

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

Definition in file app_verbose.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Send verbose output"   
)
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().

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

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().

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 if (!strcasecmp(args.level, "EVENT")) {
00150       lnum = __LOG_EVENT;
00151    } else {
00152       ast_log(LOG_ERROR, "Unknown log level: '%s'\n", args.level);
00153    }
00154 
00155    if (lnum > -1) {
00156       snprintf(context, sizeof(context), "@ %s", chan->context);
00157       snprintf(extension, sizeof(extension), "Ext. %s", chan->exten);
00158 
00159       ast_log(lnum, extension, chan->priority, context, "%s\n", args.msg);
00160    }
00161 
00162    return 0;
00163 }

static int unload_module ( void   )  [static]

Definition at line 165 of file app_verbose.c.

References ast_unregister_application().

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

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().

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

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.


Generated on 24 Aug 2010 for Asterisk - the Open Source PBX by  doxygen 1.6.1