| 1 | /* |
| 2 | * Copyright (C) 1998 Mark Baysinger ([email protected]) |
| 3 | * Copyright (C) 1998,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 | #ifndef INCLUDED_EVENTLOG_TYPES |
| 20 | #define INCLUDED_EVENTLOG_TYPES |
| 21 | |
| 22 | namespace pvpgn |
| 23 | { |
| 24 | |
| 25 | typedef enum |
| 26 | { |
| 27 | eventlog_level_none = 0, |
| 28 | eventlog_level_trace = 1, |
| 29 | eventlog_level_debug = 2, |
| 30 | eventlog_level_info = 4, |
| 31 | eventlog_level_warn = 8, |
| 32 | eventlog_level_error = 16, |
| 33 | eventlog_level_fatal = 32 |
| 34 | #ifdef WIN32_GUI |
| 35 | , eventlog_level_gui = 64 |
| 36 | #endif |
| 37 | } t_eventlog_level; |
| 38 | |
| 39 | } |
| 40 | |
| 41 | #endif |
| 42 | |
| 43 | |
| 44 | /*****/ |
| 45 | #ifndef JUST_NEED_TYPES |
| 46 | #ifndef INCLUDED_EVENTLOG_PROTOS |
| 47 | #define INCLUDED_EVENTLOG_PROTOS |
| 48 | |
| 49 | #include <cstdio> |
| 50 | #include <common/format.h> |
| 51 | |
| 52 | namespace pvpgn |
| 53 | { |
| 54 | |
| 55 | extern void eventlog_set_debugmode(int debugmode); |
| 56 | extern void eventlog_set(std::FILE * fp); |
| 57 | extern std::FILE * eventlog_get(void); |
| 58 | extern int eventlog_open(char const * filename); |
| 59 | extern int eventlog_close(void); |
| 60 | extern void eventlog_clear_level(void); |
| 61 | extern int eventlog_add_level(char const * levelname); |
| 62 | extern int eventlog_del_level(char const * levelname); |
| 63 | extern char const * eventlog_get_levelname_str(t_eventlog_level level); |
| 64 | extern void eventlog_hexdump_data(void const * data, unsigned int len); |
| 65 | |
| 66 | void eventlog(t_eventlog_level level, const char* module, const char* format, fmt::ArgList args); |
| 67 | FMT_VARIADIC(void, eventlog, t_eventlog_level, const char*, const char*) |
| 68 | //template <typename... Args> |
| 69 | // extern void eventlog2(t_eventlog_level level, const char* module, const char* format, const Args& ... args); |
| 70 | |
| 71 | extern void eventlog_step(char const * filename, t_eventlog_level level, char const * module, char const * fmt, ...) PRINTF_ATTR(4, 5); |
| 72 | |
| 73 | #define ERROR0(fmt) eventlog(eventlog_level_error,__FUNCTION__,fmt) |
| 74 | #define ERROR1(fmt,arg1) eventlog(eventlog_level_error,__FUNCTION__,fmt,arg1) |
| 75 | #define ERROR2(fmt,arg1,arg2) eventlog(eventlog_level_error,__FUNCTION__,fmt,arg1,arg2) |
| 76 | #define ERROR3(fmt,arg1,arg2,arg3) eventlog(eventlog_level_error,__FUNCTION__,fmt,arg1,arg2,arg3) |
| 77 | |
| 78 | #define WARN0(fmt) eventlog(eventlog_level_warn,__FUNCTION__,fmt) |
| 79 | #define WARN1(fmt,arg1) eventlog(eventlog_level_warn,__FUNCTION__,fmt,arg1) |
| 80 | #define WARN2(fmt,arg1,arg2) eventlog(eventlog_level_warn,__FUNCTION__,fmt,arg1,arg2) |
| 81 | #define WARN3(fmt,arg1,arg2,arg3) eventlog(eventlog_level_warn,__FUNCTION__,fmt,arg1,arg2,arg3) |
| 82 | |
| 83 | #define INFO0(fmt) eventlog(eventlog_level_info,__FUNCTION__,fmt) |
| 84 | #define INFO1(fmt,arg1) eventlog(eventlog_level_info,__FUNCTION__,fmt,arg1) |
| 85 | #define INFO2(fmt,arg1,arg2) eventlog(eventlog_level_info,__FUNCTION__,fmt,arg1,arg2) |
| 86 | #define INFO3(fmt,arg1,arg2,arg3) eventlog(eventlog_level_info,__FUNCTION__,fmt,arg1,arg2,arg3) |
| 87 | |
| 88 | #define DEBUG0(fmt) eventlog(eventlog_level_debug,__FUNCTION__,fmt) |
| 89 | #define DEBUG1(fmt,arg1) eventlog(eventlog_level_debug,__FUNCTION__,fmt,arg1) |
| 90 | #define DEBUG2(fmt,arg1,arg2) eventlog(eventlog_level_debug,__FUNCTION__,fmt,arg1,arg2) |
| 91 | #define DEBUG3(fmt,arg1,arg2,arg3) eventlog(eventlog_level_debug,__FUNCTION__,fmt,arg1,arg2,arg3) |
| 92 | |
| 93 | #define TRACE0(fmt) eventlog(eventlog_level_trace,__FUNCTION__,fmt) |
| 94 | #define TRACE1(fmt,arg1) eventlog(eventlog_level_trace,__FUNCTION__,fmt,arg1) |
| 95 | #define TRACE2(fmt,arg1,arg2) eventlog(eventlog_level_trace,__FUNCTION__,fmt,arg1,arg2) |
| 96 | #define TRACE3(fmt,arg1,arg2,arg3) eventlog(eventlog_level_trace,__FUNCTION__,fmt,arg1,arg2,arg3) |
| 97 | |
| 98 | } |
| 99 | |
| 100 | #endif |
| 101 | #endif |