forked from external/yambar
module/battery: use log framework
This commit is contained in:
parent
452669d6de
commit
2fdd419600
1 changed files with 8 additions and 6 deletions
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#include <libudev.h>
|
#include <libudev.h>
|
||||||
|
|
||||||
|
#define LOG_MODULE "battery"
|
||||||
|
#include "../../log.h"
|
||||||
#include "../../bar.h"
|
#include "../../bar.h"
|
||||||
|
|
||||||
enum state { STATE_FULL, STATE_CHARGING, STATE_DISCHARGING };
|
enum state { STATE_FULL, STATE_CHARGING, STATE_DISCHARGING };
|
||||||
|
@ -169,9 +171,9 @@ run(struct module_run_context *ctx)
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s: %s %s (at %.1f%% of original capacity)\n",
|
LOG_INFO("%s: %s %s (at %.1f%% of original capacity)",
|
||||||
m->battery, m->manufacturer, m->model,
|
m->battery, m->manufacturer, m->model,
|
||||||
100.0 * m->energy_full / energy_full_design);
|
100.0 * m->energy_full / energy_full_design);
|
||||||
|
|
||||||
int status_fd = openat(base_dir_fd, "status", O_RDONLY);
|
int status_fd = openat(base_dir_fd, "status", O_RDONLY);
|
||||||
assert(status_fd != -1);
|
assert(status_fd != -1);
|
||||||
|
@ -226,7 +228,7 @@ run(struct module_run_context *ctx)
|
||||||
else if (strcmp(status, "Unknown") == 0)
|
else if (strcmp(status, "Unknown") == 0)
|
||||||
m->state = STATE_DISCHARGING;
|
m->state = STATE_DISCHARGING;
|
||||||
else {
|
else {
|
||||||
printf("unrecognized battery state: %s\n", status);
|
LOG_ERR("unrecognized battery state: %s", status);
|
||||||
m->state = STATE_DISCHARGING;
|
m->state = STATE_DISCHARGING;
|
||||||
assert(false && "unrecognized battery state");
|
assert(false && "unrecognized battery state");
|
||||||
}
|
}
|
||||||
|
@ -235,8 +237,8 @@ run(struct module_run_context *ctx)
|
||||||
m->energy = readint_from_fd(energy_fd);
|
m->energy = readint_from_fd(energy_fd);
|
||||||
m->power = readint_from_fd(power_fd);
|
m->power = readint_from_fd(power_fd);
|
||||||
|
|
||||||
//printf("capacity: %lu, energy: %lu, power: %lu\n",
|
LOG_DBG("capacity: %lu, energy: %lu, power: %lu",
|
||||||
// m->capacity, m->energy, m->power);
|
m->capacity, m->energy, m->power);
|
||||||
|
|
||||||
bar->refresh(bar);
|
bar->refresh(bar);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue