Publish the log data via MQTT topics $NAME/log/$LEVEL.

This commit is contained in:
Jonathan Naylor
2022-11-27 20:27:44 +00:00
parent 3202d73ce5
commit 96364136d9
14 changed files with 288 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015-2021 by Jonathan Naylor G4KLX
* Copyright (C) 2015-2022 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@
#include "I2CController.h"
#endif
#include "UDPController.h"
#include "MQTTPublisher.h"
#include "DStarDefines.h"
#include "Version.h"
#include "StopWatch.h"
@@ -59,6 +60,9 @@ static bool m_killed = false;
static int m_signal = 0;
static bool m_reload = false;
// In Log.cpp
extern CMQTTPublisher* m_mqtt;
#if !defined(_WIN32) && !defined(_WIN64)
static void sigHandler1(int signum)
{
@@ -267,15 +271,23 @@ int CMMDVMHost::run()
#endif
#if !defined(_WIN32) && !defined(_WIN64)
ret = ::LogInitialise(m_daemon, m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel(), m_conf.getLogFileRotate());
ret = ::LogInitialise(m_daemon, m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel(), m_conf.getLogFileRotate(), m_conf.getMQTTName());
#else
ret = ::LogInitialise(false, m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel(), m_conf.getLogFileRotate());
ret = ::LogInitialise(false, m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), m_conf.getLogDisplayLevel(), m_conf.getLogFileRotate(), m_conf.getMQTTName());
#endif
if (!ret) {
::fprintf(stderr, "MMDVMHost: unable to open the log file\n");
return 1;
}
m_mqtt = new CMQTTPublisher(m_conf.getMQTTHost(), m_conf.getMQTTPort(), m_conf.getMQTTKeepalive(), 2);
ret = m_mqtt->open();
if (!ret) {
::fprintf(stderr, "MMDVMHost: unable to start the MQTT Publisher\n");
delete m_mqtt;
m_mqtt = NULL;
}
#if !defined(_WIN32) && !defined(_WIN64)
if (m_daemon) {
::close(STDIN_FILENO);
@@ -1361,6 +1373,11 @@ int CMMDVMHost::run()
delete m_remoteControl;
}
if (m_mqtt != NULL) {
m_mqtt->close();
delete m_mqtt;
}
delete m_dstar;
delete m_dmr;
delete m_ysf;