1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * 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 |
… | |
… | |
57 | #define PREFIX_LEN sizeof ("0000-00-00 00:00:00.0000+") - 1 |
57 | #define PREFIX_LEN sizeof ("0000-00-00 00:00:00.0000+") - 1 |
58 | |
58 | |
59 | static void |
59 | static void |
60 | log_sync (logline &line) |
60 | log_sync (logline &line) |
61 | { |
61 | { |
62 | struct tm *lt = localtime (&line.tv.tv_sec); |
62 | struct tm lt; |
63 | char pfx [PREFIX_LEN]; |
63 | char pfx [PREFIX_LEN]; |
64 | |
64 | |
|
|
65 | localtime_r (&line.tv.tv_sec, <); |
|
|
66 | |
65 | sprintf (pfx, "%04d-%02d-%02d %02d:%02d:%02d.%04d", |
67 | sprintf (pfx, "%04d-%02d-%02d %02d:%02d:%02d.%04d", |
66 | lt->tm_year + 1900, |
68 | lt.tm_year + 1900, |
67 | lt->tm_mon + 1, |
69 | lt.tm_mon + 1, |
68 | lt->tm_mday, |
70 | lt.tm_mday, |
69 | lt->tm_hour, |
71 | lt.tm_hour, |
70 | lt->tm_min, |
72 | lt.tm_min, |
71 | lt->tm_sec, |
73 | lt.tm_sec, |
72 | (int)(line.tv.tv_usec / 100) |
74 | (int)(line.tv.tv_usec / 100) |
73 | ); |
75 | ); |
74 | |
76 | |
75 | pfx [PREFIX_LEN - 1] = line.flags & logSync ? '=' : ' '; |
77 | pfx [PREFIX_LEN - 1] = line.flags & logSync ? '=' : ' '; |
76 | |
78 | |