diff options
author | anbr <vdr07@deltab.de> | 2010-12-21 20:36:58 +0100 |
---|---|---|
committer | anbr <vdr07@deltab.de> | 2010-12-21 20:36:58 +0100 |
commit | 10a33e14d6338ff004410413f6fe52810be43f67 (patch) | |
tree | 6f71b062e9235be1383a9e6c536fea336d400e6c /debug.c | |
download | vdr-plugin-dvdswitch-0.1.0.tar.gz vdr-plugin-dvdswitch-0.1.0.tar.bz2 |
release 0.1.0 from http://www.schmidtie.de/download/vdr-dvdswitch-0.1.0.tar.bz20.1.0
Diffstat (limited to 'debug.c')
-rw-r--r-- | debug.c | 68 |
1 files changed, 68 insertions, 0 deletions
@@ -0,0 +1,68 @@ +#include <vdr/plugin.h> +#include <stdarg.h> +#include "debug.h" + +// --- cDebugLog ------------------------------------------------------- + +cDebugLog DebugLog; + +cDebugLog::cDebugLog(void) +{ + FileName = NULL; + File = NULL; +} + +cDebugLog::~ cDebugLog(void) +{ + Close(); + free(FileName); +} + +bool cDebugLog::Open(void) +{ + File = fopen(FileName, "a"); + if(File) + { + DEBUG("---------"); + DEBUG("Neuer Log"); + DEBUG("---------"); + return true; + } + + return false; +} + +void cDebugLog::Close(void) +{ + if(File) + fclose(File); +} + +bool cDebugLog::SetLogFile(char *filename) +{ + if(filename) + FileName = strdup(filename); + + return Open(); +} + +void cDebugLog::WriteLine(char *file, int line, char *format, ...) +{ + if(File) + { + char *fmt; + asprintf(&fmt, "DVDSWITCH(%s,%d): %s", file, line, format); + va_list ap; + va_start(ap, format); + vfprintf(File, fmt, ap); + va_end(ap); + fprintf(File, "\n"); + fflush(File); + free(fmt); + } +} + +void cDebugLog::End(void) +{ + Close(); +} |