Skip to content

Commit

Permalink
improve logging behavior
Browse files Browse the repository at this point in the history
Increase loglevel of non-cyclic message and default loglevel to TF_NFY.
Only thing that stays at TF_INF is the lost sensor message on optional
sensors, so that wouldn't be logged by default any more.
  • Loading branch information
vmatare committed Apr 29, 2021
1 parent 38018ed commit 0c29363
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum LogLevel {
#ifdef DEBUG
#define DEFAULT_LOG_LVL TF_DBG
#else
#define DEFAULT_LOG_LVL TF_INF
#define DEFAULT_LOG_LVL TF_NFY
#endif

LogLevel &operator--(LogLevel &l);
Expand Down
20 changes: 10 additions & 10 deletions src/thinkfan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void sig_handler(int signum) {
sleep_cond.notify_all();
break;
case SIGUSR1:
log(TF_INF) << temp_state << flush;
log(TF_NFY) << temp_state << flush;
break;
#ifndef DISABLE_BUGGER
case SIGSEGV:
Expand All @@ -92,11 +92,11 @@ void sig_handler(int signum) {
case SIGUSR2:
interrupted = signum;
sleep_cond.notify_all();
log(TF_INF) << "Received SIGUSR2: Re-initializing fan control." << flush;
log(TF_NFY) << "Received SIGUSR2: Re-initializing fan control." << flush;
break;
case SIGWINCH:
tolerate_errors = 4;
log(TF_INF) << "Going to sleep: Will allow sensor read errors for the next "
log(TF_NFY) << "Going to sleep: Will allow sensor read errors for the next "
<< std::to_string(tolerate_errors) << " loops." << flush;
}
}
Expand Down Expand Up @@ -164,7 +164,7 @@ void run(const Config &config)
did_something |= fan_config->set_fanspeed(temp_state);

if (unlikely(did_something))
log(TF_INF) << temp_state << " -> " << config.fan_configs() << flush;
log(TF_NFY) << temp_state << " -> " << config.fan_configs() << flush;

did_something = false;
}
Expand All @@ -184,7 +184,7 @@ int set_options(int argc, char **argv)
while ((opt = getopt(argc, argv, optstring)) != -1) {
switch(opt) {
case 'h':
log(TF_INF) << MSG_TITLE << flush << MSG_USAGE << flush;
log(TF_NFY) << MSG_TITLE << flush << MSG_USAGE << flush;
return 1;
#ifdef USE_ATASMART
case 'd':
Expand Down Expand Up @@ -268,7 +268,7 @@ int set_options(int argc, char **argv)
}
}
if (depulse > 0)
log(TF_INF) << MSG_DEPULSE(depulse, sleeptime.count()) << flush;
log(TF_NFY) << MSG_DEPULSE(depulse, sleeptime.count()) << flush;

return 0;
}
Expand Down Expand Up @@ -488,7 +488,7 @@ int main(int argc, char **argv) {
error<SystemError>("Can't fork(): " + msg);
}
else if (child_pid > 0) {
log(TF_INF) << "Daemon PID: " << child_pid << flush;
log(TF_NFY) << "Daemon PID: " << child_pid << flush;
return 0;
}
else {
Expand Down Expand Up @@ -516,7 +516,7 @@ int main(int argc, char **argv) {
run(*config);

if (interrupted == SIGHUP) {
log(TF_INF) << MSG_RELOAD_CONF << flush;
log(TF_NFY) << MSG_RELOAD_CONF << flush;
try {
std::unique_ptr<const Config> config_new(Config::read_config(config_files));
config.swap(config_new);
Expand All @@ -534,12 +534,12 @@ int main(int argc, char **argv) {
}
} while (!interrupted);

log(TF_INF) << MSG_TERM << flush;
log(TF_NFY) << MSG_TERM << flush;
#if not defined(DISABLE_EXCEPTION_CATCHING)
}
catch (InvocationError &e) {
log(TF_ERR) << e.what() << flush;
log(TF_INF) << MSG_USAGE << flush;
log(TF_NFY) << MSG_USAGE << flush;
}
catch (ExpectedError &e) {
log(TF_ERR) << e.what() << flush;
Expand Down

0 comments on commit 0c29363

Please sign in to comment.