diff options
author | thlo <t.lohmar@gmx.de> | 2012-12-26 07:15:03 +0100 |
---|---|---|
committer | thlo <t.lohmar@gmx.de> | 2012-12-26 07:15:03 +0100 |
commit | 504925aa69338fc41156cc40b526c79b62ad71a0 (patch) | |
tree | b881d7d8492e71a80cf7edebcadaa397e18ae2c3 /vdr-smarttvweb/log.c | |
parent | 6399355d20ee87365e19ef94aa8798c602f697e6 (diff) | |
download | vdr-plugin-smarttvweb-504925aa69338fc41156cc40b526c79b62ad71a0.tar.gz vdr-plugin-smarttvweb-504925aa69338fc41156cc40b526c79b62ad71a0.tar.bz2 |
Better Log support and addition of missing files
Diffstat (limited to 'vdr-smarttvweb/log.c')
-rw-r--r-- | vdr-smarttvweb/log.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/vdr-smarttvweb/log.c b/vdr-smarttvweb/log.c index 08a9ed5..685bce3 100644 --- a/vdr-smarttvweb/log.c +++ b/vdr-smarttvweb/log.c @@ -23,6 +23,7 @@ #include "log.h" #include <time.h> +#include <cstring> Log* Log::instance = NULL; @@ -45,20 +46,30 @@ int Log::init(string fileName) { time_t now = time(NULL); strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now)); - mLogFile = new ofstream(); - mLogFile->open(fileName.c_str(), ios::out ); - *mLogFile << "Log Created: " << timebuf << endl; + if (fileName != "") { + mLogFile = new ofstream(); + + mLogFile->open(fileName.c_str(), ios::out ); + *mLogFile << "Log Created: " << timebuf << endl; + } + else + mLogFile = new ofstream("/dev/null"); return 0; } int Log::init(char* fileName) { + char timebuf[128]; time_t now = time(NULL); strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT", gmtime(&now)); - mLogFile = new ofstream(); - mLogFile->open(fileName, ios::out ); - *mLogFile << "Log Created: " << timebuf << endl; + if (strcmp(fileName, "") !=0) { + mLogFile = new ofstream(); + mLogFile->open(fileName, ios::out ); + *mLogFile << "Log Created: " << timebuf << endl; + } + else + mLogFile = new ofstream("/dev/null"); return 0; } |