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
38 #define LOG_AI_TEST LOG_NORMAL
75 enum ai_timer_activity
{
76 TIMER_START
, TIMER_STOP
79 void real_city_log(const char *file
, const char *function
, int line
,
80 enum log_level level
, bool notify
,
81 const struct city
*pcity
, const char *msg
, ...)
82 fc__attribute((__format__ (__printf__
, 7, 8)));
83 #define CITY_LOG(loglevel, pcity, msg, ...) \
85 bool notify = pcity->server.debug; \
86 enum log_level level = (notify ? LOG_AI_TEST \
87 : MIN(loglevel, LOGLEVEL_CITY)); \
88 if (log_do_output_for_level(level)) { \
89 real_city_log(__FILE__, __FUNCTION__, __FC_LINE__, level, notify, \
90 pcity, msg, ## __VA_ARGS__); \
94 void real_unit_log(const char *file
, const char *function
, int line
,
95 enum log_level level
, bool notify
,
96 const struct unit
*punit
, const char *msg
, ...)
97 fc__attribute((__format__ (__printf__
, 7, 8)));
98 #define UNIT_LOG(loglevel, punit, msg, ...) \
100 bool notify = punit->server.debug; \
101 enum log_level level; \
102 if (!notify && tile_city(unit_tile(punit)) \
103 && tile_city(unit_tile(punit))->server.debug) { \
104 level = LOG_AI_TEST; \
107 level = MIN(loglevel, LOGLEVEL_UNIT); \
109 if (log_do_output_for_level(level)) { \
110 real_unit_log(__FILE__, __FUNCTION__, __FC_LINE__, level, notify, \
111 punit, msg, ## __VA_ARGS__); \
115 void timing_log_init(void);
116 void timing_log_free(void);
118 void timing_log_real(enum ai_timer timer
, enum ai_timer_activity activity
);
119 void timing_results_real(void);
122 #define TIMING_LOG(timer, activity) timing_log_real(timer, activity)
123 #define TIMING_RESULTS() timing_results_real()
124 #else /* FREECIV_DEBUG */
125 #define TIMING_LOG(timer, activity)
126 #define TIMING_RESULTS()
127 #endif /* FREECIV_DEBUG */
129 #endif /* FC__SRV_LOG_H */