Asterisk - The Open Source Telephony Project  18.5.0
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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .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 178 of file app_verbose.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 178 of file app_verbose.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 178 of file app_verbose.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 168 of file app_verbose.c.

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

169 {
170  int res;
171 
174 
175  return res;
176 }
static char * app_log
Definition: app_verbose.c:39
static int verbose_exec(struct ast_channel *chan, const char *data)
Definition: app_verbose.c:79
static char * app_verbose
Definition: app_verbose.c:38
static int log_exec(struct ast_channel *chan, const char *data)
Definition: app_verbose.c:111
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

◆ log_exec()

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

Definition at line 111 of file app_verbose.c.

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_dynamic_logger_level(), ast_log, ast_log_dynamic_level, AST_MAX_EXTENSION, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, context, LOG_ERROR, and parse().

Referenced by load_module().

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);
125  AST_STANDARD_APP_ARGS(args, parse);
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 {
140  int level = ast_dynamic_logger_level(args.level);
141  if (level > -1) {
142  ast_log_dynamic_level(level, "%s\n", args.msg);
143  } else {
144  ast_log(LOG_ERROR, "Unknown log level: '%s'\n", args.level);
145  }
146  }
147 
148  if (lnum > -1) {
149  snprintf(context, sizeof(context), "@ %s", ast_channel_context(chan));
150  snprintf(extension, sizeof(extension), "Ext. %s", ast_channel_exten(chan));
151 
152  ast_log(lnum, extension, ast_channel_priority(chan), context, "%s\n", args.msg);
153  }
154 
155  return 0;
156 }
#define __LOG_DEBUG
Definition: logger.h:240
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define __LOG_DTMF
Definition: logger.h:306
#define ast_log_dynamic_level(level,...)
Send a log message to a dynamically registered log level.
Definition: logger.h:439
#define __LOG_WARNING
Definition: logger.h:273
#define __LOG_ERROR
Definition: logger.h:284
const char * args
int ast_channel_priority(const struct ast_channel *chan)
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
#define AST_MAX_EXTENSION
Definition: channel.h:135
structure to hold extensions
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
const char * ast_channel_exten(const struct ast_channel *chan)
#define LOG_ERROR
Definition: logger.h:285
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
int ast_dynamic_logger_level(const char *name)
Checks if a dynamic logger level exists.
Definition: logger.c:2514
#define __LOG_NOTICE
Definition: logger.h:262
#define __LOG_VERBOSE
Definition: logger.h:295
const char * ast_channel_context(const struct ast_channel *chan)
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:116
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_APP_ARG(name)
Define an application argument.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 158 of file app_verbose.c.

References app_log, app_verbose, and ast_unregister_application().

159 {
160  int res;
161 
164 
165  return res;
166 }
static char * app_log
Definition: app_verbose.c:39
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
static char * app_verbose
Definition: app_verbose.c:38

◆ verbose_exec()

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_verb, LOG_WARNING, and parse().

Referenced by load_module().

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_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
const char * args
#define ast_verb(level,...)
Definition: logger.h:463
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
#define AST_APP_ARG(name)
Define an application argument.

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

Definition at line 178 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 178 of file app_verbose.c.