2004-08-06 02:12:54 +00:00
|
|
|
/*
|
2005-09-15 15:44:26 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2004-08-06 02:12:54 +00:00
|
|
|
*
|
2005-01-21 07:06:25 +00:00
|
|
|
* Copyright (c) 2004 - 2005 Tilghman Lesher. All rights reserved.
|
2004-08-06 02:12:54 +00:00
|
|
|
*
|
|
|
|
* Tilghman Lesher <app_verbose_v001@the-tilghman.com>
|
|
|
|
*
|
|
|
|
* This code is released by the author with no restrictions on usage.
|
|
|
|
*
|
2005-09-15 15:44:26 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
2005-09-15 15:44:26 +00:00
|
|
|
*
|
2005-10-24 20:12:06 +00:00
|
|
|
* \brief Verbose logging application
|
2005-09-15 15:44:26 +00:00
|
|
|
*
|
2005-11-06 15:09:47 +00:00
|
|
|
* \ingroup applications
|
2004-08-06 02:12:54 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
2005-06-06 22:39:32 +00:00
|
|
|
|
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
|
2005-04-21 06:02:45 +00:00
|
|
|
#include "asterisk/options.h"
|
|
|
|
#include "asterisk/logger.h"
|
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/pbx.h"
|
|
|
|
#include "asterisk/module.h"
|
2004-08-06 02:12:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
static char *tdesc = "Send verbose output";
|
|
|
|
|
|
|
|
static char *app_verbose = "Verbose";
|
|
|
|
|
|
|
|
static char *verbose_synopsis = "Send arbitrary text to verbose output";
|
|
|
|
|
|
|
|
static char *verbose_descrip =
|
|
|
|
"Verbose([<level>|]<message>)\n"
|
2005-11-07 22:01:22 +00:00
|
|
|
" level must be an integer value. If not specified, defaults to 0.\n";
|
2004-08-06 02:12:54 +00:00
|
|
|
|
|
|
|
STANDARD_LOCAL_USER;
|
|
|
|
|
|
|
|
LOCAL_USER_DECL;
|
|
|
|
|
|
|
|
static int verbose_exec(struct ast_channel *chan, void *data)
|
|
|
|
{
|
|
|
|
char *vtext;
|
|
|
|
int vsize;
|
2005-10-19 18:19:02 +00:00
|
|
|
struct localuser *u;
|
|
|
|
|
|
|
|
LOCAL_USER_ADD(u);
|
2004-08-06 02:12:54 +00:00
|
|
|
|
|
|
|
if (data) {
|
|
|
|
vtext = ast_strdupa((char *)data);
|
|
|
|
if (vtext) {
|
|
|
|
char *tmp = strsep(&vtext, "|,");
|
|
|
|
if (vtext) {
|
|
|
|
if (sscanf(tmp, "%d", &vsize) != 1) {
|
|
|
|
vsize = 0;
|
|
|
|
ast_log(LOG_WARNING, "'%s' is not a verboser number\n", vtext);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
vtext = tmp;
|
|
|
|
vsize = 0;
|
|
|
|
}
|
|
|
|
if (option_verbose >= vsize) {
|
|
|
|
switch (vsize) {
|
2004-08-06 17:09:54 +00:00
|
|
|
case 0:
|
|
|
|
ast_verbose("%s\n", vtext);
|
|
|
|
break;
|
2004-08-06 02:12:54 +00:00
|
|
|
case 1:
|
|
|
|
ast_verbose(VERBOSE_PREFIX_1 "%s\n", vtext);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ast_verbose(VERBOSE_PREFIX_2 "%s\n", vtext);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ast_verbose(VERBOSE_PREFIX_3 "%s\n", vtext);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ast_verbose(VERBOSE_PREFIX_4 "%s\n", vtext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ast_log(LOG_ERROR, "Out of memory\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-19 18:19:02 +00:00
|
|
|
LOCAL_USER_REMOVE(u);
|
|
|
|
|
2004-08-06 02:12:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int unload_module(void)
|
|
|
|
{
|
2005-10-18 22:52:21 +00:00
|
|
|
int res;
|
|
|
|
|
|
|
|
res = ast_unregister_application(app_verbose);
|
|
|
|
|
2004-08-06 02:12:54 +00:00
|
|
|
STANDARD_HANGUP_LOCALUSERS;
|
2005-10-18 22:52:21 +00:00
|
|
|
|
|
|
|
return res;
|
2004-08-06 02:12:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int load_module(void)
|
|
|
|
{
|
|
|
|
return ast_register_application(app_verbose, verbose_exec, verbose_synopsis, verbose_descrip);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *description(void)
|
|
|
|
{
|
|
|
|
return tdesc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int usecount(void)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
STANDARD_USECOUNT(res);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *key()
|
|
|
|
{
|
|
|
|
return ASTERISK_GPL_KEY;
|
|
|
|
}
|