From 4100d829c7d1221925ca3ca0a8b794017b899c63 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 3 Apr 2022 02:01:50 +0300 Subject: [PATCH] Allow to override log file for daemonized NBD proxy --- src/nbd_proxy.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/nbd_proxy.cpp b/src/nbd_proxy.cpp index cb567ec9..29d5ab97 100644 --- a/src/nbd_proxy.cpp +++ b/src/nbd_proxy.cpp @@ -54,6 +54,8 @@ protected: msghdr read_msg = { 0 }, send_msg = { 0 }; iovec read_iov = { 0 }; + std::string logfile = "/dev/null"; + public: ~nbd_proxy() { @@ -278,6 +280,10 @@ public: } } } + if (cfg["logfile"].is_string()) + { + logfile = cfg["logfile"].string_value(); + } if (bg) { daemonize(); @@ -369,8 +375,8 @@ public: close(1); close(2); open("/dev/null", O_RDONLY); - open("/dev/null", O_WRONLY); - open("/dev/null", O_WRONLY); + open(logfile.c_str(), O_WRONLY|O_APPEND|O_CREAT); + open(logfile.c_str(), O_WRONLY|O_APPEND|O_CREAT); } json11::Json::object list_mapped()