Xcos log: avoid ambiguous definition 82/17082/1
Clément DAVID [Fri, 21 Aug 2015 13:37:43 +0000 (15:37 +0200)]
Change-Id: I03b2c628a776f42eae9fa0a17552a63025f77736

scilab/modules/scicos/src/cpp/LoggerView.cpp
scilab/modules/scicos/src/cpp/LoggerView.hxx

index 937189b..1cb808d 100644 (file)
@@ -122,23 +122,6 @@ void LoggerView::log(enum LogLevel level, const std::string& msg)
     }
 }
 
-void LoggerView::log(enum LogLevel level, const char* msg)
-{
-    if (level >= this->m_level)
-    {
-        if (USE_SCILAB_WRITE)
-        {
-            scilabForcedWrite(LoggerView::toDisplay(level));
-            scilabForcedWrite(msg);
-        }
-        else
-        {
-            std::cerr << LoggerView::toDisplay(level);
-            std::cerr << msg;
-        }
-    }
-}
-
 void LoggerView::log(enum LogLevel level, const char* msg, ...)
 {
     if (level >= this->m_level)
@@ -163,19 +146,26 @@ void LoggerView::log(enum LogLevel level, const char* msg, ...)
     }
 }
 
-void LoggerView::log(enum LogLevel level, const wchar_t* msg)
+void LoggerView::log(enum LogLevel level, const wchar_t* msg, ...)
 {
     if (level >= this->m_level)
     {
+        const int N = 1024;
+        wchar_t* str = new wchar_t[N];
+        va_list opts;
+        va_start(opts, msg);
+        vswprintf(str, N, msg, opts);
+        va_end(opts);
+
         if (USE_SCILAB_WRITE)
         {
             scilabForcedWrite(LoggerView::toDisplay(level));
-            scilabForcedWriteW(msg);
+            scilabForcedWriteW(str);
         }
         else
         {
             std::cerr << LoggerView::toDisplay(level);
-            std::wcerr << msg;
+            std::wcerr << str;
         }
     }
 }
index 3612586..9467fbf 100644 (file)
@@ -60,8 +60,7 @@ public:
     void log(enum LogLevel level, const std::stringstream& msg);
     void log(enum LogLevel level, const std::string& msg);
     void log(enum LogLevel level, const char* msg, ...);
-    void log(enum LogLevel level, const char* msg);
-    void log(enum LogLevel level, const wchar_t* msg);
+    void log(enum LogLevel level, const wchar_t* msg, ...);
 
     /*
      * Implement the Logger as a View