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)
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 ***********************************************************************/
17 #include "bitvector.h"
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
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
,
84 fc__attribute((__format__ (__printf__
, 8, 9)));
85 #define TECH_LOG(loglevel, pplayer, padvance, msg, ...) \
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__); \
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; \
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 */