Asterisk - The Open Source Telephony Project GIT-master-8f1982c
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Functions | Variables
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 "asterisk/logger.h"
Include dependency graph for app_verbose.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static char * app_log = "Log"
 
static char * app_verbose = "Verbose"
 
static const struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

Verbose logging application.

Author
Tilghman Lesher app_v.nosp@m.erbo.nosp@m.se_v0.nosp@m.01@t.nosp@m.he-ti.nosp@m.lghm.nosp@m.an.co.nosp@m.m

Definition in file app_verbose.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 182 of file app_verbose.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 182 of file app_verbose.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 182 of file app_verbose.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 172 of file app_verbose.c.

173{
174 int res;
175
178
179 return res;
180}
static int verbose_exec(struct ast_channel *chan, const char *data)
Definition: app_verbose.c:85
static char * app_log
Definition: app_verbose.c:39
static int log_exec(struct ast_channel *chan, const char *data)
Definition: app_verbose.c:117
static char * app_verbose
Definition: app_verbose.c:38
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640

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

◆ log_exec()

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

Definition at line 117 of file app_verbose.c.

118{
119 char *parse;
120 int lnum = -1;
123 AST_APP_ARG(level);
124 AST_APP_ARG(msg);
125 );
126
127 if (ast_strlen_zero(data))
128 return 0;
129
130 parse = ast_strdupa(data);
132
133 if (!strcasecmp(args.level, "ERROR")) {
134 lnum = __LOG_ERROR;
135 } else if (!strcasecmp(args.level, "WARNING")) {
136 lnum = __LOG_WARNING;
137 } else if (!strcasecmp(args.level, "NOTICE")) {
138 lnum = __LOG_NOTICE;
139 } else if (!strcasecmp(args.level, "DEBUG")) {
140 lnum = __LOG_DEBUG;
141 } else if (!strcasecmp(args.level, "VERBOSE")) {
142 lnum = __LOG_VERBOSE;
143 } else if (!strcasecmp(args.level, "DTMF")) {
144 lnum = __LOG_DTMF;
145 } else {
147 }
148
149 if (lnum > -1) {
150 snprintf(context, sizeof(context), "@ %s", ast_channel_context(chan));
151 snprintf(extension, sizeof(extension), "Ext. %s", ast_channel_exten(chan));
152
153 ast_log(lnum, extension, ast_channel_priority(chan), context, "%s\n", args.msg);
154 } else {
155 ast_log(LOG_ERROR, "Unknown log level: '%s'\n", args.level);
156 return 0;
157 }
158
159 return 0;
160}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_log
Definition: astobj2.c:42
int ast_channel_priority(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
const char * ast_channel_exten(const struct ast_channel *chan)
#define AST_MAX_EXTENSION
Definition: channel.h:134
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int ast_logger_get_dynamic_level(const char *name)
Retrieve dynamic logging level id.
Definition: logger.c:2855
#define __LOG_ERROR
#define __LOG_DTMF
#define __LOG_VERBOSE
#define __LOG_NOTICE
#define __LOG_DEBUG
#define __LOG_WARNING
#define LOG_ERROR
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
structure to hold extensions
const char * args

References __LOG_DEBUG, __LOG_DTMF, __LOG_ERROR, __LOG_NOTICE, __LOG_VERBOSE, __LOG_WARNING, args, AST_APP_ARG, ast_channel_context(), ast_channel_exten(), ast_channel_priority(), AST_DECLARE_APP_ARGS, ast_log, ast_logger_get_dynamic_level(), AST_MAX_EXTENSION, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), voicemailpwcheck::context, and LOG_ERROR.

Referenced by load_module().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 162 of file app_verbose.c.

163{
164 int res;
165
168
169 return res;
170}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References app_log, app_verbose, and ast_unregister_application().

◆ verbose_exec()

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

Definition at line 85 of file app_verbose.c.

86{
87 unsigned int vsize;
88 char *parse;
90 AST_APP_ARG(level);
91 AST_APP_ARG(msg);
92 );
93
94 if (ast_strlen_zero(data)) {
95 return 0;
96 }
97
98 parse = ast_strdupa(data);
100 if (args.argc == 1) {
101 args.msg = args.level;
102 args.level = "0";
103 }
104
105 if (sscanf(args.level, "%30u", &vsize) != 1) {
106 vsize = 0;
107 ast_log(LOG_WARNING, "'%s' is not a verboser number\n", args.level);
108 } else if (4 < vsize) {
109 vsize = 4;
110 }
111
112 ast_verb(vsize, "%s\n", args.msg);
113
114 return 0;
115}
#define ast_verb(level,...)
#define LOG_WARNING

References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_verb, and LOG_WARNING.

Referenced by load_module().

Variable Documentation

◆ __mod_info

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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 182 of file app_verbose.c.

◆ app_log

char* app_log = "Log"
static

Definition at line 39 of file app_verbose.c.

Referenced by load_module(), and unload_module().

◆ app_verbose

char* app_verbose = "Verbose"
static

Definition at line 38 of file app_verbose.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 182 of file app_verbose.c.