Classes | |
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 |
Typedefs | |
typedef std::map< std::string, severity > | domain_map |
typedef std::pair< const std::string, severity > | logd |
Enumerations | |
enum class | severity { LG_NONE =-1 , LG_ERROR =0 , LG_WARN =1 , LG_INFO =2 , LG_DEBUG =3 } |
Functions | |
std::ostringstream & | operator<< (std::ostringstream &oss, const lg::severity severity) |
bool | is_not_log_file (const std::string &filename) |
Use the defined prefix and suffix to determine if a filename is a log file. More... | |
void | rotate_logs (const std::string &log_dir) |
Check how many log files exist and delete the oldest when there's too many. More... | |
std::string | unique_log_filename () |
Generate a unique file name using the current timestamp and a randomly generated number. More... | |
void | check_log_dir_writable () |
Checks that a dummy file can be written to and deleted from the logs directory. More... | |
void | move_log_file () |
Move the log file to another directory. More... | |
void | set_log_to_file () |
Do the initial redirection to a log file if the logs directory is writable. More... | |
utils::optional< bool > | log_dir_writable () |
Returns the result set by check_log_dir_writable(). More... | |
std::string | get_log_file_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, severity severity) |
bool | set_log_domain_severity (const std::string &name, const logger &lg) |
bool | get_log_domain_severity (const std::string &name, severity &severity) |
std::string | list_log_domains (const std::string &filter) |
void | set_strict_severity (severity severity) |
void | set_strict_severity (const logger &lg) |
bool | broke_strict () |
std::string | format_timespan (const std::chrono::seconds &span) |
TODO: we also have utils::format_timespan, which does something very similar... More... | |
void | set_log_sanitize (bool sanitize) |
toggle log sanitization More... | |
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... | |
Variables | |
static domain_map * | domains |
static severity | strict_level_ = severity::LG_NONE |
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 std::string | out_log_file_suffix = ".out" + log_file_suffix |
const unsigned | max_logs = 8 |
typedef std::map<std::string, severity> lg::domain_map |
|
strong |
bool lg::broke_strict | ( | ) |
Definition at line 400 of file log.cpp.
References strict_threw_.
Referenced by handle_validate_command(), game_launcher::pass_victory_or_defeat(), and game_launcher::single_unit_test().
void lg::check_log_dir_writable | ( | ) |
Checks that a dummy file can be written to and deleted from the logs directory.
Definition at line 146 of file log.cpp.
References filesystem::delete_file(), filesystem::file_exists(), filesystem::file_size(), filesystem::get_logs_dir(), is_log_dir_writable_, filesystem::make_directory(), and filesystem::write_file().
Referenced by move_log_file(), and set_log_to_file().
logger & lg::debug | ( | ) |
Definition at line 325 of file log.cpp.
References LG_DEBUG.
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(), 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::do_console_redirect | ( | ) |
Allocates a console if needed and redirects output to CONOUT.
Definition at line 134 of file log_windows.cpp.
Referenced by process_command_args().
logger & lg::err | ( | ) |
Definition at line 307 of file log.cpp.
References LG_ERROR.
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(), luaW_Registry::get(), preprocessor_data::get_chunk(), vconfig::get_parsed_config(), campaignd::server::handle_read_from_fifo(), server_base::hash_password(), lua_widget::impl_widget_get(), lua_widget::impl_widget_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(), luaW_Registry::set(), gui2::dialogs::log_settings::set_logger(), gui2::show_error_message(), gui2::show_transient_error_message(), and wesnothd_connection::wait_for_handshake().
std::string lg::format_timespan | ( | const std::chrono::seconds & | span | ) |
TODO: we also have utils::format_timespan, which does something very similar...
Definition at line 404 of file log.cpp.
References chrono::deconstruct_duration(), and utils::join().
Referenced by wesnothd::banned::get_human_time_span(), and wesnothd::player_status().
log_domain & lg::general | ( | ) |
Definition at line 333 of file log.cpp.
References dom.
Referenced by default_map_generator_job::default_generate_map(), deprecated_message(), gui2::show_error_message(), and gui2::show_transient_error_message().
bool lg::get_log_domain_severity | ( | const std::string & | name, |
severity & | severity | ||
) |
Definition at line 371 of file log.cpp.
References domains.
Referenced by gui2::dialogs::log_settings::pre_show(), and game_config::set_debug().
std::string lg::get_log_file_path | ( | ) |
Definition at line 285 of file log.cpp.
References log_file_suffix, and output_file_path_.
Referenced by move_log_file().
logger & lg::info | ( | ) |
Definition at line 319 of file log.cpp.
References LG_INFO.
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(), gui2::dialogs::mp_lobby::process_network_data(), playmp_controller::process_oos(), 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(), editor::terrain_palette::setup_item(), 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().
bool lg::is_not_log_file | ( | const std::string & | filename | ) |
Use the defined prefix and suffix to determine if a filename is a log file.
Definition at line 96 of file log.cpp.
References log_file_prefix, and log_file_suffix.
Referenced by rotate_logs().
std::string lg::list_log_domains | ( | const std::string & | filter | ) |
Definition at line 380 of file log.cpp.
References domains.
Referenced by gui2::dialogs::log_settings::log_settings(), process_command_args(), and run_campaignd().
utils::optional< bool > lg::log_dir_writable | ( | ) |
Returns the result set by check_log_dir_writable().
Will not be set if called before log redirection is done.
Definition at line 280 of file log.cpp.
References is_log_dir_writable_.
Referenced by do_gameloop().
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 543 of file log.cpp.
Referenced by game_events::event_handlers::add_event_handler(), 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(), cave_map_generator::cave_map_generator_job::generate_chambers(), game_lua_kernel::intf_log(), luaW_pcall(), pathfind::manager::manager(), terrain_filter::match_internal(), side_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(), and game_events::event_handler::write_config().
void lg::move_log_file | ( | ) |
Move the log file to another directory.
Used if a custom userdata directory is given as a command line option to move it to the new location.
Definition at line 178 of file log.cpp.
References check_log_dir_writable(), get_log_file_path(), filesystem::get_logs_dir(), is_log_dir_writable_, log_file_suffix, logs_dir_, out_log_file_suffix, output_file_path_, and unique_log_filename().
Referenced by filesystem::setup_user_data_dir().
std::ostringstream & lg::operator<< | ( | std::ostringstream & | oss, |
const lg::severity | severity | ||
) |
void lg::precise_timestamps | ( | bool | pt | ) |
Definition at line 305 of file log.cpp.
References precise_timestamp.
Referenced by campaignd::server::handle_read_from_fifo(), process_command_args(), and run_campaignd().
void lg::rotate_logs | ( | const std::string & | log_dir | ) |
Check how many log files exist and delete the oldest when there's too many.
Definition at line 102 of file log.cpp.
References filesystem::delete_file(), utils::erase_if(), 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().
std::string lg::sanitize_log | ( | const std::string & | logstr | ) |
Definition at line 432 of file log.cpp.
References log_sanitization.
Referenced by lg::log_in_progress::operator|().
bool lg::set_log_domain_severity | ( | const std::string & | name, |
const logger & | lg | ||
) |
Definition at line 367 of file log.cpp.
References set_log_domain_severity().
bool lg::set_log_domain_severity | ( | const std::string & | name, |
severity | severity | ||
) |
Definition at line 347 of file log.cpp.
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().
void lg::set_log_sanitize | ( | bool | sanitize | ) |
toggle log sanitization
Definition at line 428 of file log.cpp.
References log_sanitization.
Referenced by process_command_args().
void lg::set_log_to_file | ( | ) |
Do the initial redirection to a log file if the logs directory is writable.
Also performs log rotation to delete old logs. NOTE: This runs before command line arguments are processed. Therefore the log file is initially written under the default userdata directory
Definition at line 234 of file log.cpp.
References check_log_dir_writable(), filesystem::get_logs_dir(), is_log_dir_writable_, log_file_suffix, logs_dir_, out_log_file_suffix, output_file_path_, rotate_logs(), and unique_log_filename().
Referenced by process_command_args().
void lg::set_strict_severity | ( | const logger & | lg | ) |
Definition at line 394 of file log.cpp.
References set_strict_severity().
void lg::set_strict_severity | ( | severity | severity | ) |
Definition at line 390 of file log.cpp.
References strict_level_.
Referenced by handle_validate_command(), commandline_options::parse_log_strictness(), and set_strict_severity().
void lg::timestamps | ( | bool | t | ) |
Definition at line 304 of file log.cpp.
Referenced by BOOST_AUTO_TEST_CASE(), main(), and run_campaignd().
std::string lg::unique_log_filename | ( | ) |
Generate a unique file name using the current timestamp and a randomly generated number.
Definition at line 133 of file log.cpp.
References randomness::mt_rng::get_next_random(), and log_file_prefix.
Referenced by move_log_file(), and 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 141 of file log_windows.cpp.
Referenced by main().
logger & lg::warn | ( | ) |
Definition at line 313 of file log.cpp.
References LG_WARN.
Referenced by BOOST_AUTO_TEST_CASE(), events::chat_handler::change_logging(), campaignd::command_line::command_line(), commandline_options::commandline_options(), deprecated_message(), 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 |
Referenced by general().
|
static |
Definition at line 302 of file log.cpp.
Referenced by campaignd::command_line::command_line(), get_log_domain_severity(), list_log_domains(), lg::log_domain::log_domain(), commandline_options::parse_log_domains_(), and set_log_domain_severity().
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().
const std::string lg::log_file_suffix = ".log" |
Definition at line 69 of file log.hpp.
Referenced by get_log_file_path(), is_not_log_file(), move_log_file(), and set_log_to_file().
const unsigned lg::max_logs = 8 |
Definition at line 76 of file log.hpp.
Referenced by rotate_logs().
const std::string lg::out_log_file_suffix = ".out" + log_file_suffix |
Definition at line 71 of file log.hpp.
Referenced by move_log_file(), and set_log_to_file().
|
static |
Definition at line 303 of file log.cpp.
Referenced by lg::logger::operator()(), and set_strict_severity().
|
static |
Definition at line 398 of file log.cpp.
Referenced by broke_strict(), and lg::logger::operator()().