Freeciv21
Develop your civilization from humble roots to a global empire
ailog.h
Go to the documentation of this file.
1 /**************************************************************************
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  part of Freeciv21. Freeciv21 is free software: you can redistribute it
4  and/or modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation, either version 3 of the
6  License, or (at your option) any later version. You should have received
7  a copy of the GNU General Public License along with Freeciv21. If not,
8  see https://www.gnu.org/licenses/.
9 **************************************************************************/
10 #pragma once
11 
12 // utility
13 #include "support.h"
14 
15 // common
16 #include "tech.h"
17 
18 // Qt
19 #include <QLoggingCategory>
20 
21 Q_DECLARE_LOGGING_CATEGORY(ai_category)
22 
23 struct player;
24 
25 void dai_city_log(struct ai_type *ait, char *buffer, int buflength,
26  const struct city *pcity);
27 void dai_unit_log(struct ai_type *ait, char *buffer, int buflength,
28  const struct unit *punit);
29 
30 QString tech_log_prefix(ai_type *ait, const player *pplayer,
31  advance *padvance);
32 #define TECH_LOG(ait, _, pplayer, padvance, msg, ...) \
33  { \
34  bool notify = BV_ISSET(pplayer->server.debug, PLAYER_DEBUG_TECH); \
35  QString message = tech_log_prefix(ait, pplayer, padvance) \
36  + QStringLiteral(" ") \
37  + QString::asprintf(msg, ##__VA_ARGS__); \
38  if (notify) { \
39  qCInfo(ai_category).noquote() << message; \
40  notify_conn(nullptr, nullptr, E_AI_DEBUG, ftc_log, "%s", \
41  qUtf8Printable(message)); \
42  } else { \
43  qCDebug(ai_category).noquote() << message; \
44  } \
45  }
46 
47 QString diplo_log_prefix(ai_type *ait, const player *pplayer,
48  const player *aplayer);
49 #define DIPLO_LOG(ait, loglevel, pplayer, aplayer, msg, ...) \
50  { \
51  bool notify = BV_ISSET(pplayer->server.debug, PLAYER_DEBUG_DIPLOMACY); \
52  QString message = diplo_log_prefix(ait, pplayer, aplayer) \
53  + QStringLiteral(" ") \
54  + QString::asprintf(msg, ##__VA_ARGS__); \
55  if (notify) { \
56  qCInfo(ai_category).noquote() << message; \
57  notify_conn(nullptr, nullptr, E_AI_DEBUG, ftc_log, "%s", \
58  qUtf8Printable(message)); \
59  } else { \
60  qCDebug(ai_category).noquote() << message; \
61  } \
62  }
63 
64 QString bodyguard_log_prefix(ai_type *ait, const unit *punit);
65 #define BODYGUARD_LOG(ait, loglevel, punit, msg, ...) \
66  { \
67  bool notify = punit->server.debug; \
68  QString message = bodyguard_log_prefix(ait, punit) \
69  + QStringLiteral(" ") \
70  + QString::asprintf(msg, ##__VA_ARGS__); \
71  if (notify) { \
72  qCInfo(ai_category).noquote() << message; \
73  notify_conn(nullptr, nullptr, E_AI_DEBUG, ftc_log, "%s", \
74  qUtf8Printable(message)); \
75  } else { \
76  qCDebug(ai_category).noquote() << message; \
77  } \
78  }
QString diplo_log_prefix(ai_type *ait, const player *pplayer, const player *aplayer)
Log player messages, they will appear like this.
Definition: ailog.cpp:78
void dai_unit_log(struct ai_type *ait, char *buffer, int buflength, const struct unit *punit)
Produce logline fragment for srv_log.
Definition: ailog.cpp:44
QString bodyguard_log_prefix(ai_type *ait, const unit *punit)
Log message for bodyguards.
Definition: ailog.cpp:98
QString tech_log_prefix(ai_type *ait, const player *pplayer, advance *padvance)
Log player tech messages.
Definition: ailog.cpp:56
void dai_city_log(struct ai_type *ait, char *buffer, int buflength, const struct city *pcity)
Produce logline fragment for srv_log.
Definition: ailog.cpp:32
Definition: tech.h:113
Definition: ai.h:42
Definition: city.h:291
Definition: player.h:231
Definition: unit.h:134