? asgi-timestamp-patch3.txt ? timestampstable.diff.txt Index: asterisk.c =================================================================== RCS file: /usr/cvsroot/asterisk/asterisk.c,v retrieving revision 1.125.2.5 diff -u -r1.125.2.5 asterisk.c --- asterisk.c 15 Jan 2005 19:58:41 -0000 1.125.2.5 +++ asterisk.c 11 Mar 2005 06:26:23 -0000 @@ -77,6 +77,7 @@ int option_nocolor; int option_dumpcore = 0; int option_cache_record_files = 0; +int option_timestamp = 0; int option_overrideconfig = 0; int option_reconnect = 0; int fully_booted = 0; @@ -1480,6 +1481,7 @@ printf(" -r Connect to Asterisk on this machine\n"); printf(" -R Connect to Asterisk, and attempt to reconnect if disconnected\n"); printf(" -t Record soundfiles in /var/tmp and move them where they belong after they are done.\n"); + printf(" -T Display the time in [Mmm dd hh:mm:ss] format for each line of output to the CLI.\n"); printf(" -v Increase verbosity (multiple v's = more verbose)\n"); printf(" -x Execute command (only valid with -r)\n"); printf("\n"); @@ -1542,6 +1544,8 @@ while(v) { if(!strcasecmp(v->name, "verbose")) { option_verbose= atoi(v->value); + } else if (!strcasecmp(v->name, "timestamp")) { + option_timestamp = ast_true(v->value); } else if (!strcasecmp(v->name, "debug")) { option_debug= ast_true(v->value); } else if (!strcasecmp(v->name, "nofork")) { @@ -1615,7 +1619,7 @@ } */ /* Check for options */ - while((c=getopt(argc, argv, "thfdvVqprRgcinx:U:G:C:")) != -1) { + while((c=getopt(argc, argv, "tThfdvVqprRgcinx:U:G:C:")) != -1) { switch(c) { case 'd': option_debug++; @@ -1652,6 +1656,9 @@ break; case 't': option_cache_record_files++; + break; + case 'T': + option_timestamp++; break; case 'x': option_exec++; Index: logger.c =================================================================== RCS file: /usr/cvsroot/asterisk/logger.c,v retrieving revision 1.45.2.3 diff -u -r1.45.2.3 logger.c --- logger.c 27 Dec 2004 22:34:25 -0000 1.45.2.3 +++ logger.c 11 Mar 2005 06:26:23 -0000 @@ -547,14 +547,23 @@ if (level != __LOG_VERBOSE) { sprintf(linestr, "%d", line); - snprintf(buf, sizeof(buf), "%s %s[%ld]: %s:%s %s: ", - date, - term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)), - (long)GETTID(), - 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))); - + if (!option_timestamp) + snprintf(buf, sizeof(buf), "%s %s[%ld]: %s:%s %s: ", + date, + term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)), + (long)GETTID(), + 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))); + else + snprintf(buf, sizeof(buf), "[%s] %s[%ld]: %s:%s %s: ", + date, + term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)), + (long)GETTID(), + 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))); + ast_console_puts(buf); va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); @@ -562,8 +571,12 @@ ast_console_puts(buf); } } else if ((chan->logmask & (1 << level)) && (chan->fileptr)) { - snprintf(buf, sizeof(buf), "%s %s[%ld]: ", date, - levels[level], (long)GETTID()); + if (!option_timestamp) + snprintf(buf, sizeof(buf), "%s %s[%ld]: ", date, + levels[level], (long)GETTID()); + else + snprintf(buf, sizeof(buf), "[%s] %s[%ld]: ", date, + levels[level], (long)GETTID()); fprintf(chan->fileptr, buf); va_start(ap, fmt); vsnprintf(buf, sizeof(buf), fmt, ap); @@ -603,9 +616,32 @@ static int replacelast = 0, complete; struct msglist *m; struct verb *v; + time_t t; + struct tm tm; + char date[256]; + char datefmt[20]; + char thestring[4096]; + va_list ap; va_start(ap, fmt); ast_mutex_lock(&msglist_lock); + time(&t); + localtime_r(&t, &tm); + strftime(date,sizeof(date),dateformat,&tm); + + if(option_timestamp){ + if(date) + sprintf(datefmt,"[%s] ", date); + else + strncpy(datefmt,date,sizeof(date)); + + vsnprintf(thestring, sizeof(thestring) -1,datefmt,ap); + pos = strlen(thestring); + + vsnprintf(thestring + pos, sizeof(thestring) - pos, fmt, ap); + + fmt = thestring; + } vsnprintf(stuff + pos, sizeof(stuff) - pos, fmt, ap); opos = pos; pos = strlen(stuff); @@ -648,7 +684,6 @@ } } /* else fprintf(stdout, stuff + opos); */ - ast_log(LOG_VERBOSE, "%s", stuff); if (fmt[strlen(fmt)-1] != '\n') Index: include/asterisk/options.h =================================================================== RCS file: /usr/cvsroot/asterisk/include/asterisk/options.h,v retrieving revision 1.9 diff -u -r1.9 options.h --- include/asterisk/options.h 7 Sep 2004 01:49:08 -0000 1.9 +++ include/asterisk/options.h 11 Mar 2005 06:26:24 -0000 @@ -29,6 +29,7 @@ extern int option_nocolor; extern int fully_booted; extern int option_cache_record_files; +extern int option_timestamp; extern char defaultlanguage[]; extern time_t ast_startuptime; extern time_t ast_lastreloadtime;