diff options
author | Christian Pointner <equinox@anytun.org> | 2009-02-20 19:38:39 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2009-02-20 19:38:39 +0000 |
commit | fed4a68434600b9b9d5ea4ae4a183e59f1b7cf17 (patch) | |
tree | 295ab83f30fe9e4fe51e6771a5df212e379530cc /src/log.cpp | |
parent | fixed sync error (diff) |
added file logging target
Diffstat (limited to 'src/log.cpp')
-rw-r--r-- | src/log.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/log.cpp b/src/log.cpp index 60f6e54..026a851 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -100,6 +100,10 @@ Log::~Log() #ifdef LOG_SYSLOG closelog(); #endif +#ifdef LOG_FILE + if(log_file.is_open()) + log_file.close(); +#endif #ifdef LOG_WINEVENTLOG if(h_event_source_) DeregisterEventSource(h_event_source_); @@ -111,6 +115,9 @@ void Log::open() #ifdef LOG_SYSLOG openlog(logName.c_str(), LOG_PID, facility); #endif +#ifdef LOG_FILE + log_file.open("anytun.log", std::fstream::out | std::fstream::app); +#endif #ifdef LOG_WINEVENTLOG h_event_source_ = RegisterEventSourceA(NULL, logName.c_str()); #endif @@ -125,6 +132,10 @@ void Log::log(std::string msg, int prio) #ifdef LOG_STDOUT std::cout << "LOG-" << Log::prioToString(prio) << ": " << msg << std::endl; #endif +#ifdef LOG_FILE + if(log_file.is_open()) + log_file << Log::prioToString(prio) << ": " << msg << std::endl; +#endif #ifdef LOG_WINEVENTLOG LPCTSTR lpszStrings[1]; CHAR buffer[STERROR_TEXT_MAX]; @@ -135,7 +146,7 @@ void Log::log(std::string msg, int prio) #endif } -#ifdef LOG_STDOUT +#if defined(LOG_STDOUT) || defined(LOG_FILE) std::string Log::prioToString(int prio) { switch(prio) { |