Skip to content

Commit

Permalink
gui2/log_settings: Permit disabling logdomains (log level -1)
Browse files Browse the repository at this point in the history
  • Loading branch information
irydacea committed May 2, 2018
1 parent b9dd04e commit 170b3f0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -11,6 +11,7 @@
### Miscellaneous and bug fixes
* Removed misleading tooltip text stating registered nicknames are optional for
the official MP server.
* It is now possible to disable logdomains in the Logging Options dialog.

## Version 1.14.0
### Campaigns
Expand Down
10 changes: 9 additions & 1 deletion data/gui/window/logging.cfg
@@ -1,7 +1,7 @@
#textdomain wesnoth-lib
###
### Definition of the window to select logging options.
### These first five things match the names from logging.cpp
### These first six strings match the names from logging.cpp
###
#define _NAME
"label"#enddef
Expand All @@ -13,6 +13,8 @@
"warn"#enddef
#define _ERR
"err"#enddef
#define _NONE
"none"#enddef

#define _GUI_LOGGER_RADIOS GROUP TOOLTIP
[column]
Expand Down Expand Up @@ -67,6 +69,11 @@
fixed_width = true
[/linked_group]

[linked_group]
id = {_NONE}
fixed_width = true
[/linked_group]

[tooltip]
id = "tooltip"
[/tooltip]
Expand Down Expand Up @@ -130,6 +137,7 @@
{_GUI_LOGGER_RADIOS {_INFO} ( _ "Info level logging: more information")}
{_GUI_LOGGER_RADIOS {_WARN} ( _ "Warning level logging: less information")}
{_GUI_LOGGER_RADIOS {_ERR} ( _ "Error level logging: minimum information")}
{_GUI_LOGGER_RADIOS {_NONE} ( _ "Disable logging")}

[/row]
[/grid]
Expand Down
19 changes: 12 additions & 7 deletions src/gui/dialogs/log_settings.cpp
Expand Up @@ -34,6 +34,7 @@ REGISTER_DIALOG(log_settings)
log_settings::log_settings()
{
//list of names must match those in logging.cfg
widget_id_.push_back("none");
widget_id_.push_back("err");
widget_id_.push_back("warn");
widget_id_.push_back("info");
Expand Down Expand Up @@ -77,9 +78,11 @@ void log_settings::pre_show(window& window)
group.add_member(button, this_id);
}
}
int current_sev, max_sev = widget_id_.size() - 1;
if (lg::get_log_domain_severity(this_domain, current_sev) && current_sev >= 0 && current_sev <= max_sev){
group.set_member_states(widget_id_[current_sev]);
int current_sev, max_sev = widget_id_.size();
if (lg::get_log_domain_severity(this_domain, current_sev)) {
if (current_sev <= max_sev) {
group.set_member_states(widget_id_[current_sev + 1]);
}
}
}
}
Expand All @@ -95,14 +98,16 @@ void log_settings::set_logger(const std::string log_domain)
{
std::string active_value = groups_[log_domain].get_active_member_value();

if(active_value == widget_id_[1]){ //default value, level1: warning
if(active_value == widget_id_[2]){ //default value, level1: warning
lg::set_log_domain_severity(log_domain, lg::warn());
} else if(active_value == widget_id_[3]){ //level3: debug
} else if(active_value == widget_id_[4]){ //level3: debug
lg::set_log_domain_severity(log_domain, lg::debug());
} else if(active_value == widget_id_[2]){ //level2: info
} else if(active_value == widget_id_[3]){ //level2: info
lg::set_log_domain_severity(log_domain, lg::info());
} else if(active_value == widget_id_[0]){ //level0: error
} else if(active_value == widget_id_[1]){ //level0: error
lg::set_log_domain_severity(log_domain, lg::err());
} else if(active_value == widget_id_[0]){ //level-1: disable
lg::set_log_domain_severity(log_domain, -1);
}
}

Expand Down

0 comments on commit 170b3f0

Please sign in to comment.