mirror of
https://github.com/g4klx/MMDVMHost.git
synced 2026-04-06 15:04:18 +00:00
Filter the log data sent to MQTT based on the MQTTLevel setting.
This commit is contained in:
parent
53b73c6558
commit
2f761603bc
7 changed files with 21 additions and 7 deletions
7
Log.cpp
7
Log.cpp
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
CMQTTPublisher* m_mqtt = NULL;
|
||||
|
||||
static unsigned int m_mqttLevel = 2U;
|
||||
|
||||
static unsigned int m_fileLevel = 2U;
|
||||
static std::string m_filePath;
|
||||
static std::string m_fileRoot;
|
||||
|
|
@ -127,10 +129,11 @@ bool LogOpen()
|
|||
return logOpenNoRotate();
|
||||
}
|
||||
|
||||
bool LogInitialise(bool daemon, const std::string& filePath, const std::string& fileRoot, unsigned int fileLevel, unsigned int displayLevel, bool rotate)
|
||||
bool LogInitialise(bool daemon, const std::string& filePath, const std::string& fileRoot, unsigned int fileLevel, unsigned int displayLevel, unsigned int mqttLevel, bool rotate)
|
||||
{
|
||||
m_filePath = filePath;
|
||||
m_fileRoot = fileRoot;
|
||||
m_mqttLevel = mqttLevel;
|
||||
m_fileLevel = fileLevel;
|
||||
m_displayLevel = displayLevel;
|
||||
m_daemon = daemon;
|
||||
|
|
@ -174,7 +177,7 @@ void Log(unsigned int level, const char* fmt, ...)
|
|||
|
||||
va_end(vl);
|
||||
|
||||
if (m_mqtt != NULL)
|
||||
if (m_mqtt != NULL && level >= m_mqttLevel && m_mqttLevel != 0U)
|
||||
m_mqtt->publish("log", buffer);
|
||||
|
||||
if (level >= m_fileLevel && m_fileLevel != 0U) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue