prettier logger

This commit is contained in:
2025-12-22 14:06:40 +01:00
parent d35be78720
commit d4c7ffdfc1
8 changed files with 44 additions and 30 deletions

View File

@@ -43,13 +43,13 @@ struct Sensors {
};
void sighandler(int) {
log(LOG::WRN, "Signal", "got SIGINT/SIGTERM, exiting...");
log(LOG::WRN, "got SIGINT/SIGTERM, exiting...");
sem::main.release();
sem::display.release();
}
void hassThread(std::stop_token st, Sensors* s) {
log(LOG::INF, "Thread", "Starting hass_thread");
log(LOG::INF, "Thread started");
HomeAssistant pc_power("home.drath.win", "sensor.gniazdko_komputer_moc");
pc_power.connect();
@@ -66,7 +66,7 @@ void hassThread(std::stop_token st, Sensors* s) {
}
void sensorsThread(std::stop_token st, Sensors* s) {
log(LOG::INF, "Thread", "Starting sensors_thread, poll interval {} ms", LCD_INTERVAL_MS);
log(LOG::INF, "Thread started, poll interval {} ms", LCD_INTERVAL_MS);
cpu::detectHwmon(&s->cpu, "0000:00:18.3");
gpu::detectHwmon(&s->gpu, "0000:0b:00.0");
sys::detectHwmon(&s->sys, "nct6775.656");
@@ -87,14 +87,14 @@ void sensorsThread(std::stop_token st, Sensors* s) {
gpu::update(&s->gpu);
}
// log(LOG::DBG, "Sensors", "took {} microseconds", std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - start).count());
// log(LOG::DBG, "took {} microseconds", std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now() - start).count());
sem::display.release(); // unlocks display loop
std::this_thread::sleep_until(start + std::chrono::milliseconds(LCD_INTERVAL_MS));
}
}
void displayThread(std::stop_token st, Sensors* s) {
log(LOG::INF, "Thread", "Starting display_thread");
log(LOG::INF, "Thread started");
// init internal variables of LCDDisplay class
LCDDisplay lcd(LCD_PORT);
@@ -165,7 +165,7 @@ void displayThread(std::stop_token st, Sensors* s) {
}
int main() {
log(LOG::START, "LINUXSMARTIE", "============================= PROGRAM START ============================="); // to make logs clearer
log(LOG::START, "============================= PROGRAM START ============================="); // to make logs clearer
std::signal(SIGINT, sighandler);
std::signal(SIGTERM, sighandler);