Packets: Fix VariantParser invalid parser access bug
[senf.git] / Utils / Logger / IOStreamTarget.cc
index 0de7da3..7394455 100644 (file)
@@ -30,6 +30,7 @@
 #include <locale>
 #include <boost/algorithm/string/trim.hpp>
 #include <boost/tokenizer.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
 
 //#include "IOStreamTarget.mpp"
 #define prefix_
@@ -38,6 +39,9 @@
 ///////////////////////////////////////////////////////////////////////////
 // senf::log::IOStreamTarget
 
+char const * const senf::log::IOStreamTarget::LEVELNAMES_[8] = {
+        "NONE", "VERBOSE", "NOTICE", "MESSAGE", "IMPORTANT", "CRITICAL", "FATAL", "DISABLED" };
+
 prefix_ senf::log::IOStreamTarget::IOStreamTarget(std::ostream & os)
     : stream_(os)
 {
@@ -50,7 +54,7 @@ prefix_ senf::log::IOStreamTarget::IOStreamTarget(std::ostream & os)
 ////////////////////////////////////////
 // private members
 
-prefix_ void senf::log::IOStreamTarget::v_write(boost::posix_time::ptime timestamp,
+prefix_ void senf::log::IOStreamTarget::v_write(time_type timestamp,
                                                 std::string const & stream,
                                                 std::string const & area, unsigned level,
                                                 std::string const & message)
@@ -67,10 +71,11 @@ prefix_ void senf::log::IOStreamTarget::v_write(boost::posix_time::ptime timesta
     char sep (' ');
 
     for (; i != i_end; ++i) {
-        stream_ << timestamp << sep;
+        stream_ << senf::ClockService::abstime(timestamp) << sep;
+        stream_ << "[" << LEVELNAMES_[level] << "]";
         if (area != "senf::log::DefaultArea")
-            stream_ << "[" << area << "] ";
-        stream_ << *i << "\n";
+            stream_ << " [" << area << "]";
+        stream_ << " " << *i << "\n";
         sep = '-';
     }
     stream_ << std::flush;