The Battle for Wesnoth  1.15.13+dev
Classes | Typedefs | Functions | Variables
lg Namespace Reference

Classes

class  log_domain
 
class  log_in_progress
 
class  logger
 
class  redirect_output_setter
 Helper class to redirect the output of the logger in a certain scope. More...
 
class  scope_logger
 

Typedefs

typedef std::map< std::string, int > domain_map
 
typedef std::pair< const std::string, int > logd
 

Functions

void timestamps (bool t)
 
void precise_timestamps (bool pt)
 
loggererr ()
 
loggerwarn ()
 
loggerinfo ()
 
loggerdebug ()
 
log_domaingeneral ()
 
bool set_log_domain_severity (const std::string &name, int severity)
 
bool set_log_domain_severity (const std::string &name, const logger &lg)
 
bool get_log_domain_severity (const std::string &name, int &severity)
 
std::string list_logdomains (const std::string &filter)
 
void set_strict_severity (int severity)
 
void set_strict_severity (const logger &lg)
 
bool broke_strict ()
 
std::string get_timestamp (const std::time_t &t, const std::string &format)
 
std::string get_timespan (const std::time_t &t)
 
static void print_precise_timestamp (std::ostream &out) noexcept
 
std::stringstream & wml_error ()
 Use this logger to send errors due to deprecated WML. More...
 
std::string log_file_path ()
 Returns the path to the current log file. More...
 
void early_log_file_setup (bool disable)
 Sets up the initial temporary log file. More...
 
void enable_native_console_output ()
 Switches to using a native console instead of log file redirection. More...
 
bool using_own_console ()
 Returns true if a console was allocated by the Wesnoth process. More...
 
void finish_log_file_setup ()
 Relocates the stdout+stderr log file to the user data directory. More...
 

Variables

static domain_mapdomains
 
static int strict_level_ = -1
 
static log_domain dom ("general")
 
static bool strict_threw_ = false
 
static bool disable_redirect
 

Typedef Documentation

◆ domain_map

typedef std::map<std::string, int> lg::domain_map

Definition at line 70 of file log.cpp.

◆ logd

typedef std::pair<const std::string, int> lg::logd

Definition at line 92 of file log.hpp.

Function Documentation

◆ broke_strict()

bool lg::broke_strict ( )

Definition at line 169 of file log.cpp.

References strict_threw_.

Referenced by handle_validate_command(), and game_launcher::single_unit_test().

◆ debug()

logger & lg::debug ( )

◆ early_log_file_setup()

void lg::early_log_file_setup ( bool  disable)

Sets up the initial temporary log file.

This has to be done on demand (preferably as early as possible) from a function rather than during static initialization, otherwise things go horribly wrong as soon as we try to use the logging facilities internally for debug messages.

Definition at line 480 of file log_windows.cpp.

Referenced by finish_log_file_setup(), and main().

◆ enable_native_console_output()

void lg::enable_native_console_output ( )

Switches to using a native console instead of log file redirection.

In this mode, the log file is closed (if it was created in the first place) and output is sent directly to an attached or allocated console instead. This is used to implement the –wconsole command line option.

Using a native console instead of a file has the benefit of allowing to see output in real time or redirecting it to a user-specified file.

Definition at line 494 of file log_windows.cpp.

Referenced by filesystem::get_logs_dir(), and main().

◆ err()

logger & lg::err ( )

◆ finish_log_file_setup()

void lg::finish_log_file_setup ( )

Relocates the stdout+stderr log file to the user data directory.

This function exits the process if something goes wrong (including calling it when the user data directory isn't known yet).

Definition at line 509 of file log_windows.cpp.

References early_log_file_setup(), ERR_LS, filesystem::file_exists(), filesystem::get_logs_dir(), and filesystem::make_directory().

Referenced by filesystem::setup_user_data_dir().

◆ general()

log_domain & lg::general ( )

◆ get_log_domain_severity()

bool lg::get_log_domain_severity ( const std::string &  name,
int &  severity 
)

Definition at line 140 of file log.cpp.

Referenced by gui2::dialogs::log_settings::pre_show(), and game_config::set_debug().

◆ get_timespan()

std::string lg::get_timespan ( const std::time_t &  t)

Definition at line 180 of file log.cpp.

Referenced by wesnothd::banned::get_human_time_span(), and lg::logger::get_name().

◆ get_timestamp()

std::string lg::get_timestamp ( const std::time_t &  t,
const std::string &  format 
)

◆ info()

logger & lg::info ( )

Definition at line 88 of file log.cpp.

Referenced by server_base::async_send_error(), server_base::async_send_warning(), BOOST_AUTO_TEST_CASE(), events::chat_handler::change_logging(), check_error(), campaignd::command_line::command_line(), commandline_options::commandline_options(), addons_client::connect(), deprecated_message(), addon_info::description_translated(), addon_info::display_title_translated(), game_config::dist_channel_id(), addons_client::do_resolve_addon_dependencies(), gui2::dialogs::editor_edit_side::editor_edit_side(), ai::default_recruitment::recruitment::execute(), gui2::dialogs::mp_lobby::game_filter_reload(), help::generate_terrain_sections(), get_addon_install_info(), ai::default_recruitment::recruitment::get_cheapest_unit_cost_for_leader(), gui2::get_mp_tooltip(), lg::logger::get_name(), gui2::dialogs::addon_manager::get_status_filter_visibility(), wesnothd::server::handle_player_in_game(), campaignd::server::handle_read_from_fifo(), game_lua_kernel::impl_get_terrain_info(), intf_log(), game_config_manager::load_game_config_with_loadscreen(), luaK_exp2K(), main(), ng::depcheck::manager::manager(), gui2::dialogs::addon_manager::on_addon_select(), gui2::dialogs::addon_manager::on_selected_version_change(), gui2::dialogs::mp_connect::on_server_add(), help::unit_topic_generator::operator()(), gui2::dialogs::outro::outro(), spirit_po::catalog_metadata::parse_header(), commandline_options::parse_log_strictness(), gui2::dialogs::mp_create_game::pre_show(), gui2::dialogs::mp_lobby::process_network_data(), playmp_controller::process_oos(), events::pump(), game_events::wml_event_pump::put_wml_message(), run_campaignd(), gui2::addon_list::select_addon(), unit_type_data::set_config(), gui2::dialogs::log_settings::set_logger(), editor::map_context::set_needs_terrain_rebuild(), translation::sngettext(), gui2::dialogs::mp_create_game::sync_with_depcheck(), addon_info::translated_info(), unit_moves(), and sdl::window::window().

◆ list_logdomains()

std::string lg::list_logdomains ( const std::string &  filter)

◆ log_file_path()

std::string lg::log_file_path ( )

Returns the path to the current log file.

An empty string is returned if the log file has not been set up yet or it was disabled (e.g. by –wconsole).

Definition at line 469 of file log_windows.cpp.

Referenced by filesystem::get_logs_dir().

◆ precise_timestamps()

void lg::precise_timestamps ( bool  pt)

◆ print_precise_timestamp()

static void lg::print_precise_timestamp ( std::ostream &  out)
staticnoexcept

Definition at line 197 of file log.cpp.

References c.

Referenced by lg::log_in_progress::operator|().

◆ set_log_domain_severity() [1/2]

bool lg::set_log_domain_severity ( const std::string &  name,
int  severity 
)

◆ set_log_domain_severity() [2/2]

bool lg::set_log_domain_severity ( const std::string &  name,
const logger lg 
)

Definition at line 136 of file log.cpp.

References lg::logger::get_severity(), and set_log_domain_severity().

◆ set_strict_severity() [1/2]

void lg::set_strict_severity ( int  severity)

◆ set_strict_severity() [2/2]

void lg::set_strict_severity ( const logger lg)

Definition at line 163 of file log.cpp.

References lg::logger::get_severity(), and set_strict_severity().

◆ timestamps()

void lg::timestamps ( bool  t)

Definition at line 73 of file log.cpp.

References t, and timestamp.

Referenced by BOOST_AUTO_TEST_CASE(), lg::logger::get_name(), main(), and run_campaignd().

◆ using_own_console()

bool lg::using_own_console ( )

Returns true if a console was allocated by the Wesnoth process.

Returns false if no native console or if it was attached from a parent process.

Definition at line 504 of file log_windows.cpp.

Referenced by do_gameloop().

◆ warn()

logger & lg::warn ( )

◆ wml_error()

std::stringstream & lg::wml_error ( )

Variable Documentation

◆ disable_redirect

bool lg::disable_redirect
static

Definition at line 478 of file log_windows.cpp.

◆ dom

log_domain lg::dom("general")
static

Referenced by debug(), and general().

◆ domains

domain_map* lg::domains
static

◆ strict_level_

int lg::strict_level_ = -1
static

Definition at line 72 of file log.cpp.

◆ strict_threw_

bool lg::strict_threw_ = false
static

Definition at line 167 of file log.cpp.

Referenced by broke_strict().