Clarify character encoding arrangements, and stop claiming in various
[freeciv.git] / server / srv_log.h
bloba20b277b50a96b8436814401fb7c127d2d7d75cd
1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
13 #ifndef FC__SRV_LOG_H
14 #define FC__SRV_LOG_H
16 /* utility */
17 #include "bitvector.h"
18 #include "log.h"
19 #include "support.h"
21 /* common */
22 #include "fc_types.h"
24 struct ai_data;
26 /*
27 * Change these and remake to watch logs from a specific
28 * part of the AI code.
30 #define LOGLEVEL_BODYGUARD LOG_DEBUG
31 #define LOGLEVEL_UNIT LOG_DEBUG
32 #define LOGLEVEL_GOTO LOG_DEBUG
33 #define LOGLEVEL_CITY LOG_DEBUG
34 #define LOGLEVEL_BUILD LOG_DEBUG
35 #define LOGLEVEL_HUNT LOG_DEBUG
36 #define LOGLEVEL_PLAYER LOG_DEBUG
37 #define LOGLEVEL_TECH LOG_DEBUG
39 #define LOG_AI_TEST LOG_NORMAL
41 enum ai_timer {
42 AIT_ALL,
43 AIT_MOVEMAP,
44 AIT_UNITS,
45 AIT_SETTLERS,
46 AIT_WORKERS,
47 AIT_AIDATA,
48 AIT_GOVERNMENT,
49 AIT_TAXES,
50 AIT_CITIES,
51 AIT_CITIZEN_ARRANGE,
52 AIT_BUILDINGS,
53 AIT_DANGER,
54 AIT_TECH,
55 AIT_FSTK,
56 AIT_DEFENDERS,
57 AIT_CARAVAN,
58 AIT_HUNTER,
59 AIT_AIRLIFT,
60 AIT_DIPLOMAT,
61 AIT_AIRUNIT,
62 AIT_EXPLORER,
63 AIT_EMERGENCY,
64 AIT_CITY_MILITARY,
65 AIT_CITY_TERRAIN,
66 AIT_CITY_SETTLERS,
67 AIT_ATTACK,
68 AIT_MILITARY,
69 AIT_RECOVER,
70 AIT_BODYGUARD,
71 AIT_FERRY,
72 AIT_RAMPAGE,
73 AIT_LAST
76 enum ai_timer_activity {
77 TIMER_START, TIMER_STOP
80 void real_tech_log(const char *file, const char *function, int line,
81 enum log_level level, bool notify,
82 const struct player *pplayer, struct advance *padvance,
83 const char *msg, ...)
84 fc__attribute((__format__ (__printf__, 8, 9)));
85 #define TECH_LOG(loglevel, pplayer, padvance, msg, ...) \
86 { \
87 bool notify = BV_ISSET(pplayer->server.debug, PLAYER_DEBUG_TECH); \
88 enum log_level level = (notify ? LOG_AI_TEST \
89 : MIN(loglevel, LOGLEVEL_TECH)); \
90 if (log_do_output_for_level(level)) { \
91 real_tech_log(__FILE__, __FUNCTION__, __FC_LINE__, level, notify, \
92 pplayer, padvance, msg, ## __VA_ARGS__); \
93 } \
96 void real_city_log(const char *file, const char *function, int line,
97 enum log_level level, bool notify,
98 const struct city *pcity, const char *msg, ...)
99 fc__attribute((__format__ (__printf__, 7, 8)));
100 #define CITY_LOG(loglevel, pcity, msg, ...) \
102 bool notify = pcity->server.debug; \
103 enum log_level level = (notify ? LOG_AI_TEST \
104 : MIN(loglevel, LOGLEVEL_CITY)); \
105 if (log_do_output_for_level(level)) { \
106 real_city_log(__FILE__, __FUNCTION__, __FC_LINE__, level, notify, \
107 pcity, msg, ## __VA_ARGS__); \
111 void real_unit_log(const char *file, const char *function, int line,
112 enum log_level level, bool notify,
113 const struct unit *punit, const char *msg, ...)
114 fc__attribute((__format__ (__printf__, 7, 8)));
115 #define UNIT_LOG(loglevel, punit, msg, ...) \
117 bool notify = punit->server.debug; \
118 enum log_level level; \
119 if (!notify && tile_city(unit_tile(punit)) \
120 && tile_city(unit_tile(punit))->server.debug) { \
121 level = LOG_AI_TEST; \
122 notify = TRUE; \
123 } else { \
124 level = MIN(loglevel, LOGLEVEL_UNIT); \
126 if (log_do_output_for_level(level)) { \
127 real_unit_log(__FILE__, __FUNCTION__, __FC_LINE__, level, notify, \
128 punit, msg, ## __VA_ARGS__); \
132 void TIMING_LOG(enum ai_timer timer, enum ai_timer_activity activity);
133 void TIMING_RESULTS(void);
135 #endif /* FC__SRV_LOG_H */