Freeciv-3.3: /fast/freeciv/nightly/main/server/srv_log.h Source File

Freeciv-3.3

Loading...
Searching...
No Matches
srv_log.h
Go to the documentation of this file.
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.
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__SRV_LOG_H
14#define FC__SRV_LOG_H
15
16/* utility */
17#include "bitvector.h"
18#include "log.h"
19#include "support.h"
20
21/* common */
22#include "fc_types.h"
23
24struct ai_data;
25
26/*
27 * Change these and remake to watch logs from a specific
28 * part of the AI code.
29 */
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
37
38#define LOG_AI_TEST LOG_NORMAL
39
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
73};
74
75 enum ai_timer_activity {
76 TIMER_START, TIMER_STOP
77};
78
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 } \
92}
93
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); \
108 } \
109 if (log_do_output_for_level(level)) { \
110 real_unit_log(__FILE__, __FUNCTION__, __FC_LINE__, level, notify, \
111 punit, msg, ## __VA_ARGS__); \
112 } \
113}
114
115void timing_log_init(void);
116void timing_log_free(void);
117
118void timing_log_real(enum ai_timer timer, enum ai_timer_activity activity);
119void timing_results_real(void);
120
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 */
128
129#endif /* FC__SRV_LOG_H */
bitvector.h
incite_cost
char * incite_cost
Definition comments.c:74
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:74
fc_types.h
log.h
log_level
log_level
Definition log.h:28
level
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
timing_log_init
void timing_log_init(void)
Definition srv_log.c:218
real_city_log
void real_city_log(const char *file, const char *function, int line, enum log_level level, bool notify, const struct city *pcity, const char *msg,...) fc__attribute((__format__(__printf__
real_unit_log
void real_unit_log(const char *file, const char *function, int line, enum log_level level, bool notify, const struct unit *punit, const char *msg,...) fc__attribute((__format__(__printf__
ai_timer
ai_timer
Definition srv_log.h:40
AIT_RECOVER
@ AIT_RECOVER
Definition srv_log.h:68
AIT_FSTK
@ AIT_FSTK
Definition srv_log.h:54
AIT_GOVERNMENT
@ AIT_GOVERNMENT
Definition srv_log.h:47
AIT_CARAVAN
@ AIT_CARAVAN
Definition srv_log.h:56
AIT_RAMPAGE
@ AIT_RAMPAGE
Definition srv_log.h:71
AIT_CITY_MILITARY
@ AIT_CITY_MILITARY
Definition srv_log.h:63
AIT_BUILDINGS
@ AIT_BUILDINGS
Definition srv_log.h:51
AIT_TAXES
@ AIT_TAXES
Definition srv_log.h:48
AIT_ATTACK
@ AIT_ATTACK
Definition srv_log.h:66
AIT_HUNTER
@ AIT_HUNTER
Definition srv_log.h:57
AIT_BODYGUARD
@ AIT_BODYGUARD
Definition srv_log.h:69
AIT_DEFENDERS
@ AIT_DEFENDERS
Definition srv_log.h:55
AIT_SETTLERS
@ AIT_SETTLERS
Definition srv_log.h:44
AIT_UNITS
@ AIT_UNITS
Definition srv_log.h:43
AIT_CITIES
@ AIT_CITIES
Definition srv_log.h:49
AIT_AIRUNIT
@ AIT_AIRUNIT
Definition srv_log.h:60
AIT_EXPLORER
@ AIT_EXPLORER
Definition srv_log.h:61
AIT_TECH
@ AIT_TECH
Definition srv_log.h:53
AIT_CITY_TERRAIN
@ AIT_CITY_TERRAIN
Definition srv_log.h:64
AIT_FERRY
@ AIT_FERRY
Definition srv_log.h:70
AIT_MILITARY
@ AIT_MILITARY
Definition srv_log.h:67
AIT_ALL
@ AIT_ALL
Definition srv_log.h:41
AIT_MOVEMAP
@ AIT_MOVEMAP
Definition srv_log.h:42
AIT_WORKERS
@ AIT_WORKERS
Definition srv_log.h:45
AIT_DIPLOMAT
@ AIT_DIPLOMAT
Definition srv_log.h:59
AIT_LAST
@ AIT_LAST
Definition srv_log.h:72
AIT_AIDATA
@ AIT_AIDATA
Definition srv_log.h:46
AIT_AIRLIFT
@ AIT_AIRLIFT
Definition srv_log.h:58
AIT_CITIZEN_ARRANGE
@ AIT_CITIZEN_ARRANGE
Definition srv_log.h:50
AIT_CITY_SETTLERS
@ AIT_CITY_SETTLERS
Definition srv_log.h:65
AIT_DANGER
@ AIT_DANGER
Definition srv_log.h:52
AIT_EMERGENCY
@ AIT_EMERGENCY
Definition srv_log.h:62
timing_log_free
void timing_log_free(void)
Definition srv_log.c:236
timing_results_real
void timing_results_real(void)
Definition srv_log.c:157
ai_timer_activity
ai_timer_activity
Definition srv_log.h:75
TIMER_STOP
@ TIMER_STOP
Definition srv_log.h:76
TIMER_START
@ TIMER_START
Definition srv_log.h:76
timing_log_real
void timing_log_real(enum ai_timer timer, enum ai_timer_activity activity)
Definition srv_log.c:129
city
Definition city.h:320
timer
Definition timing.c:81
unit
Definition unit.h:140
support.h
fc__attribute
#define fc__attribute(x)
Definition support.h:99