]> git.vomp.tv Git - vompclient.git/blob - log.cc
Improve connection failure handling
[vompclient.git] / log.cc
1 #include <iostream>
2 #include <fstream>
3
4 #include "log.h"
5
6 LogNT* LogNT::instance = NULL;
7
8 LogNT::LogNT()
9 {
10   instance = this;
11 }
12
13 LogNT::~LogNT()
14 {
15   instance = NULL;
16 }
17
18 LogNT* LogNT::getInstance()
19 {
20   return instance;
21 }
22
23 bool LogNT::init(const std::string& tfileName, bool tenabled)
24 {
25   if (!tenabled) return true;
26
27   enabled = true;
28   fileName = tfileName; // Keep the filename for later?
29
30   if (!fileName.compare("stdout"))
31   {
32     outstream = &std::cout;
33     return true;
34   }
35
36   outstream = &logFile;
37   logFile.open(fileName, std::ios_base::out | std::ios_base::app);
38   if (!logFile.is_open()) return false;
39
40   return true;
41 }