ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/logger.C
(Generate patch)

Comparing deliantra/server/common/logger.C (file contents):
Revision 1.8 by pippijn, Sat Jan 6 14:42:29 2007 UTC vs.
Revision 1.9 by root, Sun Jan 7 23:10:42 2007 UTC

43 { 43 {
44 char buf[20480]; /* This needs to be really really big - larger 44 char buf[20480]; /* This needs to be really really big - larger
45 * than any other buffer, since that buffer may 45 * than any other buffer, since that buffer may
46 * need to be put in this one. 46 * need to be put in this one.
47 */ 47 */
48 char msec[20];
48 char tbuf[20480]; 49 char tbuf[80];
49 50
50 time_t curtime = time (NULL); 51 struct timeval tv;
52 gettimeofday (&tv, 0);
51 struct tm *ptime = localtime (&curtime); 53 struct tm *ptime = localtime (&tv.tv_sec);
52 54
53 strftime (tbuf, 256, "%Y-%m-%d %H:%M:%S ", ptime); 55 strftime (tbuf, sizeof (tbuf), "%Y-%m-%d %H:%M:%S", ptime);
56 sprintf (msec, ".%03d ", (int)(tv.tv_usec / 1000));
54 57
55 va_list ap; 58 va_list ap;
59 va_start (ap, format);
60 vsnprintf (buf, sizeof (buf), format, ap);
61 va_end (ap);
56 62
57 va_start (ap, format); 63 strncat (tbuf, msec, sizeof (buf));
64 strncat (tbuf, buf, sizeof (buf));
58 65
59 vsnprintf (buf, sizeof (buf), format, ap);
60 strncat (tbuf, buf, 20460);
61 fputs (tbuf, logfile); 66 fputs (tbuf, logfile);
62 fputs (tbuf, stderr); 67 fputs (tbuf, stderr);
63
64 va_end (ap);
65 } 68 }
66} 69}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines