Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
meisenzahl committed Sep 25, 2024
1 parent 3ad086a commit 6e40a64
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
10 changes: 6 additions & 4 deletions src/Helpers/LocaleHelper.vala
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ namespace LocaleHelper {
var langs = Build.LANG_LIST.split (";");

var parser = new Json.Parser ();
const string ISO_639_3_PATH = "%s/iso_639-3.json".printf (Build.ISO_CODES_LOCATION);
try {
parser.load_from_file ("%s/iso_639-3.json".printf (Build.ISO_CODES_LOCATION));
parser.load_from_file (ISO_639_3_PATH);
weak Json.Object root_object = parser.get_root ().get_object ();
weak Json.Array 639_3_array = root_object.get_array_member ("639-3");
foreach (unowned Json.Node element in 639_3_array.get_elements ()) {
Expand All @@ -73,13 +74,14 @@ namespace LocaleHelper {
}
}
} catch (Error e) {
critical (e.message);
critical ("Unable to parse '%s': %s", ISO_639_3_PATH, e.message);
}

var countries = new Gee.HashMap<string, CountryEntry?> ();
parser = new Json.Parser ();
const string ISO_3166_1_PATH = "%s/iso_3166-1.json".printf (Build.ISO_CODES_LOCATION);
try {
parser.load_from_file ("%s/iso_3166-1.json".printf (Build.ISO_CODES_LOCATION));
parser.load_from_file (ISO_3166_1_PATH);
weak Json.Object root_object = parser.get_root ().get_object ();
weak Json.Array 3166_1_array = root_object.get_array_member ("3166-1");
foreach (unowned Json.Node element in 3166_1_array.get_elements ()) {
Expand All @@ -98,7 +100,7 @@ namespace LocaleHelper {
countries[entry.alpha_2] = entry;
}
} catch (Error e) {
critical (e.message);
critical ("Unable to parse '%s': %s", ISO_3166_1_PATH, e.message);
}

foreach (var lang in langs) {
Expand Down
2 changes: 1 addition & 1 deletion src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class Installer.MainWindow : Gtk.Window {
}
});
} catch (Error e) {
warning (e.message);
warning ("Unable to query upower: %s", e.message);
battery_infobar.revealed = false;
}

Expand Down
16 changes: 8 additions & 8 deletions src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Utils {
try {
system_instance.power_off (false);
} catch (GLib.Error e) {
critical (e.message);
critical ("Unable to shutdown: %s", e.message);
}
}
}
Expand All @@ -52,7 +52,7 @@ namespace Utils {
try {
system_instance.reboot (false);
} catch (GLib.Error e) {
critical (e.message);
critical ("Unable to restart: %s", e.message);
}
}
}
Expand Down Expand Up @@ -102,7 +102,7 @@ namespace Utils {
"/org/freedesktop/login1"
);
} catch (GLib.Error e) {
warning ("%s", e.message);
warning ("Unable to get system instance: %s", e.message);
}
}
}
Expand Down Expand Up @@ -145,7 +145,7 @@ namespace Utils {
"/org/freedesktop/hostname1"
);
} catch (GLib.Error e) {
warning ("%s", e.message);
warning ("Unable to get hostname instance: %s", e.message);
}
}
}
Expand All @@ -161,7 +161,7 @@ namespace Utils {
try {
FileUtils.get_contents ("/etc/machine-id", out machine_id);
} catch (FileError e) {
warning ("%s", e.message);
warning ("Unable to get machine id: %s", e.message);
return null;
}

Expand All @@ -173,7 +173,7 @@ namespace Utils {
try {
FileUtils.get_contents ("/sys/devices/virtual/dmi/id/sys_vendor", out vendor);
} catch (FileError e) {
warning ("%s", e.message);
warning ("Unable to get sys vendor: %s", e.message);
return null;
}

Expand All @@ -185,7 +185,7 @@ namespace Utils {
try {
FileUtils.get_contents ("/sys/devices/virtual/dmi/id/product_name", out model);
} catch (FileError e) {
warning ("%s", e.message);
warning ("Unable to get product name: %s", e.message);
return null;
}

Expand All @@ -197,7 +197,7 @@ namespace Utils {
try {
FileUtils.get_contents ("/sys/devices/virtual/dmi/id/product_version", out model);
} catch (FileError e) {
warning ("%s", e.message);
warning ("Unable to get product version: %s", e.message);
return null;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Views/CheckView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class Installer.CheckView : AbstractInstallerView {
return int.parse (line);
}
} catch (Error e) {
stdout.printf ("Error: %s\n", e.message);
warning ("Unable to get frequency: %s\n", e.message);
}

return 0;
Expand All @@ -151,7 +151,7 @@ public class Installer.CheckView : AbstractInstallerView {
}
}
} catch (Error e) {
warning (e.message);
warning ("Unable to get meminfo: %s", e.message);
}

return 0;
Expand All @@ -168,7 +168,7 @@ public class Installer.CheckView : AbstractInstallerView {
}
}
} catch (Error e) {
critical (e.message);
critical ("Unable to get vm: %s", e.message);
}

return false;
Expand Down

0 comments on commit 6e40a64

Please sign in to comment.