Do not build gtk3.22-client by default
[freeciv.git] / server / srv_log.h
bloba88bd02d46333ec71f0d2b1424c449a27effda02
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
38 #define LOG_AI_TEST LOG_NORMAL
40 enum ai_timer {
41 AIT_ALL,
42 AIT_MOVEMAP,
43 AIT_UNITS,
44 AIT_SETTLERS,
45 AIT_WORKERS,
46 AIT_AIDATA,
47 AIT_GOVERNMENT,
48 AIT_TAXES,
49 AIT_CITIES,
50 AIT_CITIZEN_ARRANGE,
51 AIT_BUILDINGS,
52 AIT_DANGER,
53 AIT_TECH,
54 AIT_FSTK,
55 AIT_DEFENDERS,
56 AIT_CARAVAN,
57 AIT_HUNTER,
58 AIT_AIRLIFT,
59 AIT_DIPLOMAT,
60 AIT_AIRUNIT,
61 AIT_EXPLORER,
62 AIT_EMERGENCY,
63 AIT_CITY_MILITARY,
64 AIT_CITY_TERRAIN,
65 AIT_CITY_SETTLERS,
66 AIT_ATTACK,
67 AIT_MILITARY,
68 AIT_RECOVER,
69 AIT_BODYGUARD,
70 AIT_FERRY,
71 AIT_RAMPAGE,
72 AIT_LAST
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, ...) \
84 { \
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__); \
91 } \
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, ...) \
99 { \
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; \
105 notify = TRUE; \
106 } else { \
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);
121 #ifdef FREECIV_DEBUG
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 */