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.
This commit is contained in:
pmb
2026-05-16 21:32:42 -07:00
parent 0d5414e03d
commit 35d0f21051
+5 -6
View File
@@ -8,7 +8,6 @@
#include <boost/asio/signal_set.hpp> #include <boost/asio/signal_set.hpp>
#include <boost/asio/write.hpp> #include <boost/asio/write.hpp>
#include <cstdio> #include <cstdio>
#include <syslog.h>
#include "handler.hpp" #include "handler.hpp"
@@ -34,7 +33,7 @@ awaitable<void> echo(tcp::socket socket, std::string client_addr) {
(username.back() == '\r' || username.back() == '\n')) { (username.back() == '\r' || username.back() == '\n')) {
username.pop_back(); username.pop_back();
} }
syslog(LOG_INFO, "finger request from %s for user '%s'", std::printf("finger request from %s for user '%s'\n",
client_addr.c_str(), username.c_str()); client_addr.c_str(), username.c_str());
auto response = co_await dofinger(username); auto response = co_await dofinger(username);
if (response.compare(std::string(username)) == 0) { if (response.compare(std::string(username)) == 0) {
@@ -47,7 +46,7 @@ awaitable<void> echo(tcp::socket socket, std::string client_addr) {
co_await async_write(socket, boost::asio::buffer(response), deferred); co_await async_write(socket, boost::asio::buffer(response), deferred);
co_return; co_return;
} catch (std::exception &e) { } 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<void> listener() {
} }
int main() { 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 { try {
boost::asio::io_context io_context(1); boost::asio::io_context io_context(1);
@@ -77,7 +77,6 @@ int main() {
io_context.run(); io_context.run();
} catch (std::exception &e) { } catch (std::exception &e) {
syslog(LOG_ERR, "fatal exception: %s", e.what()); std::printf("fatal exception: %s\n", e.what());
} }
closelog();
} }