boxstack->update(wallpaper);
VDR::getInstance()->configSave("General", "Last Power State", "Off");
+ logger->netLogOff();
VDR::getInstance()->disconnect();
Led::getInstance()->off();
isStandby = 1;
}
else
{
+ logger->netLogOff();
VDR::getInstance()->disconnect();
boxstack->removeAll();
boxstack->update(wallpaper);
void Command::doReboot()
{
+ logger->netLogOff();
VDR::getInstance()->disconnect();
// just kill it...
logger->log("Command", Log::NOTICE, "Reboot");
void Command::connectionLost()
{
+ logger->netLogOff();
Message* m = new Message(); // break into master mutex
m->message = Message::CONNECTION_LOST;
m->to = this;
VDR* vdr = VDR::getInstance();
char* config;
+ // See if we're supposed to do network logging
+ config = vdr->configLoad("Advanced", "Network logging");
+ if (config && !STRCASECMP(config, "On"))
+ {
+ logger->log("Command", Log::INFO, "Turning on network logging");
+ logger->netLogOn();
+ }
+ else
+ {
+ logger->netLogOn();
+ logger->log("Command", Log::INFO, "Turned off network logging");
+ }
+ if (config) delete[] config;
+
// See if config says to override video format (PAL/NTSC)
config = vdr->configLoad("General", "Override Video Format");
if (config)
#include "log.h"
+#include "vdr.h"
+
Log* Log::instance = NULL;
Log::Log()
logfile = NULL;
initted = 0;
logLevel = 0;
+ netLog = false;
}
Log::~Log()
{
if (!instance || !logfile) return 0;
- if (!enabled) return 1;
+ if (!enabled && !netLog) return 1;
if (level > logLevel) return 1;
char buffer[151];
buffer[149] = '\n';
buffer[150] = '\0';
}
+
+ int success = 1;
+ if (enabled)
+ {
+ success = fputs(buffer, logfile);
+ fflush(NULL);
+ }
- int success = fputs(buffer, logfile);
- fflush(NULL);
+ if (netLog) vdr->networkLog(buffer);
if (success != EOF)
return 1;
if (instance && logfile) return 1;
else return 0;
}
+
+void Log::netLogOn()
+{
+ vdr = VDR::getInstance();
+ netLog = true;
+ log("Log", Log::DEBUG, "Network logging started");
+}
+
+void Log::netLogOff()
+{
+ netLog = false;
+ vdr = NULL;
+}
+
+
#include <sys/types.h>
#include "defines.h"
+class VDR;
+
class Log
{
public:
int status();
void upLogLevel();
void downLogLevel();
+ void netLogOn();
+ void netLogOff();
const static int CRAZY = 0; // mad crazy things that should never happen
const static int EMERG = 1; // human assist required NOW
int enabled;
FILE *logfile;
+
+ bool netLog;
+ VDR* vdr;
};
#endif
return 1;
}
+bool VDR::networkLog(const char* logString)
+{
+ if (!connected) return false;
+ int stringLength = strlen(logString);
+ int packetLength = stringLength + 8;
+ char buffer[packetLength + 1];
+ *(ULONG*)&buffer[0] = htonl(CHANNEL_NETLOG);
+ *(ULONG*)&buffer[4] = htonl(stringLength);
+ strcpy(&buffer[8], logString);
+
+ if ((ULONG)tcp->sendData(buffer, packetLength) != packetLength) return false;
+ return true;
+}
+
bool VDR::getRecordingsList(RecMan* recman)
{
VDR_RequestPacket vrp;
const static ULONG CHANNEL_REQUEST_RESPONSE = 1;
const static ULONG CHANNEL_STREAM = 2;
const static ULONG CHANNEL_KEEPALIVE = 3;
+ const static ULONG CHANNEL_NETLOG = 4;
VDR();
~VDR();
char* configLoad(const char* section, const char* key);
ULONG setEventTimer(char* timerString);
RecTimerList* getRecTimersList();
+ bool networkLog(const char* buffer);
+
/**
* the MediaProvider functions
*