Asterisk - The Open Source Telephony Project GIT-master-7e7a603
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 176 of file app_verbose.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 176 of file app_verbose.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 176 of file app_verbose.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 166 of file app_verbose.c.

167{
168 int res;
169
172
173 return res;
174}
static int verbose_exec(struct ast_channel *chan, const char *data)
Definition: app_verbose.c:79
static char * app_log
Definition: app_verbose.c:39
static int log_exec(struct ast_channel *chan, const char *data)
Definition: app_verbose.c:111
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:626

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 111 of file app_verbose.c.

112{
113 char *parse;
114 int lnum = -1;
117 AST_APP_ARG(level);
118 AST_APP_ARG(msg);
119 );
120
121 if (ast_strlen_zero(data))
122 return 0;
123
124 parse = ast_strdupa(data);
126
127 if (!strcasecmp(args.level, "ERROR")) {
128 lnum = __LOG_ERROR;
129 } else if (!strcasecmp(args.level, "WARNING")) {
130 lnum = __LOG_WARNING;
131 } else if (!strcasecmp(args.level, "NOTICE")) {
132 lnum = __LOG_NOTICE;
133 } else if (!strcasecmp(args.level, "DEBUG")) {
134 lnum = __LOG_DEBUG;
135 } else if (!strcasecmp(args.level, "VERBOSE")) {
136 lnum = __LOG_VERBOSE;
137 } else if (!strcasecmp(args.level, "DTMF")) {
138 lnum = __LOG_DTMF;
139 } else {
141 }
142
143 if (lnum > -1) {
144 snprintf(context, sizeof(context), "@ %s", ast_channel_context(chan));
145 snprintf(extension, sizeof(extension), "Ext. %s", ast_channel_exten(chan));
146
147 ast_log(lnum, extension, ast_channel_priority(chan), context, "%s\n", args.msg);
148 } else {
149 ast_log(LOG_ERROR, "Unknown log level: '%s'\n", args.level);
150 return 0;
151 }
152
153 return 0;
154}
#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:2868
#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 156 of file app_verbose.c.

157{
158 int res;
159
162
163 return res;
164}
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 79 of file app_verbose.c.

80{
81 unsigned int vsize;
82 char *parse;
84 AST_APP_ARG(level);
85 AST_APP_ARG(msg);
86 );
87
88 if (ast_strlen_zero(data)) {
89 return 0;
90 }
91
92 parse = ast_strdupa(data);
94 if (args.argc == 1) {
95 args.msg = args.level;
96 args.level = "0";
97 }
98
99 if (sscanf(args.level, "%30u", &vsize) != 1) {
100 vsize = 0;
101 ast_log(LOG_WARNING, "'%s' is not a verboser number\n", args.level);
102 } else if (4 < vsize) {
103 vsize = 4;
104 }
105
106 ast_verb(vsize, "%s\n", args.msg);
107
108 return 0;
109}
#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 176 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 176 of file app_verbose.c.