summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eepg.c60
-rw-r--r--epghandler.c7
-rw-r--r--log.h76
3 files changed, 83 insertions, 60 deletions
diff --git a/eepg.c b/eepg.c
index 7aa3fe0..22ee520 100644
--- a/eepg.c
+++ b/eepg.c
@@ -39,14 +39,12 @@
#include "eepg.h"
#include "dish.h"
#include "epghandler.h"
+#include "log.h"
#include <map>
#include <string>
#include <stdarg.h>
-#define VERBOSE 1
-/* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */
-/* all is logged into /var/log/syslog */
#if APIVERSNUM < 10401
#error You need at least VDR API version 1.4.1 for this plugin
@@ -184,62 +182,6 @@ void cMenuSetupPremiereEpg::Store (void)
#endif
}
-bool CheckLevel(int level)
-{
-#ifdef DEBUG
- if (SetupPE.LogLevel >= level)
-#else
- if (VERBOSE >= level)
-#endif
- {
- return true;
- }
- return false;
-}
-
-const char* PrepareLog(string message)
-{
- message = "EEPG: " + message;
- return message.c_str();
-}
-
-#define MAXSYSLOGBUF 256
-
-//void LogVsyslog(int errLevel, const char * message, ...)
-void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...)
-{
- va_list ap;
- char fmt[MAXSYSLOGBUF];
- if (errLevel == LOG_DEBUG) {
- snprintf(fmt, sizeof(fmt), "[%d] %s:%d %s", cThread::ThreadId(), function, lineNum, message);
- } else {
- snprintf(fmt, sizeof(fmt), "[%d] %s", cThread::ThreadId(), message);
- }
- va_start(ap,message);
- vsyslog ( errLevel, fmt, ap );
- va_end(ap);
-}
-
-#define LogI(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_INFO, __LINE__, __FUNCTION__, b ) : void() )
-#define LogE(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_ERR, __LINE__, __FUNCTION__, b ) : void() )
-#define LogD(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_DEBUG, __LINE__, __FUNCTION__, b ) : void() )
-//#define LogE(a, b...) void( CheckLevel(a) ? esyslog ( b ) : void() )
-//#define LogD(a, b...) void( CheckLevel(a) ? dsyslog ( b ) : void() )
-#define prep(s) PrepareLog(s)
-#define prep2(s) s
-
-//void LogF(int level, const char * message, ...) __attribute__ ((format (printf,2,3)));
-
-//void LogF(int level, const char * message, ...)
-//{
-// if (CheckLevel(level)) {
-// va_list ap;
-// va_start(ap,message);
-// vsyslog (LOG_ERR, PrepareLog(message), ap );
-// va_end(ap);
-// }
-//}
-
#define Asprintf(a, b, c...) void( asprintf(a, b, c) < 0 ? esyslog("memory allocation error - %s", b) : void() )
// --- CRC16 -------------------------------------------------------------------
diff --git a/epghandler.c b/epghandler.c
index 51074ad..abc4c38 100644
--- a/epghandler.c
+++ b/epghandler.c
@@ -6,6 +6,7 @@
*/
#include "epghandler.h"
+#include "log.h"
cEEpgHandler::cEEpgHandler() {
// TODO Auto-generated constructor stub
@@ -27,13 +28,17 @@ bool cEEpgHandler::SetEventID(cEvent* Event, tEventID EventID) {
}
bool cEEpgHandler::SetTitle(cEvent* Event, const char* Title) {
+ LogD(1, prep("Event id:%d title:%s new title:%s"), Event->EventID(), Event->Title(), Title);
+
if (!strcmp(Event->Title(),"") || (strcmp(Title,"") && strcmp(Event->Title(),Title)))
Event->SetTitle(Title);
return true;
}
bool cEEpgHandler::SetShortText(cEvent* Event, const char* ShortText) {
- if (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))
+ LogD(1, prep("Event id:%d ShortText:%s new ShortText:%s"), Event->EventID(), Event->ShortText(), ShortText);
+
+ if (!strcmp(Event->ShortText(),"") || (strcmp(ShortText,"") && strcmp(Event->ShortText(),ShortText)))
Event->SetShortText(ShortText);
return true;
}
diff --git a/log.h b/log.h
new file mode 100644
index 0000000..900aed6
--- /dev/null
+++ b/log.h
@@ -0,0 +1,76 @@
+/*
+ * log.h
+ *
+ * Created on: 08.5.2012
+ * Author: d.petrovski
+ */
+
+#ifndef LOG_H_
+#define LOG_H_
+
+#include <string>
+#include <stdarg.h>
+
+#define VERBOSE 1
+/* 0 = only print errors, 1 = print channels and themes, 2 = print channels, themes, titles, summaries 3 = debug mode */
+/* all is logged into /var/log/syslog */
+
+
+bool CheckLevel(int level)
+{
+#ifdef DEBUG
+ if (SetupPE.LogLevel >= level)
+#else
+ if (VERBOSE >= level)
+#endif
+ {
+ return true;
+ }
+ return false;
+}
+
+const char* PrepareLog(std::string message)
+{
+ message = "EEPG: " + message;
+ return message.c_str();
+}
+
+#define MAXSYSLOGBUF 256
+
+//void LogVsyslog(int errLevel, const char * message, ...)
+void LogVsyslog(int errLevel, int const& lineNum, const char * function, const char * message, ...)
+{
+ va_list ap;
+ char fmt[MAXSYSLOGBUF];
+ if (errLevel == LOG_DEBUG) {
+ snprintf(fmt, sizeof(fmt), "[%d] %s:%d %s", cThread::ThreadId(), function, lineNum, message);
+ } else {
+ snprintf(fmt, sizeof(fmt), "[%d] %s", cThread::ThreadId(), message);
+ }
+ va_start(ap,message);
+ vsyslog ( errLevel, fmt, ap );
+ va_end(ap);
+}
+
+#define LogI(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_INFO, __LINE__, __FUNCTION__, b ) : void() )
+#define LogE(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_ERR, __LINE__, __FUNCTION__, b ) : void() )
+#define LogD(a, b...) void( CheckLevel(a) ? LogVsyslog ( LOG_DEBUG, __LINE__, __FUNCTION__, b ) : void() )
+//#define LogE(a, b...) void( CheckLevel(a) ? esyslog ( b ) : void() )
+//#define LogD(a, b...) void( CheckLevel(a) ? dsyslog ( b ) : void() )
+#define prep(s) PrepareLog(s)
+#define prep2(s) s
+
+
+//void LogF(int level, const char * message, ...) __attribute__ ((format (printf,2,3)));
+
+//void LogF(int level, const char * message, ...)
+//{
+// if (CheckLevel(level)) {
+// va_list ap;
+// va_start(ap,message);
+// vsyslog (LOG_ERR, PrepareLog(message), ap );
+// va_end(ap);
+// }
+//}
+
+#endif /* LOG_H_ */