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


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


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


enum  severity { LG_ERROR =0 , LG_WARN =1 , LG_INFO =2 , LG_DEBUG =3 }


bool is_not_log_file (const std::string &fn)
 Helper function for rotate_logs. More...
void rotate_logs (const std::string &log_dir)
 Deletes old log files from the log directory. More...
std::string unique_log_filename ()
 Generates a unique log file name. More...
void check_log_dir_writable ()
void set_log_to_file ()
std::optional< bool > log_dir_writable ()
std::string & get_log_file_path ()
void set_log_file_path (const std::string &path)
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::string sanitize_log (const std::string &logstr)
std::stringstream & log_to_chat ()
 Use this to show WML errors in the ingame chat. More...
void do_console_redirect ()
 Allocates a console if needed and redirects output to CONOUT. More...
bool using_own_console ()
 Returns true if a console was allocated by the Wesnoth process. More...


static domain_mapdomains
static int strict_level_ = -1
static log_domain dom ("general")
static bool strict_threw_ = false
const std::string log_file_prefix = "wesnoth-"
const std::string log_file_suffix = ".log"
const unsigned max_logs = 8

Typedef Documentation

◆ domain_map

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

Definition at line 220 of file log.cpp.

◆ logd

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

Definition at line 114 of file log.hpp.

Enumeration Type Documentation

◆ severity


Definition at line 75 of file log.hpp.

Function Documentation

◆ broke_strict()

bool lg::broke_strict ( )

◆ check_log_dir_writable()

void lg::check_log_dir_writable ( )

◆ debug()

logger & lg::debug ( )

◆ do_console_redirect()

void lg::do_console_redirect ( )

Allocates a console if needed and redirects output to CONOUT.

Definition at line 134 of file log_windows.cpp.

Referenced by main().

◆ err()

logger & lg::err ( )

◆ general()

log_domain & lg::general ( )

◆ get_log_domain_severity()

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

Definition at line 290 of file log.cpp.

References domains.

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

◆ get_log_file_path()

std::string & lg::get_log_file_path ( )

Definition at line 200 of file log.cpp.

References output_file_path_.

◆ get_timespan()

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

Definition at line 330 of file log.cpp.

References t.

Referenced by wesnothd::banned::get_human_time_span(), and wesnothd::player_status().

◆ get_timestamp()

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

◆ info()

logger & lg::info ( )

Definition at line 238 of file log.cpp.

Referenced by ad_hoc_addon_fetch_session(), game_events::event_handlers::add_event_handler(), server_base::async_send_error(), server_base::async_send_warning(), BOOST_AUTO_TEST_CASE(), events::chat_handler::change_logging(), campaignd::command_line::command_line(), commandline_options::commandline_options(), addons_client::connect(), deprecated_message(), gui2::addon_list::describe_status(), addon_info::description_translated(), gui2::dialogs::server_info::display(), 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_init(), help::generate_terrain_sections(), get_addon_install_info(), theme::get_basic_theme_info(), ai::default_recruitment::recruitment::get_cheapest_unit_cost_for_leader(), texture::get_info(), gui2::get_mp_tooltip(), 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(), addons_client::install_addon(), intf_log(), game_config_manager::load_game_config_with_loadscreen(), 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(), gui2::dialogs::mp_lobby::open_match_history(), gui2::dialogs::mp_lobby::open_profile_url(), 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(), countdown_clock::process(), sound::music_thinker::process(), 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_side_setup(), gui2::dialogs::mp_create_game::sync_with_depcheck(), addon_info::translated_info(), unit_moves(), gui2::lobby_player_list_helper::update(), gui2::dialogs::mp_lobby::user_dialog_callback(), and sdl::window::window().

◆ is_not_log_file()

bool lg::is_not_log_file ( const std::string &  fn)

Helper function for rotate_logs.

Definition at line 86 of file log.cpp.

References log_file_prefix, and log_file_suffix.

Referenced by rotate_logs().

◆ list_logdomains()

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

Definition at line 299 of file log.cpp.

References domains.

Referenced by gui2::dialogs::log_settings::log_settings(), process_command_args(), and run_campaignd().

◆ log_dir_writable()

std::optional< bool > lg::log_dir_writable ( )

Definition at line 195 of file log.cpp.

References is_log_dir_writable_.

Referenced by do_gameloop().

◆ log_to_chat()

std::stringstream & lg::log_to_chat ( )

◆ precise_timestamps()

void lg::precise_timestamps ( bool  pt)

◆ print_precise_timestamp()

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

Definition at line 347 of file log.cpp.

References c.

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

◆ rotate_logs()

void lg::rotate_logs ( const std::string &  log_dir)

Deletes old log files from the log directory.

Definition at line 95 of file log.cpp.

References filesystem::delete_file(), ERR_LS, filesystem::get_files_in_dir(), is_not_log_file(), LOG_LS, max_logs, output_file_path_, and game_config::path.

Referenced by set_log_to_file().

◆ sanitize_log()

std::string lg::sanitize_log ( const std::string &  logstr)

Definition at line 359 of file log.cpp.

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

◆ set_log_domain_severity() [1/2]

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

Definition at line 286 of file log.cpp.

References set_log_domain_severity().

◆ set_log_domain_severity() [2/2]

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

◆ set_log_file_path()

void lg::set_log_file_path ( const std::string &  path)

Definition at line 204 of file log.cpp.

References output_file_path_, and game_config::path.

◆ set_log_to_file()

void lg::set_log_to_file ( )

◆ set_strict_severity() [1/2]

void lg::set_strict_severity ( const logger lg)

Definition at line 313 of file log.cpp.

References set_strict_severity().

◆ set_strict_severity() [2/2]

void lg::set_strict_severity ( int  severity)

◆ timestamps()

void lg::timestamps ( bool  t)

Definition at line 223 of file log.cpp.

References t, and timestamp.

Referenced by BOOST_AUTO_TEST_CASE(), main(), and run_campaignd().

◆ unique_log_filename()

std::string lg::unique_log_filename ( )

Generates a unique log file name.

Definition at line 129 of file log.cpp.

References randomness::mt_rng::get_next_random(), log_file_prefix, and log_file_suffix.

Referenced by set_log_to_file().

◆ 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 141 of file log_windows.cpp.

Referenced by do_gameloop().

◆ warn()

logger & lg::warn ( )

Variable Documentation

◆ dom

log_domain lg::dom("general") ( "general"  )

Referenced by general().

◆ domains

domain_map* lg::domains

◆ log_file_prefix

const std::string lg::log_file_prefix = "wesnoth-"

Definition at line 68 of file log.hpp.

Referenced by is_not_log_file(), and unique_log_filename().

◆ log_file_suffix

const std::string lg::log_file_suffix = ".log"

Definition at line 69 of file log.hpp.

Referenced by is_not_log_file(), and unique_log_filename().

◆ max_logs

const unsigned lg::max_logs = 8

Definition at line 73 of file log.hpp.

Referenced by rotate_logs().

◆ strict_level_

int lg::strict_level_ = -1

Definition at line 222 of file log.cpp.

Referenced by lg::logger::operator()(), and set_strict_severity().

◆ strict_threw_

bool lg::strict_threw_ = false

Definition at line 317 of file log.cpp.

Referenced by broke_strict(), and lg::logger::operator()().