#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 = "a9c98e5d177805051735cb5b0b16b0a0" , .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 |
static char * | log_descrip |
static char * | log_synopsis = "Send arbitrary text to a selected log level" |
static char * | verbose_descrip |
static char * | verbose_synopsis = "Send arbitrary text to verbose output" |
Definition in file app_verbose.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 158 of file app_verbose.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 158 of file app_verbose.c.
static int load_module | ( | void | ) | [static] |
Definition at line 148 of file app_verbose.c.
References ast_register_application, log_exec(), and verbose_exec().
00149 { 00150 int res; 00151 00152 res = ast_register_application(app_log, log_exec, log_synopsis, log_descrip); 00153 res |= ast_register_application(app_verbose, verbose_exec, verbose_synopsis, verbose_descrip); 00154 00155 return res; 00156 }
static int log_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 94 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(), chan, ast_channel::context, context, ast_channel::exten, LOG_ERROR, msg, parse(), and ast_channel::priority.
Referenced by load_module().
00095 { 00096 char *parse; 00097 int lnum = -1; 00098 char extension[AST_MAX_EXTENSION + 5], context[AST_MAX_EXTENSION + 2]; 00099 AST_DECLARE_APP_ARGS(args, 00100 AST_APP_ARG(level); 00101 AST_APP_ARG(msg); 00102 ); 00103 00104 if (ast_strlen_zero(data)) 00105 return 0; 00106 00107 parse = ast_strdupa(data); 00108 AST_STANDARD_APP_ARGS(args, parse); 00109 00110 if (!strcasecmp(args.level, "ERROR")) { 00111 lnum = __LOG_ERROR; 00112 } else if (!strcasecmp(args.level, "WARNING")) { 00113 lnum = __LOG_WARNING; 00114 } else if (!strcasecmp(args.level, "NOTICE")) { 00115 lnum = __LOG_NOTICE; 00116 } else if (!strcasecmp(args.level, "DEBUG")) { 00117 lnum = __LOG_DEBUG; 00118 } else if (!strcasecmp(args.level, "VERBOSE")) { 00119 lnum = __LOG_VERBOSE; 00120 } else if (!strcasecmp(args.level, "DTMF")) { 00121 lnum = __LOG_DTMF; 00122 } else if (!strcasecmp(args.level, "EVENT")) { 00123 lnum = __LOG_EVENT; 00124 } else { 00125 ast_log(LOG_ERROR, "Unknown log level: '%s'\n", args.level); 00126 } 00127 00128 if (lnum > -1) { 00129 snprintf(context, sizeof(context), "@ %s", chan->context); 00130 snprintf(extension, sizeof(extension), "Ext. %s", chan->exten); 00131 00132 ast_log(lnum, extension, chan->priority, context, "%s\n", args.msg); 00133 } 00134 00135 return 0; 00136 }
static int unload_module | ( | void | ) | [static] |
Definition at line 138 of file app_verbose.c.
References ast_unregister_application().
00139 { 00140 int res; 00141 00142 res = ast_unregister_application(app_verbose); 00143 res |= ast_unregister_application(app_log); 00144 00145 return res; 00146 }
static int verbose_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 48 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().
00049 { 00050 int vsize; 00051 char *parse; 00052 AST_DECLARE_APP_ARGS(args, 00053 AST_APP_ARG(level); 00054 AST_APP_ARG(msg); 00055 ); 00056 00057 if (ast_strlen_zero(data)) { 00058 return 0; 00059 } 00060 00061 parse = ast_strdupa(data); 00062 AST_STANDARD_APP_ARGS(args, parse); 00063 if (args.argc == 1) { 00064 args.msg = args.level; 00065 args.level = "0"; 00066 } 00067 00068 if (sscanf(args.level, "%30d", &vsize) != 1) { 00069 vsize = 0; 00070 ast_log(LOG_WARNING, "'%s' is not a verboser number\n", args.level); 00071 } 00072 if (option_verbose >= vsize) { 00073 switch (vsize) { 00074 case 0: 00075 ast_verbose("%s\n", args.msg); 00076 break; 00077 case 1: 00078 ast_verbose(VERBOSE_PREFIX_1 "%s\n", args.msg); 00079 break; 00080 case 2: 00081 ast_verbose(VERBOSE_PREFIX_2 "%s\n", args.msg); 00082 break; 00083 case 3: 00084 ast_verbose(VERBOSE_PREFIX_3 "%s\n", args.msg); 00085 break; 00086 default: 00087 ast_verbose(VERBOSE_PREFIX_4 "%s\n", args.msg); 00088 } 00089 } 00090 00091 return 0; 00092 }
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 = "a9c98e5d177805051735cb5b0b16b0a0" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 158 of file app_verbose.c.
char* app_log = "Log" [static] |
Definition at line 41 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 158 of file app_verbose.c.
char* log_descrip [static] |
Initial value:
"Log(<level>,<message>)\n" " level must be one of ERROR, WARNING, NOTICE, DEBUG, VERBOSE, DTMF\n"
Definition at line 43 of file app_verbose.c.
char* log_synopsis = "Send arbitrary text to a selected log level" [static] |
Definition at line 42 of file app_verbose.c.
char* verbose_descrip [static] |
Initial value:
"Verbose([<level>,]<message>)\n" " level must be an integer value. If not specified, defaults to 0.\n"
Definition at line 37 of file app_verbose.c.
char* verbose_synopsis = "Send arbitrary text to verbose output" [static] |
Definition at line 36 of file app_verbose.c.