1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-29 19:28:47 -05:00

SDRdaemon: Web API: implemented logging methods

This commit is contained in:
f4exb 2018-08-19 01:28:29 +02:00
parent d7c7eb9f43
commit e3a094c9a1
3 changed files with 53 additions and 12 deletions

View File

@ -51,6 +51,8 @@ public:
~SDRDaemonMain();
static SDRDaemonMain *getInstance() { return m_instance; } // Main Core is de facto a singleton so this just returns its reference
friend class WebAPIAdapterDaemon;
signals:
void finished();

View File

@ -129,7 +129,7 @@ void SDRDaemonParser::parse(const QCoreApplication& app)
qWarning() << "SDRDaemonParser::parse: data address invalid. Defaulting to " << m_dataAddress;
}
// server port
// data port
QString dataPortStr = m_parser.value(m_dataPortOption);
serverPort = serverPortStr.toInt(&ok);

View File

@ -17,12 +17,15 @@
///////////////////////////////////////////////////////////////////////////////////
#include "SWGDaemonSummaryResponse.h"
#include "SWGLoggingInfo.h"
#include "SWGDeviceSettings.h"
#include "SWGDeviceState.h"
#include "SWGDeviceReport.h"
#include "SWGErrorResponse.h"
#include "webapiadapterdaemon.h"
#include "sdrdaemonmain.h"
#include "loggerwithfile.h"
QString WebAPIAdapterDaemon::daemonInstanceSummaryURL = "/sdrdaemon";
QString WebAPIAdapterDaemon::daemonInstanceLoggingURL = "/sdrdaemon/logging";
@ -49,22 +52,58 @@ int WebAPIAdapterDaemon::daemonInstanceSummary(
}
int WebAPIAdapterDaemon::daemonInstanceLoggingGet(
SWGSDRangel::SWGLoggingInfo& response __attribute__((unused)),
SWGSDRangel::SWGErrorResponse& error)
SWGSDRangel::SWGLoggingInfo& response,
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
{
error.init();
*error.getMessage() = "Not implemented";
return 501;
response.init();
response.setDumpToFile(m_sdrDaemonMain.m_logger->getUseFileLogger() ? 1 : 0);
if (response.getDumpToFile()) {
m_sdrDaemonMain.m_logger->getLogFileName(*response.getFileName());
m_sdrDaemonMain.m_logger->getFileMinMessageLevelStr(*response.getFileLevel());
}
m_sdrDaemonMain.m_logger->getConsoleMinMessageLevelStr(*response.getConsoleLevel());
return 200;
}
int WebAPIAdapterDaemon::daemonInstanceLoggingPut(
SWGSDRangel::SWGLoggingInfo& query __attribute__((unused)),
SWGSDRangel::SWGLoggingInfo& response __attribute__((unused)),
SWGSDRangel::SWGErrorResponse& error)
SWGSDRangel::SWGLoggingInfo& query,
SWGSDRangel::SWGLoggingInfo& response,
SWGSDRangel::SWGErrorResponse& error __attribute__((unused)))
{
error.init();
*error.getMessage() = "Not implemented";
return 501;
// response input is the query actually
bool dumpToFile = (query.getDumpToFile() != 0);
QString* consoleLevel = query.getConsoleLevel();
QString* fileLevel = query.getFileLevel();
QString* fileName = query.getFileName();
// perform actions
if (consoleLevel) {
m_sdrDaemonMain.m_settings.setConsoleMinLogLevel(getMsgTypeFromString(*consoleLevel));
}
if (fileLevel) {
m_sdrDaemonMain.m_settings.setFileMinLogLevel(getMsgTypeFromString(*fileLevel));
}
m_sdrDaemonMain.m_settings.setUseLogFile(dumpToFile);
if (fileName) {
m_sdrDaemonMain.m_settings.setLogFileName(*fileName);
}
m_sdrDaemonMain.setLoggingOptions();
// build response
response.init();
getMsgTypeString(m_sdrDaemonMain.m_settings.getConsoleMinLogLevel(), *response.getConsoleLevel());
response.setDumpToFile(m_sdrDaemonMain.m_settings.getUseLogFile() ? 1 : 0);
getMsgTypeString(m_sdrDaemonMain.m_settings.getFileMinLogLevel(), *response.getFileLevel());
*response.getFileName() = m_sdrDaemonMain.m_settings.getLogFileName();
return 200;
}
int WebAPIAdapterDaemon::daemonSettingsGet(