Asterisk - The Open Source Telephony Project  GIT-master-9ed6387
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"

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

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 171 of file app_verbose.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 171 of file app_verbose.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 161 of file app_verbose.c.

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

162 {
163  int res;
164 
167 
168  return res;
169 }
static char * app_log
Definition: app_verbose.c:38
static int verbose_exec(struct ast_channel *chan, const char *data)
Definition: app_verbose.c:77
static char * app_verbose
Definition: app_verbose.c:37
static int log_exec(struct ast_channel *chan, const char *data)
Definition: app_verbose.c:109
#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 109 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_log, AST_MAX_EXTENSION, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero, context, LOG_ERROR, and parse().

Referenced by load_module().

110 {
111  char *parse;
112  int lnum = -1;
115  AST_APP_ARG(level);
116  AST_APP_ARG(msg);
117  );
118 
119  if (ast_strlen_zero(data))
120  return 0;
121 
122  parse = ast_strdupa(data);
123  AST_STANDARD_APP_ARGS(args, parse);
124 
125  if (!strcasecmp(args.level, "ERROR")) {
126  lnum = __LOG_ERROR;
127  } else if (!strcasecmp(args.level, "WARNING")) {
128  lnum = __LOG_WARNING;
129  } else if (!strcasecmp(args.level, "NOTICE")) {
130  lnum = __LOG_NOTICE;
131  } else if (!strcasecmp(args.level, "DEBUG")) {
132  lnum = __LOG_DEBUG;
133  } else if (!strcasecmp(args.level, "VERBOSE")) {
134  lnum = __LOG_VERBOSE;
135  } else if (!strcasecmp(args.level, "DTMF")) {
136  lnum = __LOG_DTMF;
137  } else {
138  ast_log(LOG_ERROR, "Unknown log level: '%s'\n", args.level);
139  }
140 
141  if (lnum > -1) {
142  snprintf(context, sizeof(context), "@ %s", ast_channel_context(chan));
143  snprintf(extension, sizeof(extension), "Ext. %s", ast_channel_exten(chan));
144 
145  ast_log(lnum, extension, ast_channel_priority(chan), context, "%s\n", args.msg);
146  }
147 
148  return 0;
149 }
#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 __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_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
#define ast_strlen_zero(a)
Definition: muted.c:73
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
#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 151 of file app_verbose.c.

References app_log, app_verbose, and ast_unregister_application().

152 {
153  int res;
154 
157 
158  return res;
159 }
static char * app_log
Definition: app_verbose.c:38
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
static char * app_verbose
Definition: app_verbose.c:37

◆ verbose_exec()

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

Definition at line 77 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().

78 {
79  unsigned int vsize;
80  char *parse;
82  AST_APP_ARG(level);
83  AST_APP_ARG(msg);
84  );
85 
86  if (ast_strlen_zero(data)) {
87  return 0;
88  }
89 
90  parse = ast_strdupa(data);
92  if (args.argc == 1) {
93  args.msg = args.level;
94  args.level = "0";
95  }
96 
97  if (sscanf(args.level, "%30u", &vsize) != 1) {
98  vsize = 0;
99  ast_log(LOG_WARNING, "'%s' is not a verboser number\n", args.level);
100  } else if (4 < vsize) {
101  vsize = 4;
102  }
103 
104  ast_verb(vsize, "%s\n", args.msg);
105 
106  return 0;
107 }
#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:455
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define ast_strlen_zero(a)
Definition: muted.c:73
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 = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 171 of file app_verbose.c.

◆ app_log

char* app_log = "Log"
static

Definition at line 38 of file app_verbose.c.

Referenced by load_module(), and unload_module().

◆ app_verbose

char* app_verbose = "Verbose"
static

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