| 1 | /* |
| 2 | * Copyright (C) 1999 Rob Crittenden ([email protected]) |
| 3 | * Copyright (C) 1999,2000 Ross Combs ([email protected]) |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/ |
| 20 | #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/ |
| 21 | |
| 22 | #include <cerrno> |
| 23 | #include <cstdarg> |
| 24 | #include <cstdio> |
| 25 | #include <cstring> |
| 26 | #include <ctime> |
| 27 | #include <iomanip> |
| 28 | #include <string> |
| 29 | #include <sstream> |
| 30 | |
| 31 | #include <common/format.h>cxx . . $ `<file>/src/common/format.h`/ |
| 32 | |
| 33 | #include "compat/strcasecmp.h"cxx . . $ `<file>/src/compat/strcasecmp.h`/ |
| 34 | #include "common/hexdump.h"cxx . . $ `<file>/src/common/hexdump.h`/ |
| 35 | #ifdef WIN32_GUI |
| 36 | # include "common/gui_printf.h" |
| 37 | #endif |
| 38 | #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/ |
| 39 | |
| 40 | namespace pvpgncxx . . $ pvpgn/ |
| 41 | { |
| 42 | |
| 43 | static stdcxx . . $ std/::FILEcxx . . $ std/FILE# * eventstrmcxx . . $ pvpgn/eventstrm. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:416:9`!; |
| 44 | static unsigned currlevelcxx . . $ pvpgn/currlevel. = eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug. | |
| 45 | eventlog_level_infocxx . . $ pvpgn/eventlog_level_info. | |
| 46 | eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn. | |
| 47 | eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error. | |
| 48 | eventlog_level_fatalcxx . . $ pvpgn/eventlog_level_fatal. |
| 49 | #ifdef WIN32GUI |
| 50 | | eventlog_level_gui |
| 51 | #endif |
| 52 | ; |
| 53 | /* FIXME: maybe this should be default for win32 */ |
| 54 | static int eventlog_debugmodecxx . . $ pvpgn/eventlog_debugmode. = 0; |
| 55 | |
| 56 | extern void eventlog_set_debugmodecxx . . $ pvpgn/eventlog_set_debugmode(d4f767463ce0a6b3).(int debugmode) |
| 57 | { |
| 58 | eventlog_debugmodecxx . . $ pvpgn/eventlog_debugmode. = debugmode; |
| 59 | } |
| 60 | |
| 61 | extern void eventlog_setcxx . . $ pvpgn/eventlog_set(8d4262d45fc644ab).(stdcxx . . $ std/::FILEcxx . . $ std/FILE# * fp) |
| 62 | { |
| 63 | eventstrmcxx . . $ pvpgn/eventstrm. = fp; |
| 64 | } |
| 65 | |
| 66 | extern stdcxx . . $ std/::FILEcxx . . $ std/FILE# * eventlog_getcxx . . $ pvpgn/eventlog_get(3637adb0f06093ef).(void) |
| 67 | { |
| 68 | return eventstrmcxx . . $ pvpgn/eventstrm.; |
| 69 | } |
| 70 | |
| 71 | extern int eventlog_closecxx . . $ pvpgn/eventlog_close(b126dc7c1de90089).(void) |
| 72 | { |
| 73 | stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(eventstrmcxx . . $ pvpgn/eventstrm.); |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | extern int eventlog_opencxx . . $ pvpgn/eventlog_open(5c4306d8553b3696).(char const * filename) |
| 78 | { |
| 79 | stdcxx . . $ std/::FILEcxx . . $ std/FILE# * temp; |
| 80 | |
| 81 | if (!filename) |
| 82 | { |
| 83 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL filename"); |
| 84 | return -1; |
| 85 | } |
| 86 | |
| 87 | if (!(temp = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(filename, "a"))) |
| 88 | { |
| 89 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not open file \"{}\" for appending (std::fopen: {})", filename, stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 90 | return -1; |
| 91 | } |
| 92 | |
| 93 | if (eventstrmcxx . . $ pvpgn/eventstrm. && eventstrmcxx . . $ pvpgn/eventstrm. != stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!) /* close old one */ |
| 94 | if (stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(eventstrmcxx . . $ pvpgn/eventstrm.) < 0) |
| 95 | { |
| 96 | eventstrmcxx . . $ pvpgn/eventstrm. = temp; |
| 97 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "could not close previous logfile after writing (std::fclose: {})", stdcxx . . $ std/::strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!)); |
| 98 | return 0; |
| 99 | } |
| 100 | eventstrmcxx . . $ pvpgn/eventstrm. = temp; |
| 101 | |
| 102 | return 0; |
| 103 | } |
| 104 | |
| 105 | |
| 106 | extern void eventlog_clear_levelcxx . . $ pvpgn/eventlog_clear_level(49f6e7a06ebc5aa8).(void) |
| 107 | { |
| 108 | currlevelcxx . . $ pvpgn/currlevel. = eventlog_level_nonecxx . . $ pvpgn/eventlog_level_none.; |
| 109 | } |
| 110 | |
| 111 | |
| 112 | extern int eventlog_add_levelcxx . . $ pvpgn/eventlog_add_level(5c4306d8553b3696).(char const * levelname) |
| 113 | { |
| 114 | if (!levelname) |
| 115 | { |
| 116 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL levelname"); |
| 117 | return -1; |
| 118 | } |
| 119 | |
| 120 | if (strcasecmp(levelname, "trace") == 0) |
| 121 | { |
| 122 | currlevelcxx . . $ pvpgn/currlevel. |= eventlog_level_tracecxx . . $ pvpgn/eventlog_level_trace.; |
| 123 | return 0; |
| 124 | } |
| 125 | if (strcasecmp(levelname, "debug") == 0) |
| 126 | { |
| 127 | currlevelcxx . . $ pvpgn/currlevel. |= eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug.; |
| 128 | return 0; |
| 129 | } |
| 130 | if (strcasecmp(levelname, "info") == 0) |
| 131 | { |
| 132 | currlevelcxx . . $ pvpgn/currlevel. |= eventlog_level_infocxx . . $ pvpgn/eventlog_level_info.; |
| 133 | return 0; |
| 134 | } |
| 135 | if (strcasecmp(levelname, "warn") == 0) |
| 136 | { |
| 137 | currlevelcxx . . $ pvpgn/currlevel. |= eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn.; |
| 138 | return 0; |
| 139 | } |
| 140 | if (strcasecmp(levelname, "error") == 0) |
| 141 | { |
| 142 | currlevelcxx . . $ pvpgn/currlevel. |= eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.; |
| 143 | return 0; |
| 144 | } |
| 145 | if (strcasecmp(levelname, "fatal") == 0) |
| 146 | { |
| 147 | currlevelcxx . . $ pvpgn/currlevel. |= eventlog_level_fatalcxx . . $ pvpgn/eventlog_level_fatal.; |
| 148 | return 0; |
| 149 | } |
| 150 | #ifdef WIN32_GUI |
| 151 | if (strcasecmp(levelname, "gui") == 0) |
| 152 | { |
| 153 | currlevel |= eventlog_level_gui; |
| 154 | return 0; |
| 155 | } |
| 156 | #endif |
| 157 | |
| 158 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got bad levelname \"{}\"", levelname); |
| 159 | return -1; |
| 160 | } |
| 161 | |
| 162 | |
| 163 | extern int eventlog_del_levelcxx . . $ pvpgn/eventlog_del_level(5c4306d8553b3696).(char const * levelname) |
| 164 | { |
| 165 | if (!levelname) |
| 166 | { |
| 167 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL levelname"); |
| 168 | return -1; |
| 169 | } |
| 170 | |
| 171 | if (strcasecmp(levelname, "trace") == 0) |
| 172 | { |
| 173 | currlevelcxx . . $ pvpgn/currlevel. &= ~eventlog_level_tracecxx . . $ pvpgn/eventlog_level_trace.; |
| 174 | return 0; |
| 175 | } |
| 176 | if (strcasecmp(levelname, "debug") == 0) |
| 177 | { |
| 178 | currlevelcxx . . $ pvpgn/currlevel. &= ~eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug.; |
| 179 | return 0; |
| 180 | } |
| 181 | if (strcasecmp(levelname, "info") == 0) |
| 182 | { |
| 183 | currlevelcxx . . $ pvpgn/currlevel. &= ~eventlog_level_infocxx . . $ pvpgn/eventlog_level_info.; |
| 184 | return 0; |
| 185 | } |
| 186 | if (strcasecmp(levelname, "warn") == 0) |
| 187 | { |
| 188 | currlevelcxx . . $ pvpgn/currlevel. &= ~eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn.; |
| 189 | return 0; |
| 190 | } |
| 191 | if (strcasecmp(levelname, "error") == 0) |
| 192 | { |
| 193 | currlevelcxx . . $ pvpgn/currlevel. &= ~eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.; |
| 194 | return 0; |
| 195 | } |
| 196 | if (strcasecmp(levelname, "fatal") == 0) |
| 197 | { |
| 198 | currlevelcxx . . $ pvpgn/currlevel. &= ~eventlog_level_fatalcxx . . $ pvpgn/eventlog_level_fatal.; |
| 199 | return 0; |
| 200 | } |
| 201 | #ifdef WIN32_GUI |
| 202 | if (strcasecmp(levelname, "gui") == 0) |
| 203 | { |
| 204 | currlevel &= ~eventlog_level_gui; |
| 205 | return 0; |
| 206 | } |
| 207 | #endif |
| 208 | |
| 209 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got bad levelname \"{}\"", levelname); |
| 210 | return -1; |
| 211 | } |
| 212 | |
| 213 | extern char const * eventlog_get_levelname_strcxx . . $ pvpgn/eventlog_get_levelname_str(2e91973defcccfe1).(t_eventlog_levelcxx . . $ pvpgn/t_eventlog_level# level) |
| 214 | { |
| 215 | switch (level) |
| 216 | { |
| 217 | case eventlog_level_tracecxx . . $ pvpgn/eventlog_level_trace.: |
| 218 | return "trace"; |
| 219 | case eventlog_level_debugcxx . . $ pvpgn/eventlog_level_debug.: |
| 220 | return "debug"; |
| 221 | case eventlog_level_infocxx . . $ pvpgn/eventlog_level_info.: |
| 222 | return "info "; |
| 223 | case eventlog_level_warncxx . . $ pvpgn/eventlog_level_warn.: |
| 224 | return "warn "; |
| 225 | case eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error.: |
| 226 | return "error"; |
| 227 | case eventlog_level_fatalcxx . . $ pvpgn/eventlog_level_fatal.: |
| 228 | return "fatal"; |
| 229 | #ifdef WIN32_GUI |
| 230 | case eventlog_level_gui: |
| 231 | return "gui"; |
| 232 | #endif |
| 233 | default: |
| 234 | return "unknown"; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | extern void eventlog_hexdump_datacxx . . $ pvpgn/eventlog_hexdump_data(d249e89a313417f2).(void const * data, unsigned int len) |
| 239 | { |
| 240 | unsigned int i; |
| 241 | char dst[100]; |
| 242 | unsigned char * datac; |
| 243 | |
| 244 | if (!data) { |
| 245 | eventlogcxx . . $ pvpgn/eventlog(f1d8dd72586f1e25).(eventlog_level_errorcxx . . $ pvpgn/eventlog_level_error., __FUNCTION__, "got NULL data"); |
| 246 | return; |
| 247 | } |
| 248 | |
| 249 | for (i = 0, datac = (unsigned char*)data; i < len; i += 16, datac += 16) |
| 250 | { |
| 251 | hexdump_stringcxx . . $ pvpgn/hexdump_string(c601f8efb03f3efb).(datac, (len - i < 16) ? (len - i) : 16, dst, i); |
| 252 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(eventstrmcxx . . $ pvpgn/eventstrm., "%s\n", dst); |
| 253 | #ifdef WIN32_GUI |
| 254 | if (eventlog_level_gui&currlevel) |
| 255 | gui_lvprintf(eventlog_level_info, "{}\n", dst); |
| 256 | #endif |
| 257 | if (eventlog_debugmodecxx . . $ pvpgn/eventlog_debugmode.) |
| 258 | { |
| 259 | stdcxx . . $ std/::printfcxx . . $ std/printf(581fddd72a8db8fc).("%s\n", dst); |
| 260 | } |
| 261 | |
| 262 | } |
| 263 | if (eventlog_debugmodecxx . . $ pvpgn/eventlog_debugmode.) stdcxx . . $ std/::fflushcxx . . $ std/fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 264 | stdcxx . . $ std/::fflushcxx . . $ std/fflush(89bc1efcdac0ca22).(eventstrmcxx . . $ pvpgn/eventstrm.); |
| 265 | } |
| 266 | |
| 267 | //template <typename... Args> |
| 268 | //extern void eventlog2(t_eventlog_level level, const char* module, const char* format, const Args& ... args) |
| 269 | void eventlogcxx . . $ pvpgn/eventlog(87c28105849d94ee).(t_eventlog_levelcxx . . $ pvpgn/t_eventlog_level# level, const char* module, const char* format, fmtcxx . . $ fmt/::ArgListcxx . . $ fmt/ArgList# args) |
| 270 | { |
| 271 | if (!(level & currlevelcxx . . $ pvpgn/currlevel.)) |
| 272 | { |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | if (!eventstrmcxx . . $ pvpgn/eventstrm.) |
| 277 | { |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | stdcxx . . $ std/::time_tcxx . . $ std/time_t# now = stdcxx . . $ std/::timecxx . . $ std/time(a7cd306b2d326b09).(nullptr); |
| 282 | stdcxx . . $ std/::tmcxx . . $ std/tm#* tmnow = stdcxx . . $ std/::localtimecxx . . $ std/localtime(7d91c9e5f6bb884b).(&now); |
| 283 | stdcxx . . $ std/::stringcxx . . $ std/string# timecxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).; |
| 284 | if (!tmnow) |
| 285 | { |
| 286 | time =cxx . . $ std/__cxx11/basic_string#`operator=`(978ca1133b5f6e74). "?"; |
| 287 | } |
| 288 | else |
| 289 | { |
| 290 | stdcxx . . $ std/::stringstreamcxx . . $ std/stringstream# tempcxx . . $ std/__cxx11/basic_stringstream#basic_stringstream(49f6e7a06ebc5aa8).; |
| 291 | temp <<cxx . . $ std/`operator<<`(c4ec0882ec555143). stdcxx . . $ std/::put_timecxx . . $ std/put_time(9b0daf211b76c148).(tmnow, EVENT_TIME_FORMATcxx . . $ `src/common/setup_before.h:95:9`!); |
| 292 | time =cxx . . $ std/__cxx11/basic_string#`operator=`(36befb0d0c9f966). fmtcxx . . $ fmt/::formatcxx . . $ fmt/format(9dfaebe7421e19ae).("{}"cxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08)., temp.strcxx . . $ std/__cxx11/basic_stringstream#str(d33e1a6fd36255f7).()); |
| 293 | } |
| 294 | |
| 295 | if (!module) |
| 296 | { |
| 297 | fmtcxx . . $ fmt/::printcxx . . $ fmt/print(48b87ac3cb87cdb4).(eventstrmcxx . . $ pvpgn/eventstrm., "{} [error] eventlog: got NULL module\n"cxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08)., time); |
| 298 | #ifdef WIN32_GUI |
| 299 | if (eventlog_level_gui & currlevel) |
| 300 | gui_lvprintf(eventlog_level_error, "{} [error] eventlog: got NULL module\n", time); |
| 301 | #endif |
| 302 | stdcxx . . $ std/::fflushcxx . . $ std/fflush(89bc1efcdac0ca22).(eventstrmcxx . . $ pvpgn/eventstrm.); |
| 303 | return; |
| 304 | } |
| 305 | |
| 306 | if (!format) |
| 307 | { |
| 308 | fmtcxx . . $ fmt/::printcxx . . $ fmt/print(48b87ac3cb87cdb4).(eventstrmcxx . . $ pvpgn/eventstrm., "{} [error] eventlog: got NULL fmt\n"cxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08)., time); |
| 309 | #ifdef WIN32_GUI |
| 310 | if (eventlog_level_gui&currlevel) |
| 311 | gui_lvprintf(eventlog_level_error, "{} [error] eventlog: got NULL fmt\n", time); |
| 312 | #endif |
| 313 | stdcxx . . $ std/::fflushcxx . . $ std/fflush(89bc1efcdac0ca22).(eventstrmcxx . . $ pvpgn/eventstrm.); |
| 314 | return; |
| 315 | } |
| 316 | |
| 317 | /****************************************************************/ |
| 318 | |
| 319 | try |
| 320 | { |
| 321 | fmtcxx . . $ fmt/::printcxx . . $ fmt/print(48b87ac3cb87cdb4).(eventstrmcxx . . $ pvpgn/eventstrm., "{} [{}] {}: "cxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08)., time, eventlog_get_levelname_strcxx . . $ pvpgn/eventlog_get_levelname_str(2e91973defcccfe1).(level), module); |
| 322 | #ifdef WIN32_GUI |
| 323 | if (eventlog_level_gui&currlevel) |
| 324 | { |
| 325 | gui_lvprintf(level, "{} [{}] {}: ", time, eventlog_get_levelname_str(level), module); |
| 326 | } |
| 327 | #endif |
| 328 | |
| 329 | fmtcxx . . $ fmt/::printcxx . . $ fmt/print(e8f536e71f29b79e).(eventstrmcxx . . $ pvpgn/eventstrm., formatcxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08)., args); |
| 330 | #ifdef WIN32_GUI |
| 331 | if (eventlog_level_gui & currlevel) |
| 332 | { |
| 333 | gui_lvprintf(level, format, args); |
| 334 | } |
| 335 | #endif |
| 336 | |
| 337 | fmtcxx . . $ fmt/::printcxx . . $ fmt/print(48b87ac3cb87cdb4).(eventstrmcxx . . $ pvpgn/eventstrm., "\n"cxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08).); |
| 338 | #ifdef WIN32_GUI |
| 339 | if (eventlog_level_gui & currlevel) |
| 340 | { |
| 341 | gui_lvprintf(level, "\n"); |
| 342 | } |
| 343 | #endif |
| 344 | |
| 345 | if (eventlog_debugmodecxx . . $ pvpgn/eventlog_debugmode.) |
| 346 | { |
| 347 | fmtcxx . . $ fmt/::printcxx . . $ fmt/print(c08fd8e13808dc4c).("{} [{}] {}: {}\n"cxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08)., time, eventlog_get_levelname_strcxx . . $ pvpgn/eventlog_get_levelname_str(2e91973defcccfe1).(level), module, fmtcxx . . $ fmt/::formatcxx . . $ fmt/format(d879789e7f34a190).(formatcxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08)., args)); |
| 348 | stdcxx . . $ std/::fflushcxx . . $ std/fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 349 | } |
| 350 | } |
| 351 | catch (const fmtcxx . . $ fmt/::FormatErrorcxx . . $ fmt/FormatError#& e) |
| 352 | { |
| 353 | fmtcxx . . $ fmt/::printcxx . . $ fmt/print(48b87ac3cb87cdb4).(eventstrmcxx . . $ pvpgn/eventstrm., "Failed to format string ({})\n"cxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08)., e.whatcxx . . $ std/runtime_error#what(ba32b354807b2b81).()); |
| 354 | #ifdef WIN32_GUI |
| 355 | if (eventlog_level_gui & currlevel) |
| 356 | gui_lvprintf(eventlog_level_error, "Failed to format string ({})\n", e.what()); |
| 357 | #endif |
| 358 | } |
| 359 | |
| 360 | stdcxx . . $ std/::fflushcxx . . $ std/fflush(89bc1efcdac0ca22).(eventstrmcxx . . $ pvpgn/eventstrm.); |
| 361 | } |
| 362 | |
| 363 | extern void eventlog_stepcxx . . $ pvpgn/eventlog_step(54caeed647379468).(char const * filename, t_eventlog_levelcxx . . $ pvpgn/t_eventlog_level# level, char const * module, char const * fmt, ...) |
| 364 | { |
| 365 | stdcxx . . $ std/::va_listcxx . . $ std/va_list# args; |
| 366 | char time_string[EVENT_TIME_MAXLENcxx . . $ EVENT_TIME_MAXLEN.]; |
| 367 | struct stdcxx . . $ std/::tmcxx . . $ tm# * tmnow; |
| 368 | stdcxx . . $ std/::time_tcxx . . $ std/time_t# now; |
| 369 | stdcxx . . $ std/::FILEcxx . . $ std/FILE# * fp; |
| 370 | |
| 371 | if (!(level&currlevelcxx . . $ pvpgn/currlevel.)) |
| 372 | return; |
| 373 | if (!eventstrmcxx . . $ pvpgn/eventstrm.) |
| 374 | return; |
| 375 | |
| 376 | if (!(fp = stdcxx . . $ std/::fopencxx . . $ std/fopen(82ec0787cd37e0a3).(filename, "a"))) |
| 377 | return; |
| 378 | |
| 379 | /* get the time before parsing args */ |
| 380 | stdcxx . . $ std/::timecxx . . $ std/time(a7cd306b2d326b09).(&now); |
| 381 | if (!(tmnow = stdcxx . . $ std/::localtimecxx . . $ std/localtime(7d91c9e5f6bb884b).(&now))) |
| 382 | stdcxx . . $ std/::strcpy(time_string, "?"); |
| 383 | else |
| 384 | stdcxx . . $ std/::strftimecxx . . $ std/strftime(689617e6f2fd1a9a).(time_string, EVENT_TIME_MAXLENcxx . . $ EVENT_TIME_MAXLEN., EVENT_TIME_FORMATcxx . . $ `src/common/setup_before.h:95:9`!, tmnow); |
| 385 | |
| 386 | if (!module) |
| 387 | { |
| 388 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(fp, "%s [error] eventlog_step: got NULL module\n", time_string); |
| 389 | stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fp); |
| 390 | return; |
| 391 | } |
| 392 | if (!fmt) |
| 393 | { |
| 394 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(fp, "%s [error] eventlog_step: got NULL fmt\n", time_string); |
| 395 | stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fp); |
| 396 | return; |
| 397 | } |
| 398 | |
| 399 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(fp, "%s [%s] %s: ", time_string, eventlog_get_levelname_strcxx . . $ pvpgn/eventlog_get_levelname_str(2e91973defcccfe1).(level), module); |
| 400 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, fmt); |
| 401 | stdcxx . . $ std/::vfprintfcxx . . $ std/vfprintf(bded311e54d67f9c).(fp, fmt, args); |
| 402 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args); |
| 403 | stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(fp, "\n"); |
| 404 | stdcxx . . $ std/::fclosecxx . . $ std/fclose(89bc1efcdac0ca22).(fp); |
| 405 | } |
| 406 | |
| 407 | } |