26#define MAX_LEN_LOG_LINE 5120
40#define __FC_LINE__ __LINE__
44#define NOLOGMSG nologmsg
48 const char *
where,
const char *msg);
58typedef const char *(*log_prefix_fn)(
void);
74 const char *file,
int line);
86#define log_do_output_for_level(level) \
87 log_do_output_for_level_at_location(level, __FILE__, __FC_LINE__)
89#define log_do_output_for_level(level) (log_get_level() >= level)
94#define log_base(level, message, ...) \
95 if (log_do_output_for_level(level)) { \
96 do_log(__FILE__, __FUNCTION__, __FC_LINE__, FALSE, \
97 level, message, ## __VA_ARGS__); \
100#define log_fatal(message, ...) \
101 do_log(__FILE__, __FUNCTION__, __FC_LINE__, FALSE, \
102 LOG_FATAL, message, ## __VA_ARGS__);
103#define log_error(message, ...) \
104 log_base(LOG_ERROR, message, ## __VA_ARGS__)
105#define log_warn(message, ...) \
106 log_base(LOG_WARN, message, ## __VA_ARGS__)
107#define log_normal(message, ...) \
108 log_base(LOG_NORMAL, message, ## __VA_ARGS__)
109#define log_verbose(message, ...) \
110 log_base(LOG_VERBOSE, message, ## __VA_ARGS__)
112# define log_debug(message, ...) \
113 log_base(LOG_DEBUG, message, ## __VA_ARGS__)
115# define log_debug(message, ...)
117#ifdef FREECIV_TESTMATIC
118#define log_testmatic(message, ...) \
119 log_base(LOG_ERROR, message, ## __VA_ARGS__)
120#define log_testmatic_alt(altlvl, message, ...) \
121 log_base(LOG_ERROR, message, ## __VA_ARGS__)
123#define log_testmatic(message, ...)
124#define log_testmatic_alt(altlvl, message, ...) \
125 log_base(altlvl, message, ## __VA_ARGS__)
128#define log_va_list(level, msg, args) \
129 if (log_do_output_for_level(level)) { \
131 vdo_log(__FILE__, __FUNCTION__, __FC_LINE__, FALSE, \
132 level, __buf_, sizeof(__buf_), msg, args); \
136#define log_test log_normal
137#define log_packet log_verbose
138#define log_packet_detailed log_debug
139#define LOG_TEST LOG_NORMAL
146#define fc_assert_fail(...) (void) 0
153#define fc_assert_full(file, function, line, \
154 condition, action, message, ...) \
155 if (!(condition)) { \
156 fc_assert_fail(file, function, line, #condition, \
157 message, ## __VA_ARGS__); \
164#define fc_assert(...) (void) 0
165#define fc_assert_msg(...) (void) 0
166#define fc_assert_action(...) (void) 0
167#define fc_assert_ret(...) (void) 0
168#define fc_assert_ret_val(...) (void) 0
169#define fc_assert_exit(...) (void) 0
170#define fc_assert_action_msg(...) (void) 0
171#define fc_assert_ret_msg(...) (void) 0
172#define fc_assert_ret_val_msg(...) (void) 0
173#define fc_assert_exit_msg(...) (void) 0
176#define fc_assert(condition) \
177 ((condition) ? (void) 0 \
178 : fc_assert_fail(__FILE__, __FUNCTION__, __FC_LINE__, #condition, \
181#define fc_assert_msg(condition, message, ...) \
182 ((condition) ? (void) 0 \
183 : fc_assert_fail(__FILE__, __FUNCTION__, __FC_LINE__, \
184 #condition, message, ## __VA_ARGS__))
187#define fc_assert_action(condition, action) \
188 fc_assert_full(__FILE__, __FUNCTION__, __FC_LINE__, condition, action, \
191#define fc_assert_ret(condition) \
192 fc_assert_action(condition, return)
194#define fc_assert_ret_val(condition, val) \
195 fc_assert_action(condition, return val)
197#define fc_assert_exit(condition) \
198 fc_assert_action(condition, exit(EXIT_FAILURE))
201#define fc_assert_action_msg(condition, action, message, ...) \
202 fc_assert_full(__FILE__, __FUNCTION__, __FC_LINE__, condition, action, \
203 message, ## __VA_ARGS__)
205#define fc_assert_ret_msg(condition, message, ...) \
206 fc_assert_action_msg(condition, return, message, ## __VA_ARGS__)
208#define fc_assert_ret_val_msg(condition, val, message, ...) \
209 fc_assert_action_msg(condition, return val, message, ## __VA_ARGS__)
211#define fc_assert_exit_msg(condition, message, ...) \
212 fc_assert_action(condition, \
213 log_fatal(message, ## __VA_ARGS__); exit(EXIT_FAILURE))
217#ifdef FREECIV_CXX11_STATIC_ASSERT
218#define FC_STATIC_ASSERT(cond, tag) static_assert(cond, #tag)
221#ifdef FREECIV_C11_STATIC_ASSERT
222#define FC_STATIC_ASSERT(cond, tag) _Static_assert(cond, #tag)
224#ifdef FREECIV_STATIC_STRLEN
225#define FC_STATIC_STRLEN_ASSERT(cond, tag) FC_STATIC_ASSERT(cond, tag)
227#define FC_STATIC_STRLEN_ASSERT(cond, tag)
231#ifndef FC_STATIC_ASSERT
235#define FC_STATIC_ASSERT(cond, tag) \
236 enum { static_assert_ ## tag = 1 / (!!(cond)) }
void fc_assert_fail(const char *file, const char *function, int line, const char *assertion, const char *message,...) fc__attribute((__format__(__printf__
const char *(* log_prefix_fn)(void)
void(* log_callback_fn)(enum log_level, const char *, bool file_too)
void log_init(const char *filename, enum log_level initial_level, log_callback_fn callback, log_prefix_fn prefix, int fatal_assertions)
void fc_assert_set_fatal(int fatal_assertions)
void do_log(const char *file, const char *function, int line, bool print_from_where, enum log_level level, const char *message,...) fc__attribute((__format__(__printf__
void log_set_level(enum log_level level)
void(* log_pre_callback_fn)(enum log_level, bool print_from_where, const char *where, const char *msg)
log_callback_fn log_set_callback(log_callback_fn callback)
const char * log_level_name(enum log_level lvl)
log_pre_callback_fn log_set_pre_callback(log_pre_callback_fn precallback)
void vdo_log(const char *file, const char *function, int line, bool print_from_where, enum log_level level, char *buf, int buflen, const char *message, va_list args)
bool log_parse_level_str(const char *level_str, enum log_level *ret_level)
log_prefix_fn log_set_prefix(log_prefix_fn prefix)
enum log_level log_get_level(void)
static int fatal_assertions
struct setting_list * level[OLEVELS_NUM]