diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-07-29 19:29:33 +0200 |
---|---|---|
committer | Luca Boccassi <luca.boccassi@gmail.com> | 2023-07-31 11:06:04 +0200 |
commit | 02f7f8aa4f1d0b7a24ee3cd5685a791771d9ded5 (patch) | |
tree | 09394b654dfdbcf8b1124d866765a43d25459aec | |
parent | Merge pull request #28474 from yuwata/chase-fix (diff) | |
download | systemd-02f7f8aa4f1d0b7a24ee3cd5685a791771d9ded5.tar.xz systemd-02f7f8aa4f1d0b7a24ee3cd5685a791771d9ded5.zip |
systemd-battery-check: provide more debug logs
The logs would give no hint about the answer to most interesting question: why
we decided to return true or false from the program. If we find batteries
that are low or uncertain, log at info level.
-rw-r--r-- | src/shared/battery-util.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/shared/battery-util.c b/src/shared/battery-util.c index 71ee89a549..8b7bdc704d 100644 --- a/src/shared/battery-util.c +++ b/src/shared/battery-util.c @@ -254,19 +254,28 @@ int battery_is_discharging_and_low(void) { level = battery_read_capacity_percentage(dev); if (level < 0) { + log_device_debug_errno(dev, level, "Battery capacity is unreadable: %m"); unsure = true; continue; } - if (level > BATTERY_LOW_CAPACITY_LEVEL) /* Found a charged battery */ + if (level > BATTERY_LOW_CAPACITY_LEVEL) { /* Found a charged battery */ + log_device_full(dev, + found_low ? LOG_INFO : LOG_DEBUG, + "Found battery with capacity above threshold (%d%% > %d%%).", + level, BATTERY_LOW_CAPACITY_LEVEL); return false; + } + log_device_info(dev, + "Found battery with capacity below threshold (%d%% <= %d%%).", + level, BATTERY_LOW_CAPACITY_LEVEL); found_low = true; } /* If we found a battery whose state we couldn't read, don't assume we are in low battery state */ if (unsure) { - log_debug("Found battery with unreadable state, assuming not in low battery state."); + log_info("Found battery with unreadable state, assuming not in low battery state."); return false; } |