Re: Include miliseconds in logging

"Juan Nin" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
Thank you very much Raul and Vincent who also sent me his patch!!!  :)

Juan

On Nov 29, 2007 9:42 AM, Raul Igrisan <[email protected]> wrote:
> I did it months ago against 1.4.1 release:
>
> In log.c add
> #include <sys/types.h>
> #include <sys/time.h>
>
> And modify
> static void format(char *buf, int level, const char *place, int e,
>                    const char *fmt, int with_timestamp)
> as follows:
>
> variables:
> //      time_t t;
>     struct timeval tv;
>     int millis;
>
> and the first if ()
>
>     if (with_timestamp) {
> //              time(&t);
>                 gettimeofday(&tv, NULL);
> #if LOG_TIMESTAMP_LOCALTIME
>         tm = gw_localtime(tv.tv_sec);
> #else
>         tm = gw_gmtime(tv.tv_sec);
> #endif
>                 // tv_usec is in microseconds
>                 millis = tv.tv_usec / 1000;
>         sprintf(p, "%04d-%02d-%02d %02d:%02d:%02d.%03d ",
>         tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
>         tm.tm_hour, tm.tm_min, tm.tm_sec, millis);
>
>         p = strchr(p, '\0');
>     }
>
>
>
>
> > -----Original Message-----
> > From: Juan Nin [mailto:[email protected]]
> > Sent: 28 November 2007 19:30
> > To: [email protected]
> > Subject: Include miliseconds in logging
> >
>
> > Hi!
> >
> > Sorry for this stupid question, but my C skills are very poor and I'm
> > not being able to do this correctly...
> >
> > I want to be able to see miliseconds on my logs, something like having
> > this in gwlib/log.c
> >
> >
> > sprintf(p, "%04d-%02d-%02d %02d:%02d:%02d (%d)",
> >         tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
> >         tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec);
> >
> >
> > where I added a "(%d)" and "tm.tm_usec"
> >
> > but I'm not sure where I have to modify the tm struct to include tm_usec
> > can anyone guide me on where to modifiy this?
> >
> > thnx in advance,
> >
> > Juan
> >
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.