Skip to content

Commit

Permalink
Merge branch 'fix-log-verbosity'
Browse files Browse the repository at this point in the history
* Branch commit log:
  ase/main.cc: log exit status to logfile only
  ase/logging: add logtxt()

Signed-off-by: Tim Janik <[email protected]>
  • Loading branch information
tim-janik committed Jun 19, 2024
2 parents 5f8b8ee + fea5a71 commit a10b18e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ase/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ logmsg (const char c, const String &dept, const String &msg)
for (auto fd : log_fds (c == 'E')) {
if (fd == 1) fflush (stdout);
if (fd == 2) fflush (stderr);
if (c == 'T' && fd <= 2)
continue;
write (fd, s.data(), s.size());
// fdatasync (fd);
}
Expand Down
11 changes: 11 additions & 0 deletions ase/logging.hh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,22 @@ void log_setup (bool inf2stderr, bool log2file);

// == Impl ==
void logmsg (const char c, const String &dept, const String &msg);

/// Log text into logfile only.
template<class... A> void
logtxt (const char *format, const A &...args)
{
logmsg ('T', "", string_format (format, args...).c_str());
}

/// Log info to logfile (and stderr for some configs)
template<class... A> void
loginf (const char *format, const A &...args)
{
logmsg ('I', "", string_format (format, args...).c_str());
}

/// Log error to stderr and logfile.
template<class... A> void
logerr (const String &dept, const char *format, const A &...args)
{
Expand Down
4 changes: 2 additions & 2 deletions ase/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ main (int argc, char *argv[])
// run main event loop and catch SIGUSR2
const int exitcode = main_loop->run();
assert_return (main_loop, -1); // ptr must be kept around
loginf ("main loop quit (code=%d)", exitcode);
logtxt ("main loop quit (code=%d)", exitcode);

// cleanup
wss->shutdown(); // close socket, allow no more calls
Expand All @@ -644,7 +644,7 @@ main (int argc, char *argv[])
main_loop->iterate_pending();
main_config_.engine = nullptr;

loginf ("exiting: %d", exitcode);
logtxt ("exiting: %d", exitcode);
return exitcode;
}

Expand Down

0 comments on commit a10b18e

Please sign in to comment.