Sort of working log window.
[dcpomatic.git] / src / lib / log.cc
index accf3694d3775d24609c0149658ab7f76b5a7d87..7f1eea20634f8cba480d8d6884765f7e1be14268 100644 (file)
 
 using namespace std;
 
-/** @param f Filename to write log to */
-Log::Log (string f)
-       : _file (f)
-       , _level (VERBOSE)
+Log::Log ()
+       : _level (VERBOSE)
 {
 
 }
@@ -45,13 +43,13 @@ Log::log (string m, Level l)
                return;
        }
        
-       ofstream f (_file.c_str(), fstream::app);
-
        time_t t;
        time (&t);
        string a = ctime (&t);
-       
-       f << a.substr (0, a.length() - 1) << ": " << m << "\n";
+
+       stringstream s;
+       s << a.substr (0, a.length() - 1) << ": " << m;
+       do_log (s.str ());
 }
 
 void
@@ -61,3 +59,18 @@ Log::set_level (Level l)
        _level = l;
 }
 
+
+/** @param file Filename to write log to */
+FileLog::FileLog (string file)
+       : _file (file)
+{
+
+}
+
+void
+FileLog::do_log (string m)
+{
+       ofstream f (_file.c_str(), fstream::app);
+       f << m << "\n";
+}
+