mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
Separate verbose output from CLI output, by using a preamble.
(closes issue #12402) Reported by: Corydon76 Patches: 20080410__no_verbose_in_rx_output.diff.txt uploaded by Corydon76 (license 14) 20080501__no_verbose_in_rx_output__1.4.diff.txt uploaded by Corydon76 (license 14) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@115333 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1345,6 +1345,12 @@ static void __quit_handler(int num)
|
|||||||
static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp)
|
static const char *fix_header(char *outbuf, int maxout, const char *s, char *cmp)
|
||||||
{
|
{
|
||||||
const char *c;
|
const char *c;
|
||||||
|
|
||||||
|
/* Check for verboser preamble */
|
||||||
|
if (*s == 127) {
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strncmp(s, cmp, strlen(cmp))) {
|
if (!strncmp(s, cmp, strlen(cmp))) {
|
||||||
c = s + strlen(cmp);
|
c = s + strlen(cmp);
|
||||||
term_color(outbuf, cmp, COLOR_GRAY, 0, maxout);
|
term_color(outbuf, cmp, COLOR_GRAY, 0, maxout);
|
||||||
@@ -1788,6 +1794,7 @@ static int ast_el_read_char(EditLine *el, char *cp)
|
|||||||
|
|
||||||
buf[res] = '\0';
|
buf[res] = '\0';
|
||||||
|
|
||||||
|
/* Write over the CLI prompt */
|
||||||
if (!ast_opt_exec && !lastpos)
|
if (!ast_opt_exec && !lastpos)
|
||||||
write(STDOUT_FILENO, "\r", 1);
|
write(STDOUT_FILENO, "\r", 1);
|
||||||
write(STDOUT_FILENO, buf, res);
|
write(STDOUT_FILENO, buf, res);
|
||||||
@@ -2292,13 +2299,38 @@ static void ast_remotecontrol(char * data)
|
|||||||
ast_el_read_history(filename);
|
ast_el_read_history(filename);
|
||||||
|
|
||||||
if (ast_opt_exec && data) { /* hack to print output then exit if asterisk -rx is used */
|
if (ast_opt_exec && data) { /* hack to print output then exit if asterisk -rx is used */
|
||||||
char tempchar;
|
|
||||||
struct pollfd fds;
|
struct pollfd fds;
|
||||||
fds.fd = ast_consock;
|
fds.fd = ast_consock;
|
||||||
fds.events = POLLIN;
|
fds.events = POLLIN;
|
||||||
fds.revents = 0;
|
fds.revents = 0;
|
||||||
while (poll(&fds, 1, 100) > 0)
|
while (poll(&fds, 1, 500) > 0) {
|
||||||
ast_el_read_char(el, &tempchar);
|
char buf[512] = "", *curline = buf, *nextline;
|
||||||
|
int not_written = 1;
|
||||||
|
|
||||||
|
if (read(ast_consock, buf, sizeof(buf) - 1) < 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
do {
|
||||||
|
if ((nextline = strchr(curline, '\n'))) {
|
||||||
|
nextline++;
|
||||||
|
} else {
|
||||||
|
nextline = strchr(curline, '\0');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skip verbose lines */
|
||||||
|
if (*curline != 127) {
|
||||||
|
not_written = 0;
|
||||||
|
write(STDOUT_FILENO, curline, nextline - curline + (*nextline == '\0' ? 1 : 0));
|
||||||
|
}
|
||||||
|
curline = nextline;
|
||||||
|
} while (!ast_strlen_zero(curline));
|
||||||
|
|
||||||
|
/* No non-verbose output in 500ms */
|
||||||
|
if (not_written) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@@ -875,8 +875,12 @@ void ast_verbose(const char *fmt, ...)
|
|||||||
ast_localtime(&t, &tm, NULL);
|
ast_localtime(&t, &tm, NULL);
|
||||||
strftime(date, sizeof(date), dateformat, &tm);
|
strftime(date, sizeof(date), dateformat, &tm);
|
||||||
datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1);
|
datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1);
|
||||||
sprintf(datefmt, "[%s] %s", date, fmt);
|
sprintf(datefmt, "%c[%s] %s", 127, date, fmt);
|
||||||
fmt = datefmt;
|
fmt = datefmt;
|
||||||
|
} else {
|
||||||
|
char *tmp = alloca(strlen(fmt) + 2);
|
||||||
|
sprintf(tmp, "%c%s", 127, fmt);
|
||||||
|
fmt = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(buf = ast_dynamic_str_thread_get(&verbose_buf, VERBOSE_BUF_INIT_SIZE)))
|
if (!(buf = ast_dynamic_str_thread_get(&verbose_buf, VERBOSE_BUF_INIT_SIZE)))
|
||||||
@@ -897,7 +901,7 @@ void ast_verbose(const char *fmt, ...)
|
|||||||
v->verboser(buf->str);
|
v->verboser(buf->str);
|
||||||
AST_LIST_UNLOCK(&verbosers);
|
AST_LIST_UNLOCK(&verbosers);
|
||||||
|
|
||||||
ast_log(LOG_VERBOSE, "%s", buf->str);
|
ast_log(LOG_VERBOSE, "%s", buf->str + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_register_verbose(void (*v)(const char *string))
|
int ast_register_verbose(void (*v)(const char *string))
|
||||||
|
Reference in New Issue
Block a user