From 458255f13ecb931397ab9be7d759bdc37dd8f5e6 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 24 Aug 2020 10:09:36 +0100 Subject: [PATCH] Add selectable logging levels to the gateway. --- NXDNGateway/Conf.cpp | 28 ++++++++++++++++++++++------ NXDNGateway/Conf.h | 4 ++++ NXDNGateway/NXDNGateway.cpp | 2 +- NXDNGateway/NXDNGateway.ini | 3 +++ NXDNGateway/Version.h | 2 +- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/NXDNGateway/Conf.cpp b/NXDNGateway/Conf.cpp index df80dd1..c9cbc63 100644 --- a/NXDNGateway/Conf.cpp +++ b/NXDNGateway/Conf.cpp @@ -62,6 +62,8 @@ m_lookupTime(0U), m_voiceEnabled(true), m_voiceLanguage("en_GB"), m_voiceDirectory(), +m_logDisplayLevel(0U), +m_logFileLevel(0U), m_logFilePath(), m_logFileRoot(), m_aprsEnabled(false), @@ -194,6 +196,10 @@ bool CConf::read() m_logFilePath = value; else if (::strcmp(key, "FileRoot") == 0) m_logFileRoot = value; + else if (::strcmp(key, "FileLevel") == 0) + m_logFileLevel = (unsigned int)::atoi(value); + else if (::strcmp(key, "DisplayLevel") == 0) + m_logDisplayLevel = (unsigned int)::atoi(value); } else if (section == SECTION_APRS) { if (::strcmp(key, "Enable") == 0) m_aprsEnabled = ::atoi(value) == 1; @@ -353,11 +359,6 @@ std::string CConf::getVoiceDirectory() const return m_voiceDirectory; } -std::string CConf::getLogFilePath() const -{ - return m_logFilePath; -} - bool CConf::getAPRSEnabled() const { return m_aprsEnabled; @@ -383,9 +384,24 @@ std::string CConf::getAPRSDescription() const return m_aprsDescription; } +unsigned int CConf::getLogDisplayLevel() const +{ + return m_logDisplayLevel; +} + +unsigned int CConf::getLogFileLevel() const +{ + return m_logFileLevel; +} + +std::string CConf::getLogFilePath() const +{ + return m_logFilePath; +} + std::string CConf::getLogFileRoot() const { - return m_logFileRoot; + return m_logFileRoot; } unsigned int CConf::getNetworkPort() const diff --git a/NXDNGateway/Conf.h b/NXDNGateway/Conf.h index 5700b40..6d8ebd3 100644 --- a/NXDNGateway/Conf.h +++ b/NXDNGateway/Conf.h @@ -67,6 +67,8 @@ public: std::string getAPRSDescription() const; // The Log section + unsigned int getLogDisplayLevel() const; + unsigned int getLogFileLevel() const; std::string getLogFilePath() const; std::string getLogFileRoot() const; @@ -119,6 +121,8 @@ private: std::string m_voiceLanguage; std::string m_voiceDirectory; + unsigned int m_logDisplayLevel; + unsigned int m_logFileLevel; std::string m_logFilePath; std::string m_logFileRoot; diff --git a/NXDNGateway/NXDNGateway.cpp b/NXDNGateway/NXDNGateway.cpp index 5277b07..36a5ba8 100644 --- a/NXDNGateway/NXDNGateway.cpp +++ b/NXDNGateway/NXDNGateway.cpp @@ -164,7 +164,7 @@ void CNXDNGateway::run() } #endif - ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), 1U, 1U); + ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel()); if (!ret) { ::fprintf(stderr, "NXDNGateway: unable to open the log file\n"); return; diff --git a/NXDNGateway/NXDNGateway.ini b/NXDNGateway/NXDNGateway.ini index d0aba7b..19ce4b4 100644 --- a/NXDNGateway/NXDNGateway.ini +++ b/NXDNGateway/NXDNGateway.ini @@ -46,6 +46,9 @@ Name=NXDN.csv Time=24 [Log] +# Logging levels, 0=No logging +DisplayLevel=1 +FileLevel=1 FilePath=. FileRoot=NXDNGateway diff --git a/NXDNGateway/Version.h b/NXDNGateway/Version.h index dc7a96b..5b3863b 100644 --- a/NXDNGateway/Version.h +++ b/NXDNGateway/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200701"; +const char* VERSION = "20200824"; #endif