Wed Jan 8 2020 09:49:55

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"

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, 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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static char * app_log = "Log"
 
static char * app_verbose = "Verbose"
 
static 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

static void __reg_module ( void  )
static

Definition at line 187 of file app_verbose.c.

static void __unreg_module ( void  )
static

Definition at line 187 of file app_verbose.c.

static int load_module ( void  )
static

Definition at line 177 of file app_verbose.c.

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

178 {
179  int res;
180 
183 
184  return res;
185 }
static char * app_log
Definition: app_verbose.c:40
static int verbose_exec(struct ast_channel *chan, const char *data)
Definition: app_verbose.c:79
static char * app_verbose
Definition: app_verbose.c:39
static int log_exec(struct ast_channel *chan, const char *data)
Definition: app_verbose.c:125
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int log_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 125 of file app_verbose.c.

References __LOG_DEBUG, __LOG_DTMF, __LOG_ERROR, __LOG_NOTICE, __LOG_VERBOSE, __LOG_WARNING, args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_MAX_EXTENSION, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), context, ast_channel::context, ast_channel::exten, LOG_ERROR, parse(), and ast_channel::priority.

Referenced by load_module().

126 {
127  char *parse;
128  int lnum = -1;
131  AST_APP_ARG(level);
132  AST_APP_ARG(msg);
133  );
134 
135  if (ast_strlen_zero(data))
136  return 0;
137 
138  parse = ast_strdupa(data);
139  AST_STANDARD_APP_ARGS(args, parse);
140 
141  if (!strcasecmp(args.level, "ERROR")) {
142  lnum = __LOG_ERROR;
143  } else if (!strcasecmp(args.level, "WARNING")) {
144  lnum = __LOG_WARNING;
145  } else if (!strcasecmp(args.level, "NOTICE")) {
146  lnum = __LOG_NOTICE;
147  } else if (!strcasecmp(args.level, "DEBUG")) {
148  lnum = __LOG_DEBUG;
149  } else if (!strcasecmp(args.level, "VERBOSE")) {
150  lnum = __LOG_VERBOSE;
151  } else if (!strcasecmp(args.level, "DTMF")) {
152  lnum = __LOG_DTMF;
153  } else {
154  ast_log(LOG_ERROR, "Unknown log level: '%s'\n", args.level);
155  }
156 
157  if (lnum > -1) {
158  snprintf(context, sizeof(context), "@ %s", chan->context);
159  snprintf(extension, sizeof(extension), "Ext. %s", chan->exten);
160 
161  ast_log(lnum, extension, chan->priority, context, "%s\n", args.msg);
162  }
163 
164  return 0;
165 }
#define __LOG_DEBUG
Definition: logger.h:121
int priority
Definition: channel.h:841
char context[AST_MAX_CONTEXT]
Definition: channel.h:868
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Definition: app.h:572
#define __LOG_DTMF
Definition: logger.h:176
#define __LOG_WARNING
Definition: logger.h:143
#define __LOG_ERROR
Definition: logger.h:154
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define AST_MAX_EXTENSION
Definition: channel.h:135
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
#define LOG_ERROR
Definition: logger.h:155
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
#define __LOG_NOTICE
Definition: logger.h:132
#define __LOG_VERBOSE
Definition: logger.h:165
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
Definition: app.h:604
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:107
char exten[AST_MAX_EXTENSION]
Definition: channel.h:869
static int unload_module ( void  )
static

Definition at line 167 of file app_verbose.c.

References ast_unregister_application().

168 {
169  int res;
170 
173 
174  return res;
175 }
static char * app_log
Definition: app_verbose.c:40
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
static char * app_verbose
Definition: app_verbose.c:39
static int verbose_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 79 of file app_verbose.c.

References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_verbose(), LOG_WARNING, option_verbose, parse(), VERBOSE_PREFIX_1, VERBOSE_PREFIX_2, VERBOSE_PREFIX_3, and VERBOSE_PREFIX_4.

Referenced by load_module().

80 {
81  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, "%30d", &vsize) != 1) {
100  vsize = 0;
101  ast_log(LOG_WARNING, "'%s' is not a verboser number\n", args.level);
102  }
103  if (option_verbose >= vsize) {
104  switch (vsize) {
105  case 0:
106  ast_verbose("%s\n", args.msg);
107  break;
108  case 1:
109  ast_verbose(VERBOSE_PREFIX_1 "%s\n", args.msg);
110  break;
111  case 2:
112  ast_verbose(VERBOSE_PREFIX_2 "%s\n", args.msg);
113  break;
114  case 3:
115  ast_verbose(VERBOSE_PREFIX_3 "%s\n", args.msg);
116  break;
117  default:
118  ast_verbose(VERBOSE_PREFIX_4 "%s\n", args.msg);
119  }
120  }
121 
122  return 0;
123 }
#define VERBOSE_PREFIX_1
Definition: logger.h:41
#define VERBOSE_PREFIX_3
Definition: logger.h:43
#define LOG_WARNING
Definition: logger.h:144
void ast_verbose(const char *fmt,...)
Definition: logger.c:1568
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Definition: app.h:572
int option_verbose
Definition: asterisk.c:181
#define VERBOSE_PREFIX_4
Definition: logger.h:44
#define VERBOSE_PREFIX_2
Definition: logger.h:42
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
Definition: app.h:604

Variable Documentation

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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 187 of file app_verbose.c.

char* app_log = "Log"
static

Definition at line 40 of file app_verbose.c.

char* app_verbose = "Verbose"
static

Definition at line 39 of file app_verbose.c.

Definition at line 187 of file app_verbose.c.