summaryrefslogtreecommitdiff
path: root/log.h
diff options
context:
space:
mode:
authorDimitar Petrovski <dimeptr@gmail.com>2012-05-08 16:27:16 (GMT)
committerDimitar Petrovski <dimeptr@gmail.com>2012-05-18 07:19:33 (GMT)
commit46f6510bb78a19f862bd3c1ffff6ac322ca6d6b4 (patch)
treec921f3bec8a2dc8468be8117dbe19e78882133e9 /log.h
parentbcd0b697d5953b286878542fb4c33238d65c6cb2 (diff)
downloadvdr-plugin-eepg-46f6510bb78a19f862bd3c1ffff6ac322ca6d6b4.tar.gz
vdr-plugin-eepg-46f6510bb78a19f862bd3c1ffff6ac322ca6d6b4.tar.bz2
modified logging and added logging to epghandler.c
Diffstat (limited to 'log.h')
-rw-r--r--log.h76
1 files changed, 76 insertions, 0 deletions
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_ */