From 9992e7125f4d59b9a6e545ef95da0565515ad1d2 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 24 Aug 2020 10:16:02 +0100 Subject: [PATCH] Allow the logging levels to be configurable in the gateway. --- P25Gateway/Conf.cpp | 20 ++++++++++++++++++-- P25Gateway/Conf.h | 4 ++++ P25Gateway/P25Gateway.cpp | 2 +- P25Gateway/P25Gateway.ini | 3 +++ P25Gateway/Version.h | 2 +- 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/P25Gateway/Conf.cpp b/P25Gateway/Conf.cpp index 22a7e96..ce846a5 100644 --- a/P25Gateway/Conf.cpp +++ b/P25Gateway/Conf.cpp @@ -48,6 +48,8 @@ m_lookupTime(0U), m_voiceEnabled(true), m_voiceLanguage("en_GB"), m_voiceDirectory(), +m_logDisplayLevel(0U), +m_logFileLevel(0U), m_logFilePath(), m_logFileRoot(), m_networkPort(0U), @@ -138,6 +140,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_NETWORK) { if (::strcmp(key, "Port") == 0) m_networkPort = (unsigned int)::atoi(value); @@ -224,14 +230,24 @@ std::string CConf::getVoiceDirectory() const return m_voiceDirectory; } +unsigned int CConf::getLogDisplayLevel() const +{ + return m_logDisplayLevel; +} + +unsigned int CConf::getLogFileLevel() const +{ + return m_logFileLevel; +} + std::string CConf::getLogFilePath() const { - return m_logFilePath; + return m_logFilePath; } std::string CConf::getLogFileRoot() const { - return m_logFileRoot; + return m_logFileRoot; } unsigned int CConf::getNetworkPort() const diff --git a/P25Gateway/Conf.h b/P25Gateway/Conf.h index b1c21f7..6541395 100644 --- a/P25Gateway/Conf.h +++ b/P25Gateway/Conf.h @@ -47,6 +47,8 @@ public: std::string getVoiceDirectory() const; // The Log section + unsigned int getLogDisplayLevel() const; + unsigned int getLogFileLevel() const; std::string getLogFilePath() const; std::string getLogFileRoot() const; @@ -82,6 +84,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/P25Gateway/P25Gateway.cpp b/P25Gateway/P25Gateway.cpp index 1b5c038..9d220b1 100644 --- a/P25Gateway/P25Gateway.cpp +++ b/P25Gateway/P25Gateway.cpp @@ -153,7 +153,7 @@ void CP25Gateway::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, "P25Gateway: unable to open the log file\n"); return; diff --git a/P25Gateway/P25Gateway.ini b/P25Gateway/P25Gateway.ini index 5b9de04..506cbfd 100644 --- a/P25Gateway/P25Gateway.ini +++ b/P25Gateway/P25Gateway.ini @@ -15,6 +15,9 @@ Language=en_GB Directory=./Audio [Log] +# Logging levels, 0=No logging +DisplayLevel=1 +FileLevel=1 FilePath=. FileRoot=P25Gateway diff --git a/P25Gateway/Version.h b/P25Gateway/Version.h index 54b6d54..e99254c 100644 --- a/P25Gateway/Version.h +++ b/P25Gateway/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200403"; +const char* VERSION = "20200824"; #endif