logging: Try to improve common operations

This adds sugar for logging `Result`s with a handler, makes names evoke something closer to "logging" than "warning", tries to remove any redundant `Logging` where the module name will do, and introduces a type strictly for bad things happening.
This commit is contained in:
Dorota Czaplejewicz
2020-01-16 15:57:46 +00:00
parent f3d852f552
commit ea84f4f031
5 changed files with 168 additions and 89 deletions

View File

@ -19,6 +19,7 @@
/*! CSS data loading. */
use std::env;
use ::logging;
use glib::object::ObjectExt;
use logging::Warn;
@ -94,15 +95,13 @@ fn get_theme_name(settings: &gtk::Settings) -> GtkTheme {
None => GtkTheme {
name: {
settings.get_property("gtk-theme-name")
// maybe TODO: is this worth a warning?
.or_warn("No theme name")
.or_print(logging::Problem::Surprise, "No theme name")
.and_then(|value| value.get::<String>())
.unwrap_or(DEFAULT_THEME_NAME.into())
},
variant: {
settings.get_property("gtk-application-prefer-dark-theme")
// maybe TODO: is this worth a warning?
.or_warn("No settings key")
.or_print(logging::Problem::Surprise, "No settings key")
.and_then(|value| value.get::<bool>())
.and_then(|dark_preferred| match dark_preferred {
true => Some("dark".into()),