From ab8fe2e3239538cabdf178ca67183e89298c1e01 Mon Sep 17 00:00:00 2001 From: badaix Date: Wed, 27 Sep 2017 22:04:03 +0200 Subject: [PATCH] --debug= will log into --- client/snapClient.cpp | 20 +++++++++++++------- externals/aixlog | 2 +- server/snapServer.cpp | 20 +++++++++++++------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/client/snapClient.cpp b/client/snapClient.cpp index 96afefba..210ec94f 100644 --- a/client/snapClient.cpp +++ b/client/snapClient.cpp @@ -81,7 +81,7 @@ int main (int argc, char **argv) OptionParser op("Allowed options"); auto helpSwitch = op.add("", "help", "produce help message"); - auto debugSwitch = op.add("", "debug", "enable debug logging"); + auto debugOption = op.add, Visibility::hidden>("", "debug", "enable debug logging", ""); auto versionSwitch = op.add("v", "version", "show version number"); #if defined(HAS_ALSA) auto listSwitch = op.add("l", "list", "list pcm devices"); @@ -142,12 +142,18 @@ int main (int argc, char **argv) if (instance <= 0) std::invalid_argument("instance id must be >= 1"); - AixLog::Log::init( - { - make_shared(debugSwitch->is_set()?(AixLog::Severity::trace):(AixLog::Severity::info), AixLog::Type::all, debugSwitch->is_set()?"%Y-%m-%d %H-%M-%S.#ms [#severity] (#function)":"%Y-%m-%d %H-%M-%S [#severity]"), - make_shared("snapclient", AixLog::Severity::trace, AixLog::Type::special) - } - ); + AixLog::Log::init("snapclient", AixLog::Severity::trace, AixLog::Type::special); + if (debugOption->is_set()) + { + AixLog::Log::instance().add_logsink(AixLog::Severity::trace, AixLog::Type::all, "%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag_func)"); + if (!debugOption->value().empty()) + AixLog::Log::instance().add_logsink(AixLog::Severity::trace, AixLog::Type::all, debugOption->value(), "%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag_func)"); + } + else + { + AixLog::Log::instance().add_logsink(AixLog::Severity::info, AixLog::Type::all, "%Y-%m-%d %H-%M-%S [#severity]"); + } + signal(SIGHUP, signal_handler); signal(SIGTERM, signal_handler); diff --git a/externals/aixlog b/externals/aixlog index 9ecd2543..80ddcd98 160000 --- a/externals/aixlog +++ b/externals/aixlog @@ -1 +1 @@ -Subproject commit 9ecd25432f66f8a8cf291a9a5bae4fd137300af7 +Subproject commit 80ddcd98d5790adf7689f0862038aa99764737d4 diff --git a/server/snapServer.cpp b/server/snapServer.cpp index 547b2fdf..13e9692c 100644 --- a/server/snapServer.cpp +++ b/server/snapServer.cpp @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) OptionParser op("Allowed options"); auto helpSwitch = op.add("h", "help", "Produce help message"); - auto debugSwitch = op.add("", "debug", "enable debug logging"); + auto debugOption = op.add, Visibility::hidden>("", "debug", "enable debug logging", ""); auto versionSwitch = op.add("v", "version", "Show version number"); /*auto portValue =*/ op.add>("p", "port", "Server port", settings.port, &settings.port); /*auto controlPortValue =*/ op.add>("", "controlPort", "Remote control port", settings.controlPort, &settings.controlPort); @@ -127,12 +127,18 @@ int main(int argc, char* argv[]) return 1; } - AixLog::Log::init( - { - make_shared(debugSwitch->is_set()?(AixLog::Severity::trace):(AixLog::Severity::info), AixLog::Type::all, debugSwitch->is_set()?"%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag)":"%Y-%m-%d %H-%M-%S [#severity]"), - make_shared("snapserver", AixLog::Severity::trace, AixLog::Type::special) - } - ); + AixLog::Log::init("snapserver", AixLog::Severity::trace, AixLog::Type::special); + if (debugOption->is_set()) + { + AixLog::Log::instance().add_logsink(AixLog::Severity::trace, AixLog::Type::all, "%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag_func)"); + if (!debugOption->value().empty()) + AixLog::Log::instance().add_logsink(AixLog::Severity::trace, AixLog::Type::all, debugOption->value(), "%Y-%m-%d %H-%M-%S.#ms [#severity] (#tag_func)"); + } + else + { + AixLog::Log::instance().add_logsink(AixLog::Severity::info, AixLog::Type::all, "%Y-%m-%d %H-%M-%S [#severity]"); + } + signal(SIGHUP, signal_handler); signal(SIGTERM, signal_handler);