mirror of
https://github.com/rofafor/vdr-plugin-satip.git
synced 2023-10-10 13:37:42 +02:00
Added a preliminary support for dynamic logging level.
This commit is contained in:
parent
d48fe3bced
commit
735e7487d3
10
common.h
10
common.h
@ -13,15 +13,9 @@
|
||||
#include <vdr/config.h>
|
||||
#include <vdr/i18n.h>
|
||||
|
||||
#ifdef DEBUG
|
||||
#define debug(x...) dsyslog("SATIP: " x)
|
||||
#define error(x...) esyslog("SATIP-ERROR: " x)
|
||||
#define info(x...) isyslog("SATIP: " x)
|
||||
#define error(x...) esyslog("ERROR: " x)
|
||||
#else
|
||||
#define debug(x...) {}
|
||||
#define info(x...) isyslog("SATIP: " x)
|
||||
#define error(x...) esyslog("ERROR: " x)
|
||||
#endif
|
||||
#define debug(x...) void( SatipConfig.IsLogLevelDebug() ? dsyslog("SATIP: " x) : void() )
|
||||
|
||||
#define ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
|
5
config.c
5
config.c
@ -12,6 +12,11 @@ cSatipConfig SatipConfig;
|
||||
|
||||
cSatipConfig::cSatipConfig(void)
|
||||
: operatingModeM(eOperatingModeLow),
|
||||
#ifdef DEBUG
|
||||
logLevelM(eLogLevelMask),
|
||||
#else
|
||||
logLevelM(eLogLevelNormal),
|
||||
#endif
|
||||
eitScanM(1),
|
||||
useBytesM(1)
|
||||
{
|
||||
|
11
config.h
11
config.h
@ -15,6 +15,7 @@ class cSatipConfig
|
||||
{
|
||||
private:
|
||||
unsigned int operatingModeM;
|
||||
unsigned int logLevelM;
|
||||
unsigned int eitScanM;
|
||||
unsigned int useBytesM;
|
||||
int disabledSourcesM[MAX_DISABLED_SOURCES_COUNT];
|
||||
@ -29,6 +30,12 @@ public:
|
||||
eOperatingModeHigh,
|
||||
eOperatingModeCount
|
||||
};
|
||||
enum {
|
||||
eLogLevelNormal = 0x00,
|
||||
eLogLevelDebug = 0x01,
|
||||
eLogLevelExtra = 0x02,
|
||||
eLogLevelMask = 0x0F
|
||||
};
|
||||
cSatipConfig();
|
||||
unsigned int GetOperatingMode(void) const { return operatingModeM; }
|
||||
bool IsOperatingModeOff(void) const { return (operatingModeM == eOperatingModeOff); }
|
||||
@ -36,6 +43,9 @@ public:
|
||||
bool IsOperatingModeNormal(void) const { return (operatingModeM == eOperatingModeNormal); }
|
||||
bool IsOperatingModeHigh(void) const { return (operatingModeM == eOperatingModeHigh); }
|
||||
void ToggleOperatingMode(void) { operatingModeM = (operatingModeM + 1) % eOperatingModeCount; }
|
||||
unsigned int GetLogLevel(void) const { return logLevelM; }
|
||||
bool IsLogLevelDebug(void) const { return (logLevelM & eLogLevelDebug); }
|
||||
bool IsLogLevelExtra(void) const { return (logLevelM & eLogLevelExtra); }
|
||||
unsigned int GetEITScan(void) const { return eitScanM; }
|
||||
unsigned int GetUseBytes(void) const { return useBytesM; }
|
||||
const char *GetConfigDirectory(void) const { return configDirectoryM; }
|
||||
@ -45,6 +55,7 @@ public:
|
||||
int GetDisabledFilters(unsigned int indexP) const;
|
||||
|
||||
void SetOperatingMode(unsigned int operatingModeP) { operatingModeM = operatingModeP; }
|
||||
void SetLogLevel(unsigned int logLevelP) { logLevelM = (logLevelP & eLogLevelMask); }
|
||||
void SetEITScan(unsigned int onOffP) { eitScanM = onOffP; }
|
||||
void SetUseBytes(unsigned int onOffP) { useBytesM = onOffP; }
|
||||
void SetConfigDirectory(const char *directoryP);
|
||||
|
@ -196,12 +196,14 @@ void cSatipDiscover::Fetch(const char *urlP)
|
||||
if (handleM && !isempty(urlP)) {
|
||||
long rc = 0;
|
||||
CURLcode res = CURLE_OK;
|
||||
#ifdef DEBUG
|
||||
|
||||
// Verbose output
|
||||
if (SatipConfig.IsLogLevelExtra()) {
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_VERBOSE, 1L);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_DEBUGFUNCTION, cSatipDiscover::DebugCallback);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_DEBUGDATA, this);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Set callback
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_WRITEFUNCTION, cSatipDiscover::WriteCallback);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_WRITEDATA, this);
|
||||
|
@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "discover.h"
|
||||
#include "poller.h"
|
||||
|
1
poller.c
1
poller.c
@ -7,6 +7,7 @@
|
||||
|
||||
#include <sys/epoll.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "poller.h"
|
||||
|
||||
|
5
rtsp.c
5
rtsp.c
@ -5,6 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "common.h"
|
||||
#include "rtsp.h"
|
||||
|
||||
@ -18,12 +19,12 @@ cSatipRtsp::cSatipRtsp(cSatipTunerIf &tunerP)
|
||||
if (handleM) {
|
||||
CURLcode res = CURLE_OK;
|
||||
|
||||
#ifdef DEBUG
|
||||
// Verbose output
|
||||
if (SatipConfig.IsLogLevelExtra()) {
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_VERBOSE, 1L);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_DEBUGFUNCTION, cSatipRtsp::DebugCallback);
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_DEBUGDATA, this);
|
||||
#endif
|
||||
}
|
||||
|
||||
// No progress meter and no signaling
|
||||
SATIP_CURL_EASY_SETOPT(handleM, CURLOPT_NOPROGRESS, 1L);
|
||||
|
13
satip.c
13
satip.c
@ -90,16 +90,20 @@ bool cPluginSatip::ProcessArgs(int argc, char *argv[])
|
||||
// Implement command line argument processing here if applicable.
|
||||
static const struct option long_options[] = {
|
||||
{ "devices", required_argument, NULL, 'd' },
|
||||
{ "loglevel", required_argument, NULL, 'l' },
|
||||
{ "server", required_argument, NULL, 's' },
|
||||
{ NULL, no_argument, NULL, 0 }
|
||||
};
|
||||
|
||||
int c;
|
||||
while ((c = getopt_long(argc, argv, "d:s:", long_options, NULL)) != -1) {
|
||||
while ((c = getopt_long(argc, argv, "d:l:s:", long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'd':
|
||||
deviceCountM = atoi(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
SatipConfig.SetLogLevel(atoi(optarg));
|
||||
break;
|
||||
case 's':
|
||||
ParseServer(optarg);
|
||||
break;
|
||||
@ -316,6 +320,8 @@ const char **cPluginSatip::SVDRPHelpPages(void)
|
||||
" Shows SAT>IP device count.\n",
|
||||
"OPER\n"
|
||||
" Toggles operating mode of SAT>IP devices.\n",
|
||||
"LOGL [ <level> ]\n"
|
||||
" Gets and sets used logging level.\n",
|
||||
NULL
|
||||
};
|
||||
return HelpPages;
|
||||
@ -396,6 +402,11 @@ cString cPluginSatip::SVDRPCommand(const char *commandP, const char *optionP, in
|
||||
}
|
||||
return cString::sprintf("SAT>IP operating mode: %s\n", *mode);
|
||||
}
|
||||
else if (strcasecmp(commandP, "LOGL") == 0) {
|
||||
if (optionP && *optionP)
|
||||
SatipConfig.SetLogLevel(atoi(optionP));
|
||||
return cString::sprintf("SAT>IP logging level: %d\n", SatipConfig.GetLogLevel());
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user