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.3 by root, Tue Aug 29 08:01:35 2006 UTC vs.
Revision 1.4 by root, Sun Sep 10 16:00:23 2006 UTC

1
1/* 2/*
2 * static char *rcsid_loger_c = 3 * static char *rcsid_loger_c =
3 * "$Id: logger.C,v 1.3 2006/08/29 08:01:35 root Exp $ "; 4 * "$Id: logger.C,v 1.4 2006/09/10 16:00:23 root Exp $ ";
4 */ 5 */
5 6
6/* 7/*
7 CrossFire, A Multiplayer game for X-windows 8 CrossFire, A Multiplayer game for X-windows
8 9
38 * 39 *
39 * See include/logger.h for possible logLevels. Messages with llevInfo 40 * See include/logger.h for possible logLevels. Messages with llevInfo
40 * and llevError are always printed, regardless of debug mode. 41 * and llevError are always printed, regardless of debug mode.
41 */ 42 */
42 43
44void
43void LOG (LogLevel logLevel, const char *format, ...) 45LOG (LogLevel logLevel, const char *format, ...)
44{ 46{
45 char buf[20480]; /* This needs to be really really big - larger 47 char buf[20480]; /* This needs to be really really big - larger
46 * than any other buffer, since that buffer may 48 * than any other buffer, since that buffer may
47 * need to be put in this one. 49 * need to be put in this one.
48 */ 50 */
49 char tbuf[20480]; 51 char tbuf[20480];
50 52
51 time_t curtime = time (NULL); 53 time_t curtime = time (NULL);
52 struct tm *ptime = localtime (&curtime); 54 struct tm *ptime = localtime (&curtime);
53 55
54 strftime (tbuf, 256, "%Y-%m-%d %H:%M:%S ", ptime); 56 strftime (tbuf, 256, "%Y-%m-%d %H:%M:%S ", ptime);
55 57
56 va_list ap; 58 va_list ap;
59
57 va_start(ap, format); 60 va_start (ap, format);
58 61
59 buf[0] = '\0'; 62 buf[0] = '\0';
60 if (logLevel <= settings.debug) 63 if (logLevel <= settings.debug)
61 { 64 {
62 vsnprintf(buf, sizeof (buf), format, ap); 65 vsnprintf (buf, sizeof (buf), format, ap);
63 strncat(tbuf, buf, 20460); 66 strncat (tbuf, buf, 20460);
64#ifdef WIN32 /* ---win32 change log handling for win32 */ 67#ifdef WIN32 /* ---win32 change log handling for win32 */
65 fputs(tbuf, logfile); /* wrote to file or stdout */ 68 fputs (tbuf, logfile); /* wrote to file or stdout */
66#ifdef DEBUG /* if we have a debug version, we want see ALL output */ 69# ifdef DEBUG /* if we have a debug version, we want see ALL output */
67 fflush(logfile); /* so flush this! */ 70 fflush (logfile); /* so flush this! */
71# endif
72 if (logfile != stderr) /* if was it a logfile wrote it to screen too */
73 fputs (tbuf, stderr);
74#else
75 fputs (tbuf, logfile);
68#endif 76#endif
69 if(logfile != stderr) /* if was it a logfile wrote it to screen too */
70 fputs(tbuf, stderr);
71#else
72 fputs(tbuf, logfile);
73#endif
74 } 77 }
75 if (!exiting && !trying_emergency_save && 78 if (!exiting && !trying_emergency_save && logLevel == llevError && ++nroferrors > MAX_ERRORS)
76 logLevel == llevError && ++nroferrors > MAX_ERRORS) { 79 {
77 exiting = 1; 80 exiting = 1;
78 if (!trying_emergency_save) 81 if (!trying_emergency_save)
79 emergency_save(0); 82 emergency_save (0);
80 } 83 }
81 va_end(ap); 84 va_end (ap);
82} 85}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines