From 35d0f21051f86836a7b894f91642e367f0fa0f35 Mon Sep 17 00:00:00 2001 From: waffle2k Date: Sat, 16 May 2026 21:32:42 -0700 Subject: [PATCH] Revert syslog logging back to stdout Stdout works in both contexts: docker logs captures it directly, and on FreeBSD daemon(8) / the Bastille jail rc script can redirect or pipe it to syslog as needed. Going through syslog from inside the daemon required openlog/closelog and a libc dependency that broke portability with no real benefit. --- main.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 288eab6..390b4f2 100644 --- a/main.cpp +++ b/main.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include "handler.hpp" @@ -34,8 +33,8 @@ awaitable echo(tcp::socket socket, std::string client_addr) { (username.back() == '\r' || username.back() == '\n')) { username.pop_back(); } - syslog(LOG_INFO, "finger request from %s for user '%s'", - client_addr.c_str(), username.c_str()); + std::printf("finger request from %s for user '%s'\n", + client_addr.c_str(), username.c_str()); auto response = co_await dofinger(username); if (response.compare(std::string(username)) == 0) { // No plan found @@ -47,7 +46,7 @@ awaitable echo(tcp::socket socket, std::string client_addr) { co_await async_write(socket, boost::asio::buffer(response), deferred); co_return; } catch (std::exception &e) { - syslog(LOG_ERR, "echo exception: %s", e.what()); + std::printf("echo exception: %s\n", e.what()); } } @@ -66,7 +65,8 @@ awaitable listener() { } int main() { - openlog("fingerd", LOG_PID, LOG_DAEMON); + // Line-buffer stdout so docker logs / tail -f see entries in real time. + std::setvbuf(stdout, nullptr, _IOLBF, 0); try { boost::asio::io_context io_context(1); @@ -77,7 +77,6 @@ int main() { io_context.run(); } catch (std::exception &e) { - syslog(LOG_ERR, "fatal exception: %s", e.what()); + std::printf("fatal exception: %s\n", e.what()); } - closelog(); }