1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
3 | |
3 | |
|
|
4 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | |
7 | This program is free software; you can redistribute it and/or modify |
8 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | it under the terms of the GNU General Public License as published by |
… | |
… | |
42 | { |
43 | { |
43 | char buf[20480]; /* This needs to be really really big - larger |
44 | char buf[20480]; /* This needs to be really really big - larger |
44 | * than any other buffer, since that buffer may |
45 | * than any other buffer, since that buffer may |
45 | * need to be put in this one. |
46 | * need to be put in this one. |
46 | */ |
47 | */ |
|
|
48 | char msec[20]; |
47 | char tbuf[20480]; |
49 | char tbuf[80]; |
48 | |
50 | |
49 | time_t curtime = time (NULL); |
51 | struct timeval tv; |
|
|
52 | gettimeofday (&tv, 0); |
50 | struct tm *ptime = localtime (&curtime); |
53 | struct tm *ptime = localtime (&tv.tv_sec); |
51 | |
54 | |
52 | 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)); |
53 | |
57 | |
54 | va_list ap; |
58 | va_list ap; |
|
|
59 | va_start (ap, format); |
|
|
60 | vsnprintf (buf, sizeof (buf), format, ap); |
|
|
61 | va_end (ap); |
55 | |
62 | |
56 | va_start (ap, format); |
63 | strncat (tbuf, msec, sizeof (buf)); |
|
|
64 | strncat (tbuf, buf, sizeof (buf)); |
57 | |
65 | |
58 | vsnprintf (buf, sizeof (buf), format, ap); |
|
|
59 | strncat (tbuf, buf, 20460); |
|
|
60 | fputs (tbuf, logfile); |
66 | fputs (tbuf, logfile); |
61 | fputs (tbuf, stderr); |
67 | fputs (tbuf, stderr); |
62 | |
|
|
63 | va_end (ap); |
|
|
64 | } |
68 | } |
65 | } |
69 | } |