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.5 by root, Thu Sep 14 22:33:59 2006 UTC vs.
Revision 1.7 by root, Sat Dec 30 10:16:10 2006 UTC

36 */ 36 */
37 37
38void 38void
39LOG (LogLevel logLevel, const char *format, ...) 39LOG (LogLevel logLevel, const char *format, ...)
40{ 40{
41 char buf[20480]; /* This needs to be really really big - larger
42 * than any other buffer, since that buffer may
43 * need to be put in this one.
44 */
45 char tbuf[20480];
46
47 time_t curtime = time (NULL);
48 struct tm *ptime = localtime (&curtime);
49
50 strftime (tbuf, 256, "%Y-%m-%d %H:%M:%S ", ptime);
51
52 va_list ap;
53
54 va_start (ap, format);
55
56 buf[0] = '\0';
57 if (logLevel <= settings.debug) 41 if (logLevel <= settings.debug)
58 { 42 {
43 char buf[20480]; /* This needs to be really really big - larger
44 * than any other buffer, since that buffer may
45 * need to be put in this one.
46 */
47 char tbuf[20480];
48
49 time_t curtime = time (NULL);
50 struct tm *ptime = localtime (&curtime);
51
52 strftime (tbuf, 256, "%Y-%m-%d %H:%M:%S ", ptime);
53
54 va_list ap;
55
56 va_start (ap, format);
57
59 vsnprintf (buf, sizeof (buf), format, ap); 58 vsnprintf (buf, sizeof (buf), format, ap);
60 strncat (tbuf, buf, 20460); 59 strncat (tbuf, buf, 20460);
61#ifdef WIN32 /* ---win32 change log handling for win32 */
62 fputs (tbuf, logfile); /* wrote to file or stdout */
63# ifdef DEBUG /* if we have a debug version, we want see ALL output */
64 fflush (logfile); /* so flush this! */
65# endif
66 if (logfile != stderr) /* if was it a logfile wrote it to screen too */
67 fputs (tbuf, stderr);
68#else
69 fputs (tbuf, logfile); 60 fputs (tbuf, logfile);
70#endif 61 fputs (tbuf, stderr);
62
63 va_end (ap);
71 } 64 }
72 if (!exiting && !trying_emergency_save && logLevel == llevError && ++nroferrors > MAX_ERRORS)
73 {
74 exiting = 1;
75 if (!trying_emergency_save)
76 emergency_save (0);
77 }
78 va_end (ap);
79} 65}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines