Freeciv21
Develop your civilization from humble roots to a global empire
srv_log.h File Reference
#include <QString>
#include <QtGlobal>
#include "bitvector.h"
#include "support.h"
#include "fc_types.h"
#include "notify.h"
+ Include dependency graph for srv_log.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LOGLEVEL_BODYGUARD   LOG_DEBUG
 
#define LOGLEVEL_UNIT   LOG_DEBUG
 
#define LOGLEVEL_GOTO   LOG_DEBUG
 
#define LOGLEVEL_CITY   LOG_DEBUG
 
#define LOGLEVEL_BUILD   LOG_DEBUG
 
#define LOGLEVEL_HUNT   LOG_DEBUG
 
#define LOGLEVEL_PLAYER   LOG_DEBUG
 
#define LOG_AI_TEST   LOG_NORMAL
 
#define CITY_LOG(_, pcity, msg, ...)
 
#define UNIT_LOG(_, punit, msg, ...)
 
#define TIMING_LOG(timer, activity)
 
#define TIMING_RESULTS()
 

Enumerations

enum  ai_timer {
  AIT_ALL , AIT_MOVEMAP , AIT_UNITS , AIT_SETTLERS ,
  AIT_WORKERS , AIT_AIDATA , AIT_GOVERNMENT , AIT_TAXES ,
  AIT_CITIES , AIT_CITIZEN_ARRANGE , AIT_BUILDINGS , AIT_DANGER ,
  AIT_TECH , AIT_FSTK , AIT_DEFENDERS , AIT_CARAVAN ,
  AIT_HUNTER , AIT_AIRLIFT , AIT_DIPLOMAT , AIT_AIRUNIT ,
  AIT_EXPLORER , AIT_EMERGENCY , AIT_CITY_MILITARY , AIT_CITY_TERRAIN ,
  AIT_CITY_SETTLERS , AIT_ATTACK , AIT_MILITARY , AIT_RECOVER ,
  AIT_BODYGUARD , AIT_FERRY , AIT_RAMPAGE , AIT_LAST
}
 
enum  ai_timer_activity { TIMER_START , TIMER_STOP }
 

Functions

QString city_log_prefix (const city *pcity)
 Log a city, it will appear like this Polish Romenna(5,35) [s1 d106 u11 g1]. More...
 
QString unit_log_prefix (const unit *punit)
 Log a unit, it will appear like this Polish Archers[139] (5,35)->(0,0){0,0} where [] is unit id, ()->() are coordinates present and goto, and {,} contains bodyguard and ferryboat ids. More...
 
void timing_log_init ()
 Initialize AI timing system. More...
 
void timing_log_free ()
 Free AI timing system resources. More...
 
void timing_log_real (enum ai_timer timer, enum ai_timer_activity activity)
 Measure the time between the calls. More...
 
void timing_results_real ()
 Print results. More...
 

Macro Definition Documentation

◆ CITY_LOG

#define CITY_LOG (   _,
  pcity,
  msg,
  ... 
)
Value:
{ \
bool notify = pcity->server.debug; \
QString message = city_log_prefix(pcity) + QStringLiteral(" ") \
+ QString::asprintf(msg, ##__VA_ARGS__); \
if (notify) { \
qInfo().noquote() << message; \
notify_conn(nullptr, nullptr, E_AI_DEBUG, ftc_log, "%s", \
qUtf8Printable(message)); \
} else { \
qDebug().noquote() << message; \
} \
}
const struct ft_color ftc_log
QString city_log_prefix(const city *pcity)
Log a city, it will appear like this Polish Romenna(5,35) [s1 d106 u11 g1].
Definition: srv_log.cpp:43

Definition at line 80 of file srv_log.h.

◆ LOG_AI_TEST

#define LOG_AI_TEST   LOG_NORMAL

Definition at line 40 of file srv_log.h.

◆ LOGLEVEL_BODYGUARD

#define LOGLEVEL_BODYGUARD   LOG_DEBUG

Definition at line 32 of file srv_log.h.

◆ LOGLEVEL_BUILD

#define LOGLEVEL_BUILD   LOG_DEBUG

Definition at line 36 of file srv_log.h.

◆ LOGLEVEL_CITY

#define LOGLEVEL_CITY   LOG_DEBUG

Definition at line 35 of file srv_log.h.

◆ LOGLEVEL_GOTO

#define LOGLEVEL_GOTO   LOG_DEBUG

Definition at line 34 of file srv_log.h.

◆ LOGLEVEL_HUNT

#define LOGLEVEL_HUNT   LOG_DEBUG

Definition at line 37 of file srv_log.h.

◆ LOGLEVEL_PLAYER

#define LOGLEVEL_PLAYER   LOG_DEBUG

Definition at line 38 of file srv_log.h.

◆ LOGLEVEL_UNIT

#define LOGLEVEL_UNIT   LOG_DEBUG

Definition at line 33 of file srv_log.h.

◆ TIMING_LOG

#define TIMING_LOG (   timer,
  activity 
)

Definition at line 121 of file srv_log.h.

◆ TIMING_RESULTS

#define TIMING_RESULTS ( )

Definition at line 122 of file srv_log.h.

◆ UNIT_LOG

#define UNIT_LOG (   _,
  punit,
  msg,
  ... 
)
Value:
{ \
bool notify = punit->server.debug \
|| (tile_city(unit_tile(punit)) \
&& tile_city(unit_tile(punit))->server.debug); \
QString message = unit_log_prefix(punit) + QStringLiteral(" ") \
+ QString::asprintf(msg, ##__VA_ARGS__); \
if (notify) { \
qInfo().noquote() << message; \
notify_conn(nullptr, nullptr, E_AI_DEBUG, ftc_log, "%s", \
qUtf8Printable(message)); \
} else { \
qDebug().noquote() << message; \
} \
}
QString unit_log_prefix(const unit *punit)
Log a unit, it will appear like this Polish Archers[139] (5,35)->(0,0){0,0} where [] is unit id,...
Definition: srv_log.cpp:61
struct city::@15::@17 server
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
Definition: tile.cpp:72
#define unit_tile(_pu)
Definition: unit.h:371

Definition at line 95 of file srv_log.h.

Enumeration Type Documentation

◆ ai_timer

enum ai_timer
Enumerator
AIT_ALL 
AIT_MOVEMAP 
AIT_UNITS 
AIT_SETTLERS 
AIT_WORKERS 
AIT_AIDATA 
AIT_GOVERNMENT 
AIT_TAXES 
AIT_CITIES 
AIT_CITIZEN_ARRANGE 
AIT_BUILDINGS 
AIT_DANGER 
AIT_TECH 
AIT_FSTK 
AIT_DEFENDERS 
AIT_CARAVAN 
AIT_HUNTER 
AIT_AIRLIFT 
AIT_DIPLOMAT 
AIT_AIRUNIT 
AIT_EXPLORER 
AIT_EMERGENCY 
AIT_CITY_MILITARY 
AIT_CITY_TERRAIN 
AIT_CITY_SETTLERS 
AIT_ATTACK 
AIT_MILITARY 
AIT_RECOVER 
AIT_BODYGUARD 
AIT_FERRY 
AIT_RAMPAGE 
AIT_LAST 

Definition at line 42 of file srv_log.h.

◆ ai_timer_activity

Enumerator
TIMER_START 
TIMER_STOP 

Definition at line 77 of file srv_log.h.

Function Documentation

◆ city_log_prefix()

QString city_log_prefix ( const city pcity)

Log a city, it will appear like this Polish Romenna(5,35) [s1 d106 u11 g1].

Definition at line 43 of file srv_log.cpp.

◆ timing_log_free()

void timing_log_free ( )

Free AI timing system resources.

Definition at line 177 of file srv_log.cpp.

Referenced by server_quit().

◆ timing_log_init()

void timing_log_init ( )

Initialize AI timing system.

Definition at line 163 of file srv_log.cpp.

Referenced by srv_init().

◆ timing_log_real()

void timing_log_real ( enum ai_timer  timer,
enum ai_timer_activity  activity 
)

Measure the time between the calls.

Used to see where in the AI too much CPU is being used.

Definition at line 86 of file srv_log.cpp.

◆ timing_results_real()

void timing_results_real ( )

Print results.

Definition at line 114 of file srv_log.cpp.

◆ unit_log_prefix()

QString unit_log_prefix ( const unit punit)

Log a unit, it will appear like this Polish Archers[139] (5,35)->(0,0){0,0} where [] is unit id, ()->() are coordinates present and goto, and {,} contains bodyguard and ferryboat ids.

Definition at line 61 of file srv_log.cpp.