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.13 by root, Mon May 28 21:21:40 2007 UTC vs.
Revision 1.14 by root, Sat Jun 9 23:18:17 2007 UTC

32 int level = flags & 15; 32 int level = flags & 15;
33 33
34 if (level > settings.debug) 34 if (level > settings.debug)
35 return; 35 return;
36 36
37 char msec[20];
38 char buf[20460];
39 char tbuf[20480]; 37 char buf[20480];
40 38
41 struct timeval tv; 39 struct timeval tv;
42 gettimeofday (&tv, 0); 40 gettimeofday (&tv, 0);
43 struct tm *ptime = localtime (&tv.tv_sec); 41 struct tm *ptime = localtime (&tv.tv_sec);
44 42
45 strftime (tbuf, sizeof (tbuf), "%Y-%m-%d %H:%M:%S", ptime); 43 int len = strftime (buf, sizeof (buf) - 7, "%Y-%m-%d %H:%M:%S", ptime);
46 sprintf (msec, ".%03d ", (int)(tv.tv_usec / 1000)); 44 len += sprintf (buf + len, ".%04d ", (int)(tv.tv_usec / 100));
47 45
48 va_list ap; 46 va_list ap;
49 va_start (ap, format); 47 va_start (ap, format);
50 vsnprintf (buf, sizeof (buf), format, ap); 48 len += vsnprintf (buf + len, sizeof (buf) - len, format, ap);
51 va_end (ap); 49 va_end (ap);
52 50
53 strncat (tbuf, msec, sizeof (tbuf)); 51 len = min (sizeof (buf) - 1, len);
54 strncat (tbuf, buf, sizeof (tbuf));
55 52
56 fputs (tbuf, logfile); 53 if (buf [len - 1] != '\n')
54 buf [len++] = '\n'; // not 0-terminated
55
56 write (STDERR_FILENO, buf, len);
57 if (logfile != stderr) 57 if (logfile != stderr)
58 fputs (tbuf, stderr); 58 fwrite (buf, 1, len, logfile);
59 59
60 if (flags & logBacktrace) 60 if (flags & logBacktrace)
61 log_backtrace (tbuf); 61 log_backtrace (buf);
62} 62}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines