Freeciv-3.2
|
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "deprecations.h"
#include "fciconv.h"
#include "fcintl.h"
#include "fcthread.h"
#include "mem.h"
#include "shared.h"
#include "support.h"
#include "log.h"
Go to the source code of this file.
Variables | |
static char * | log_filename = NULL |
static log_pre_callback_fn | log_pre_callback = log_real |
static log_callback_fn | log_callback = NULL |
static log_prefix_fn | log_prefix = NULL |
static fc_mutex | logfile_mutex |
static enum log_level | max_level = LOG_VERBOSE |
static enum log_level | fc_log_level = LOG_NORMAL |
static int | fc_fatal_assertions = -1 |
static char * | log_level_names [] |
const char * | nologmsg = "nologmsg:%s" |
void do_log | ( | const char * | file, |
const char * | function, | ||
int | line, | ||
bool | print_from_where, | ||
enum log_level | level, | ||
const char * | message, | ||
... | |||
) |
Unconditionally print a log message. This function is usually protected by do_log_for(). For repeat message, may wait and print instead "last message repeated ..." at some later time. Calls log_callback if not NULL, else prints to stderr.
Definition at line 514 of file log.c.
Referenced by caravan_parameter_log_real(), fc_assert_fail(), pf_path_print_real(), real_bodyguard_log(), real_city_log(), real_diplo_log(), real_tech_log(), and real_unit_log().
Deinitialize logging module.
Definition at line 270 of file log.c.
Referenced by client_exit(), con_log_close(), fcmp_deinit(), and main().
Returns the current log level.
Definition at line 322 of file log.c.
Referenced by client_start_server().
void log_init | ( | const char * | filename, |
enum log_level | initial_level, | ||
log_callback_fn | callback, | ||
log_prefix_fn | prefix, | ||
int | fatal_assertions | ||
) |
Initialise the log module. Either 'filename' or 'callback' may be NULL. If both are NULL, print to stderr. If both are non-NULL, both callback, and fprintf to file. Pass -1 for fatal_assertions to don't raise any signal on failed assertion.
Definition at line 245 of file log.c.
Referenced by client_main(), con_log_init(), fcmp_parse_cmdline(), main(), and re_parse_cmdline().
Return name of the given log level
Definition at line 330 of file log.c.
Referenced by client_start_server().
level_str should be either "0", "1", "2", "3", "4" or "4:filename" or "4:file1:file2" or "4:filename,100,200" etc
If everything goes ok, returns TRUE. If there was a parsing problem, prints to stderr, and returns FALSE.
Return in ret_level the requested level only if level_str is a simple number (like "0", "1", "2").
Also sets up the log_files data structure. Does not set fc_log_level.
Definition at line 86 of file log.c.
Referenced by client_main(), fcmp_parse_cmdline(), main(), main(), and re_parse_cmdline().
log_callback_fn log_set_callback | ( | log_callback_fn | callback | ) |
Adjust the callback function after initial log_init().
Definition at line 290 of file log.c.
Referenced by ui_init().
Adjust the logging level after initial log_init().
log_pre_callback_fn log_set_pre_callback | ( | log_pre_callback_fn | precallback | ) |
Adjust the log preparation callback function.
Definition at line 278 of file log.c.
Referenced by backtrace_deinit(), and backtrace_init().
log_prefix_fn log_set_prefix | ( | log_prefix_fn | prefix | ) |
Adjust the prefix callback function after initial log_init().
|
static |
Unconditionally print a simple string. Let the callback do its own level formatting and add a '
' if it wants.
Definition at line 366 of file log.c.
Referenced by log_real().
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 | ||
) |
Unconditionally print a log message. This function is usually protected by do_log_for().
Definition at line 403 of file log.c.
Referenced by bugreport_request(), do_log(), do_log_deprecation(), fc_assert_fail(), and ruleset_error_real().
|
static |
Definition at line 53 of file log.c.
Referenced by fc_assert_fail(), fc_assert_set_fatal(), and log_init().
|
static |
Definition at line 52 of file log.c.
Referenced by log_get_level(), log_init(), and log_set_level().
|
static |
Definition at line 41 of file log.c.
Referenced by log_init(), log_set_callback(), and log_write().
Definition at line 39 of file log.c.
Referenced by con_log_init(), log_init(), log_real(), and log_write().
|
static |
Definition at line 66 of file log.c.
Referenced by log_level_name(), and log_parse_level_str().
|
static |
Definition at line 40 of file log.c.
Referenced by log_set_pre_callback(), and vdo_log().
|
static |
Definition at line 42 of file log.c.
Referenced by con_log_init(), log_init(), log_set_prefix(), and log_write().
|
static |
Definition at line 44 of file log.c.
Referenced by log_close(), log_init(), and log_real().
|
static |
Definition at line 49 of file log.c.
Referenced by log_parse_level_str(), and send_server_access_level_settings().