log via syslog (LOG_DAEMON) instead of stdout
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <boost/asio/signal_set.hpp>
|
||||
#include <boost/asio/write.hpp>
|
||||
#include <cstdio>
|
||||
#include <syslog.h>
|
||||
|
||||
#include "handler.hpp"
|
||||
|
||||
@@ -44,7 +45,7 @@ awaitable<void> echo(tcp::socket socket) {
|
||||
co_await async_write(socket, boost::asio::buffer(response), deferred);
|
||||
co_return;
|
||||
} catch (std::exception &e) {
|
||||
std::printf("echo Exception: %s\n", e.what());
|
||||
syslog(LOG_ERR, "echo exception: %s", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +57,7 @@ awaitable<void> listener() {
|
||||
boost::system::error_code ec;
|
||||
auto endpoint = socket.remote_endpoint(ec);
|
||||
if (!ec) {
|
||||
std::printf("connection from %s:%u\n",
|
||||
syslog(LOG_INFO, "connection from %s:%u",
|
||||
endpoint.address().to_string().c_str(),
|
||||
endpoint.port());
|
||||
}
|
||||
@@ -65,6 +66,7 @@ awaitable<void> listener() {
|
||||
}
|
||||
|
||||
int main() {
|
||||
openlog("fingerd", LOG_PID, LOG_DAEMON);
|
||||
try {
|
||||
boost::asio::io_context io_context(1);
|
||||
|
||||
@@ -75,6 +77,7 @@ int main() {
|
||||
|
||||
io_context.run();
|
||||
} catch (std::exception &e) {
|
||||
std::printf("Exception: %s\n", e.what());
|
||||
syslog(LOG_ERR, "fatal exception: %s", e.what());
|
||||
}
|
||||
closelog();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user