Index: asterisk.c =================================================================== RCS file: /usr/cvsroot/asterisk/asterisk.c,v retrieving revision 1.47 diff -u -r1.47 asterisk.c --- asterisk.c 9 Dec 2003 20:37:10 -0000 1.47 +++ asterisk.c 11 Jan 2004 21:08:54 -0000 @@ -151,9 +151,26 @@ static void network_verboser(const char *s, int pos, int replace, int complete) { int x; - for (x=0;x -1) - fdprint(consoles[x].p[1], s); + char *buf = alloca(strlen(s) + 2); + + if (complete) { + if (buf) { + /* Have to strip terminal colors on remote consoles here, + * otherwise local console can't get color on ast_verbose messages */ + memset(buf, 0, strlen(s) + 1); + term_strip(buf, s, strlen(s) + 1); + + /* On messages originally ast_verbose, the newline is there, but not there for ast_log messages */ + if (!strchr(buf,'\n')) + strcat(buf, "\n"); + + for (x=0;x -1) + fdprint(consoles[x].p[1], buf); + } + } else { + /* Can't call ast_log on memory error, because ast_log calls ast_verbose (recursive) */ + } } } @@ -231,13 +248,13 @@ FD_SET(ast_socket, &fds); s = ast_select(ast_socket + 1, &fds, NULL, NULL, NULL); if (s < 0) { - ast_log(LOG_WARNING, "Select retured error: %s\n", strerror(errno)); + ast_log(LOG_WARNING, "Select returned error: %s\n", strerror(errno)); continue; } len = sizeof(sun); s = accept(ast_socket, (struct sockaddr *)&sun, &len); if (s < 0) { - ast_log(LOG_WARNING, "Accept retured %d: %s\n", s, strerror(errno)); + ast_log(LOG_WARNING, "Accept returned %d: %s\n", s, strerror(errno)); } else { for (x=0;xf, "%s %s[%ld]: File %s, Line %d (%s): ", date, levels[level], (long)pthread_self(), file, line, function); } else { + char *msg; sprintf(linestr, "%d", line); - fprintf(f->f, "%s[%ld]: File %s, Line %s (%s): ", + if (asprintf(&msg, "%s %s[%ld]: File %s, Line %s (%s): ", + date, term_color(tmp, levels[level], colors[level], 0, sizeof(tmp)), (long)pthread_self(), term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)), term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)), - term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4))); + term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4)) + ) != -1) { + ast_verbose(msg); + } } va_start(ap, fmt); vfprintf(f->f, fmt, ap); @@ -479,7 +478,8 @@ last = m; } else { msgcnt--; - ast_log(LOG_ERROR, "Out of memory\n"); + /* Because ast_log can call ast_verbose, this could get recursive. */ + /* ast_log(LOG_ERROR, "Out of memory\n"); */ free(m); } } Index: term.c =================================================================== RCS file: /usr/cvsroot/asterisk/term.c,v retrieving revision 1.3 diff -u -r1.3 term.c --- term.c 22 Oct 2003 03:04:45 -0000 1.3 +++ term.c 11 Jan 2004 21:08:55 -0000 @@ -96,6 +96,27 @@ return outbuf; } +char *term_strip(char *outbuf, char *inbuf, int maxout) +{ + char *outbuf_ptr = outbuf, *inbuf_ptr = inbuf; + + while (outbuf_ptr < outbuf + maxout) { + switch (*inbuf_ptr) { + case ESC: + while (*inbuf_ptr && (*inbuf_ptr != 'm')) + inbuf_ptr++; + break; + default: + *outbuf_ptr = *inbuf_ptr; + outbuf_ptr++; + } + if (! *inbuf_ptr) + break; + inbuf_ptr++; + } + return outbuf; +} + char *term_prompt(char *outbuf, const char *inbuf, int maxout) { if (!vt100compat) { Index: include/asterisk/term.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/term.h,v retrieving revision 1.2 diff -u -r1.2 term.h --- include/asterisk/term.h 16 Mar 2003 22:37:31 -0000 1.2 +++ include/asterisk/term.h 11 Jan 2004 21:08:55 -0000 @@ -46,6 +46,8 @@ extern char *term_color(char *outbuf, const char *inbuf, int fgcolor, int bgcolor, int maxout); +extern char *term_strip(char *outbuf, char *inbuf, int maxout); + extern char *term_prompt(char *outbuf, const char *inbuf, int maxout); extern char *term_prep(void);