Freeciv-3.1: /fast/freeciv/nightly/S3_1/ai/default/ailog.h Source File

Freeciv-3.1

Loading...
Searching...
No Matches
ailog.h
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 2002 - The Freeciv Project
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.
7
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__AILOG_H
14#define FC__AILOG_H
15
16/* utility */
17#include "log.h"
18#include "support.h"
19
20/* Change these and remake to watch logs from a specific
21 part of the AI code. */
22#define LOGLEVEL_TECH LOG_DEBUG
23
24struct player;
25
26void dai_city_log(struct ai_type *ait, char *buffer, int buflength,
27 const struct city *pcity);
28void dai_unit_log(struct ai_type *ait, char *buffer, int buflength,
29 const struct unit *punit);
30
31 void real_tech_log(struct ai_type *ait, const char *file, const char *function,
32 int line, enum log_level level, bool send_notify,
33 const struct player *pplayer, struct advance *padvance,
34 const char *msg, ...)
35 fc__attribute((__format__ (__printf__, 9, 10)));
36#define TECH_LOG(ait, loglevel, pplayer, padvance, msg, ...) \
37{ \
38 bool send_notify = BV_ISSET(pplayer->server.debug, PLAYER_DEBUG_TECH); \
39 enum log_level level = (send_notify ? LOG_AI_TEST \
40 : MIN(loglevel, LOGLEVEL_TECH)); \
41 if (log_do_output_for_level(level)) { \
42 real_tech_log(ait, __FILE__, __FUNCTION__, __FC_LINE__, level, \
43 send_notify, pplayer, padvance, msg, ## __VA_ARGS__); \
44 } \
45}
46
47 void real_diplo_log(struct ai_type *ait,
48 const char *file, const char *function, int line,
49 enum log_level level, bool send_notify,
50 const struct player *pplayer,
51 const struct player *aplayer, const char *msg, ...)
52 fc__attribute((__format__ (__printf__, 9, 10)));
53#define DIPLO_LOG(ait, loglevel, pplayer, aplayer, msg, ...) \
54{ \
55 bool send_notify = BV_ISSET(pplayer->server.debug, PLAYER_DEBUG_DIPLOMACY); \
56 enum log_level level = (send_notify ? LOG_AI_TEST \
57 : MIN(loglevel, LOGLEVEL_PLAYER)); \
58 if (log_do_output_for_level(level)) { \
59 real_diplo_log(ait, __FILE__, __FUNCTION__, __FC_LINE__, level, \
60 send_notify, pplayer, aplayer, msg, ## __VA_ARGS__); \
61 } \
62}
63
64 void real_bodyguard_log(struct ai_type *ait, const char *file,
65 const char *function, int line,
66 enum log_level level, bool send_notify,
67 const struct unit *punit, const char *msg, ...)
68 fc__attribute((__format__ (__printf__, 8, 9)));
69#define BODYGUARD_LOG(ait, loglevel, punit, msg, ...) \
70{ \
71 bool send_notify = punit->server.debug; \
72 enum log_level level = (send_notify ? LOG_AI_TEST \
73 : MIN(loglevel, LOGLEVEL_BODYGUARD)); \
74 if (log_do_output_for_level(level)) { \
75 real_bodyguard_log(ait, __FILE__, __FUNCTION__, __FC_LINE__, level, \
76 send_notify, punit, \
77 msg, ## __VA_ARGS__); \
78 } \
79}
80
81#endif /* FC__AILOG_H */
real_diplo_log
void real_diplo_log(struct ai_type *ait, const char *file, const char *function, int line, enum log_level level, bool send_notify, const struct player *pplayer, const struct player *aplayer, const char *msg,...) fc__attribute((__format__(__printf__
real_tech_log
void real_tech_log(struct ai_type *ait, const char *file, const char *function, int line, enum log_level level, bool send_notify, const struct player *pplayer, struct advance *padvance, const char *msg,...) fc__attribute((__format__(__printf__
dai_unit_log
void dai_unit_log(struct ai_type *ait, char *buffer, int buflength, const struct unit *punit)
Definition ailog.c:53
real_bodyguard_log
void real_bodyguard_log(struct ai_type *ait, const char *file, const char *function, int line, enum log_level level, bool send_notify, const struct unit *punit, const char *msg,...) fc__attribute((__format__(__printf__
dai_city_log
void dai_city_log(struct ai_type *ait, char *buffer, int buflength, const struct city *pcity)
Definition ailog.c:40
punit
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
log.h
log_level
log_level
Definition log.h:28
level
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:183
advance
Definition tech.h:124
ai_type
Definition ai.h:50
city
Definition city.h:309
player
Definition player.h:249
unit
Definition unit.h:138
support.h
fc__attribute
#define fc__attribute(x)
Definition support.h:89