From 52e36228e7b89de07af15a5029ac2655d5d55dfa Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli (think)" Date: Wed, 15 Aug 2012 17:06:44 +0200 Subject: crc-dabmod: file log corrections --- src/DabMod.cpp | 8 +++++--- src/Log.h | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 0d899d1..d3cc877 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -313,16 +313,18 @@ int main(int argc, char* argv[]) } if (pt.get("log.filelog", 0) == 1) { + std::string logfilename; try { - std::string logfilename = pt.get("fileoutput.filename"); - LogToFile* log_file = new LogToFile(logfilename); - logger.register_backend(log_file); + logfilename = pt.get("log.filename"); } catch (std::exception &e) { std::cerr << "Error: " << e.what() << "\n"; std::cerr << " Configuration enables file log, but does not specify log filename\n"; goto END_MAIN; } + + LogToFile* log_file = new LogToFile(logfilename); + logger.register_backend(log_file); } diff --git a/src/Log.h b/src/Log.h index dc686fc..617293f 100644 --- a/src/Log.h +++ b/src/Log.h @@ -92,7 +92,8 @@ class LogToFile : public LogBackend { LogToFile(std::string filename) { name = "FILE"; log_filename = filename; - log_stream.open(filename.c_str(), std::ios::app); + + log_stream.open(filename.c_str(), std::ios::out | std::ios::app); if (!log_stream.is_open()) { throw new std::runtime_error("Cannot open log file !"); } @@ -113,6 +114,7 @@ class LogToFile : public LogBackend { va_start(arg_ptr, fmt); snprintf(message, 200, fmt, arg_ptr); log_stream << "CRC-DABMOD: " << log_level_text[(size_t)level] << ": " << message << std::endl; + log_stream.flush(); va_end(arg_ptr); } -- cgit v1.2.3