[Asterisk-Dev] Time stamps

Steve Brown sbrown at cortland.com
Sun Apr 6 04:07:24 MST 2003


Agreed.

Back to the drawing board.

Steve

Tilghman Lesher wrote:

>A couple thoughts on your patches:
>
>I think the prompt might could be better addressed as an asterisk
>command line option and/or environmental variable with
>formatting.  For example, username and hostname of the running
>process may be beneficial to people running multiple asterisk
>servers.  Instead of hardcoding the prompt, it should probably be
>customizable from outside the source.
>
>Ditto for the logger.  For some active servers, coding the time
>is just going to be clutter in the logs.  For other less active
>servers, it might even be good to have the date, in addition to
>the time.
>
>Also, you should probably use the POSIX gettimeofday(2),
>instead of the obsolete time(2) call.
>
>-Tilghman
>
>On Saturday 05 April 2003 19:59, Steve Brown wrote:
>  
>
>>Mark,
>>
>>Would you consider this patch too?
>>
>>Steve
>>
>>RCS file: /usr/cvsroot/asterisk/asterisk.c,v
>>retrieving revision 1.1.1.5
>>diff -u -r1.1.1.5 asterisk.c
>>--- asterisk.c  16 Mar 2003 22:37:29 -0000      1.1.1.5
>>+++ asterisk.c  6 Apr 2003 02:04:02 -0000
>>@@ -687,11 +687,15 @@
>> static char *cli_prompt(EditLine *el)
>> {
>>        char prompt[80];
>>+       time_t current;
>>+
>>+       current = time(NULL);
>>+       strftime(prompt, sizeof(prompt), "[%H:%M:%S]",
>>localtime(&current));
>>
>>        if (remotehostname)
>>-               snprintf(prompt, sizeof(prompt),
>>ASTERISK_PROMPT2, remotehostname);
>>+               snprintf(prompt + strlen(prompt),
>>sizeof(prompt), ASTERISK_PROMPT2, remotehostname);
>>        else
>>-               snprintf(prompt, sizeof(prompt),
>>ASTERISK_PROMPT); +               snprintf(prompt +
>>strlen(prompt), sizeof(prompt), ASTERISK_PROMPT);
>>
>>        return strdup(prompt);
>> }
>>Index: logger.c
>>==============================================================
>>===== RCS file: /usr/cvsroot/asterisk/logger.c,v
>>retrieving revision 1.1.1.2
>>diff -u -r1.1.1.2 logger.c
>>--- logger.c    16 Mar 2003 22:37:29 -0000      1.1.1.2
>>+++ logger.c    6 Apr 2003 02:04:03 -0000
>>@@ -296,6 +296,10 @@
>>        struct msglist *m;
>>        struct verb *v;
>>        va_list ap;
>>+       time_t current;
>>+       current = time(NULL);
>>+       strftime(stuff, sizeof(stuff), "[%H:%M:%S]",
>>localtime(&current)); +       pos = strlen(stuff);
>>        va_start(ap, fmt);
>>        ast_pthread_mutex_lock(&msglist_lock);
>>        vsnprintf(stuff + pos, sizeof(stuff) - pos, fmt, ap);
>>    
>>
>
>_______________________________________________
>Asterisk-Dev mailing list
>Asterisk-Dev at lists.digium.com
>http://lists.digium.com/mailman/listinfo/asterisk-dev
>
>  
>





More information about the asterisk-dev mailing list