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 |
Enumerations | |
enum | severity { LG_ERROR =0, LG_WARN =1, LG_INFO =2, LG_DEBUG =3 } |
Functions | |
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 | set_log_to_file () |
std::string & | get_log_file_path () |
void | set_log_file_path (const std::string &path) |
void | timestamps (bool t) |
void | precise_timestamps (bool pt) |
logger & | err () |
logger & | warn () |
logger & | info () |
logger & | debug () |
log_domain & | general () |
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 | 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_map * | domains |
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 |
static bool | disable_redirect |
typedef std::map<std::string, int> lg::domain_map |
enum lg::severity |
bool lg::broke_strict | ( | ) |
Definition at line 263 of file log.cpp.
References strict_threw_.
Referenced by handle_validate_command(), game_launcher::pass_victory_or_defeat(), and game_launcher::single_unit_test().
logger & lg::debug | ( | ) |
Definition at line 188 of file log.cpp.
References dom.
Referenced by BOOST_AUTO_TEST_CASE(), events::chat_handler::change_logging(), campaignd::command_line::command_line(), commandline_options::commandline_options(), lg::scope_logger::do_log_entry(), lg::scope_logger::do_log_exit(), lg::logger::get_name(), ai::ai_default_rca::get_villages_phase::get_villages(), campaignd::server::handle_read_from_fifo(), game_events::event_handlers::log_handlers(), main(), game_events::wml_event_pump::operator()(), commandline_options::parse_log_strictness(), game_events::wml_event_pump::put_wml_message(), wb::move::remove_temp_modifier(), lg::scope_logger::scope_logger(), and gui2::dialogs::log_settings::set_logger().
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 378 of file log_windows.cpp.
Referenced by finish_log_file_setup(), and main().
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 392 of file log_windows.cpp.
Referenced by main().
logger & lg::err | ( | ) |
Definition at line 170 of file log.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), events::chat_handler::change_logging(), campaignd::command_line::command_line(), commandline_options::commandline_options(), deprecated_message(), gui2::dialogs::mp_join_game::fetch_game_config(), preprocessor_data::get_chunk(), lg::logger::get_name(), vconfig::get_parsed_config(), campaignd::server::handle_read_from_fifo(), server_base::hash_password(), game_lua_kernel::impl_schedule_set(), intf_log(), intf_switch_ai(), persist_file_context::load(), game_config_manager::load_addons_cfg(), main(), commandline_options::parse_log_strictness(), network_asio::connection::poll(), game_events::wml_event_pump::put_wml_message(), savegame::read_save_file(), events::menu_handler::recall(), persist_file_context::save_context(), image::save_image(), gui2::dialogs::log_settings::set_logger(), gui2::show_error_message(), gui2::show_transient_error_message(), and wesnothd_connection::wait_for_handshake().
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 407 of file log_windows.cpp.
References early_log_file_setup(), ERR_LS, filesystem::file_exists(), filesystem::get_logs_dir(), filesystem::make_directory(), and rotate_logs().
Referenced by filesystem::setup_user_data_dir().
log_domain & lg::general | ( | ) |
Definition at line 196 of file log.cpp.
References dom.
Referenced by default_map_generator_job::default_generate_map(), deprecated_message(), lg::logger::get_name(), game_config_manager::init_game_config(), gui2::show_error_message(), and gui2::show_transient_error_message().
bool lg::get_log_domain_severity | ( | const std::string & | name, |
int & | severity | ||
) |
Definition at line 234 of file log.cpp.
Referenced by gui2::dialogs::log_settings::pre_show(), and game_config::set_debug().
std::string & lg::get_log_file_path | ( | ) |
Definition at line 144 of file log.cpp.
References output_file_path_.
Referenced by lg::logger::get_name().
std::string lg::get_timespan | ( | const std::time_t & | t | ) |
Definition at line 274 of file log.cpp.
Referenced by wesnothd::banned::get_human_time_span(), lg::logger::get_name(), and wesnothd::player_status().
std::string lg::get_timestamp | ( | const std::time_t & | t, |
const std::string & | format | ||
) |
Definition at line 267 of file log.cpp.
Referenced by preferences::get_chat_timestamp(), wesnothd::banned::get_human_end_time(), wesnothd::banned::get_human_start_time(), lg::logger::get_name(), lg::log_in_progress::operator|(), and wesnothd::server::searchlog_handler().
logger & lg::info | ( | ) |
Definition at line 182 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(), 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_init(), help::generate_terrain_sections(), get_addon_install_info(), theme::get_basic_theme_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(), 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_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(), 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(), gui2::lobby_player_list_helper::update(), and sdl::window::window().
bool lg::is_not_log_file | ( | const std::string & | fn | ) |
Helper function for rotate_logs.
Definition at line 83 of file log.cpp.
References log_file_prefix, and log_file_suffix.
Referenced by rotate_logs().
std::string lg::list_logdomains | ( | const std::string & | filter | ) |
Definition at line 243 of file log.cpp.
Referenced by gui2::dialogs::log_settings::log_settings(), process_command_args(), and run_campaignd().
std::stringstream & lg::log_to_chat | ( | ) |
Use this to show WML errors in the ingame chat.
After every WML event the errors are shown to the user so they can inform the campaign maintainer.
Definition at line 412 of file log.cpp.
Referenced by game_events::event_handlers::add_event_handler(), attack_type::add_formula_context(), name_generator_factory::add_name_generator_from_config(), events::mouse_handler::attack_enemy(), gui2::implementation::builder_stacked_widget::builder_stacked_widget(), deprecated_message(), ai::default_recruitment::recruitment::execute(), ai::configuration::expand_simplified_aspects(), unit_filter_impl::unit_filter_compound::fill(), cave_map_generator::cave_map_generator_job::generate_chambers(), get_renamed_config_attribute(), game_lua_kernel::intf_log(), luaW_pcall(), pathfind::manager::manager(), side_filter::match_internal(), terrain_filter::match_internal(), matches_simple_filter(), context_free_grammar_generator::print_nonterminal(), game_lua_kernel::run_wml_conditional(), game_events::wml_event_pump::show_wml_errors(), unit_race::unit_race(), game_events::builtin_conditions::variable_matches(), game_events::WML_HANDLER_FUNCTION(), game_events::event_handler::write_config(), and lg::scope_logger::~scope_logger().
void lg::precise_timestamps | ( | bool | pt | ) |
Definition at line 168 of file log.cpp.
References precise_timestamp.
Referenced by lg::logger::get_name(), campaignd::server::handle_read_from_fifo(), process_command_args(), and run_campaignd().
|
staticnoexcept |
Definition at line 291 of file log.cpp.
References c.
Referenced by lg::log_in_progress::operator|().
void lg::rotate_logs | ( | const std::string & | log_dir | ) |
Deletes old log files from the log directory.
Definition at line 92 of file log.cpp.
References filesystem::delete_file(), ERR_LS, filesystem::get_files_in_dir(), is_not_log_file(), LOG_LS, max_logs, and game_config::path.
Referenced by finish_log_file_setup(), and filesystem::setup_user_data_dir().
std::string lg::sanitize_log | ( | const std::string & | logstr | ) |
Definition at line 303 of file log.cpp.
Referenced by lg::logger::get_name(), and lg::log_in_progress::operator|().
bool lg::set_log_domain_severity | ( | const std::string & | name, |
int | severity | ||
) |
Definition at line 210 of file log.cpp.
References s.
Referenced by BOOST_AUTO_TEST_CASE(), events::chat_handler::change_logging(), campaignd::server::handle_read_from_fifo(), main(), process_command_args(), run_campaignd(), game_config::set_debug(), set_log_domain_severity(), and gui2::dialogs::log_settings::set_logger().
bool lg::set_log_domain_severity | ( | const std::string & | name, |
const logger & | lg | ||
) |
Definition at line 230 of file log.cpp.
References lg::logger::get_severity(), and set_log_domain_severity().
void lg::set_log_file_path | ( | const std::string & | path | ) |
Definition at line 148 of file log.cpp.
References game_config::path.
Referenced by lg::logger::get_name().
void lg::set_log_to_file | ( | ) |
Definition at line 135 of file log.cpp.
References filesystem::get_logs_dir(), filesystem::ostream_file(), output_file_, and unique_log_filename().
Referenced by main().
void lg::set_strict_severity | ( | int | severity | ) |
Definition at line 253 of file log.cpp.
Referenced by handle_validate_command(), commandline_options::parse_log_strictness(), and set_strict_severity().
void lg::set_strict_severity | ( | const logger & | lg | ) |
Definition at line 257 of file log.cpp.
References lg::logger::get_severity(), and set_strict_severity().
void lg::timestamps | ( | bool | t | ) |
Definition at line 167 of file log.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), lg::logger::get_name(), main(), and run_campaignd().
std::string lg::unique_log_filename | ( | ) |
Generates a unique log file name.
Definition at line 121 of file log.cpp.
References randomness::mt_rng::get_next_random(), log_file_prefix, and log_file_suffix.
Referenced by set_log_to_file().
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 402 of file log_windows.cpp.
Referenced by do_gameloop().
logger & lg::warn | ( | ) |
Definition at line 176 of file log.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), events::chat_handler::change_logging(), campaignd::command_line::command_line(), commandline_options::commandline_options(), deprecated_message(), lg::logger::get_name(), campaignd::server::handle_read_from_fifo(), intf_log(), main(), commandline_options::parse_log_strictness(), game_events::wml_event_pump::put_wml_message(), and gui2::dialogs::log_settings::set_logger().
|
static |
Definition at line 376 of file log_windows.cpp.
|
static |
|
static |
Definition at line 165 of file log.cpp.
Referenced by campaignd::command_line::command_line(), and commandline_options::parse_log_domains_().
const std::string lg::log_file_prefix = "wesnoth-" |
Definition at line 66 of file log.hpp.
Referenced by is_not_log_file(), and unique_log_filename().
const std::string lg::log_file_suffix = ".log" |
Definition at line 67 of file log.hpp.
Referenced by is_not_log_file(), and unique_log_filename().
const unsigned lg::max_logs = 8 |
Definition at line 71 of file log.hpp.
Referenced by rotate_logs().
|
static |
Definition at line 261 of file log.cpp.
Referenced by broke_strict().