#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "asterisk/options.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.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 | AST_MODFLAG_BUILDSUM, .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } |
static char * | app_log = "Log" |
static char * | app_verbose = "Verbose" |
static const 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 168 of file app_verbose.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 168 of file app_verbose.c.
static int load_module | ( | void | ) | [static] |
Definition at line 158 of file app_verbose.c.
References ast_register_application(), log_exec(), and verbose_exec().
00159 { 00160 int res; 00161 00162 res = ast_register_application(app_log, log_exec, log_synopsis, log_descrip); 00163 res |= ast_register_application(app_verbose, verbose_exec, verbose_synopsis, verbose_descrip); 00164 00165 return res; 00166 }
static int log_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 101 of file app_verbose.c.
References __LOG_DEBUG, __LOG_DTMF, __LOG_ERROR, __LOG_EVENT, __LOG_NOTICE, __LOG_VERBOSE, __LOG_WARNING, ast_log(), AST_MAX_EXTENSION, ast_module_user_add, ast_module_user_remove, ast_strdupa, ast_strlen_zero(), ast_module_user::chan, ast_channel::context, context, ast_channel::exten, LOG_ERROR, and ast_channel::priority.
Referenced by load_module().
00102 { 00103 char *level, *ltext; 00104 struct ast_module_user *u; 00105 int lnum = -1; 00106 char extension[AST_MAX_EXTENSION + 5], context[AST_MAX_EXTENSION + 2]; 00107 00108 u = ast_module_user_add(chan); 00109 if (ast_strlen_zero(data)) { 00110 ast_module_user_remove(u); 00111 return 0; 00112 } 00113 00114 ltext = ast_strdupa(data); 00115 00116 level = strsep(<ext, "|"); 00117 00118 if (!strcasecmp(level, "ERROR")) { 00119 lnum = __LOG_ERROR; 00120 } else if (!strcasecmp(level, "WARNING")) { 00121 lnum = __LOG_WARNING; 00122 } else if (!strcasecmp(level, "NOTICE")) { 00123 lnum = __LOG_NOTICE; 00124 } else if (!strcasecmp(level, "DEBUG")) { 00125 lnum = __LOG_DEBUG; 00126 } else if (!strcasecmp(level, "VERBOSE")) { 00127 lnum = __LOG_VERBOSE; 00128 } else if (!strcasecmp(level, "DTMF")) { 00129 lnum = __LOG_DTMF; 00130 } else if (!strcasecmp(level, "EVENT")) { 00131 lnum = __LOG_EVENT; 00132 } else { 00133 ast_log(LOG_ERROR, "Unknown log level: '%s'\n", level); 00134 } 00135 00136 if (lnum > -1) { 00137 snprintf(context, sizeof(context), "@ %s", chan->context); 00138 snprintf(extension, sizeof(extension), "Ext. %s", chan->exten); 00139 00140 ast_log(lnum, extension, chan->priority, context, "%s\n", ltext); 00141 } 00142 ast_module_user_remove(u); 00143 return 0; 00144 }
static int unload_module | ( | void | ) | [static] |
Definition at line 146 of file app_verbose.c.
References ast_module_user_hangup_all, and ast_unregister_application().
00147 { 00148 int res; 00149 00150 res = ast_unregister_application(app_verbose); 00151 res |= ast_unregister_application(app_log); 00152 00153 ast_module_user_hangup_all(); 00154 00155 return res; 00156 }
static int verbose_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 55 of file app_verbose.c.
References ast_log(), ast_module_user_add, ast_module_user_remove, ast_strdupa, ast_verbose(), ast_module_user::chan, LOG_WARNING, option_verbose, VERBOSE_PREFIX_1, VERBOSE_PREFIX_2, VERBOSE_PREFIX_3, and VERBOSE_PREFIX_4.
Referenced by load_module().
00056 { 00057 char *vtext; 00058 int vsize; 00059 struct ast_module_user *u; 00060 00061 u = ast_module_user_add(chan); 00062 00063 if (data) { 00064 char *tmp; 00065 vtext = ast_strdupa(data); 00066 tmp = strsep(&vtext, "|"); 00067 if (vtext) { 00068 if (sscanf(tmp, "%30d", &vsize) != 1) { 00069 vsize = 0; 00070 ast_log(LOG_WARNING, "'%s' is not a verboser number\n", vtext); 00071 } 00072 } else { 00073 vtext = tmp; 00074 vsize = 0; 00075 } 00076 if (option_verbose >= vsize) { 00077 switch (vsize) { 00078 case 0: 00079 ast_verbose("%s\n", vtext); 00080 break; 00081 case 1: 00082 ast_verbose(VERBOSE_PREFIX_1 "%s\n", vtext); 00083 break; 00084 case 2: 00085 ast_verbose(VERBOSE_PREFIX_2 "%s\n", vtext); 00086 break; 00087 case 3: 00088 ast_verbose(VERBOSE_PREFIX_3 "%s\n", vtext); 00089 break; 00090 default: 00091 ast_verbose(VERBOSE_PREFIX_4 "%s\n", vtext); 00092 } 00093 } 00094 } 00095 00096 ast_module_user_remove(u); 00097 00098 return 0; 00099 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .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 = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 168 of file app_verbose.c.
char* app_log = "Log" [static] |
Definition at line 48 of file app_verbose.c.
char* app_verbose = "Verbose" [static] |
Definition at line 42 of file app_verbose.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 168 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 50 of file app_verbose.c.
char* log_synopsis = "Send arbitrary text to a selected log level" [static] |
Definition at line 49 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 44 of file app_verbose.c.
char* verbose_synopsis = "Send arbitrary text to verbose output" [static] |
Definition at line 43 of file app_verbose.c.