From e4d3adf64832e42979fb52e07ecb885ca58f2051 Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Fri, 31 Jan 2020 12:11:08 +0100
Subject: [PATCH] Provide backward compatibility + reorganize headers.

---
 include/dynamic-graph/logger.h | 20 ++++++++++++++++----
 src/debug/logger.cpp           |  7 +++++++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/include/dynamic-graph/logger.h b/include/dynamic-graph/logger.h
index 0ea5832..3c46851 100644
--- a/include/dynamic-graph/logger.h
+++ b/include/dynamic-graph/logger.h
@@ -45,14 +45,18 @@ enum MsgType {
 /* --- INCLUDE --------------------------------------------------------- */
 /* --------------------------------------------------------------------- */
 
+#include <map>
+/// \todo These 3 headers should be removed.
+#include <fstream>
+#include <iomanip> // std::setprecision
+#include <sstream>
+
 #include <boost/assign.hpp>
 #include <boost/preprocessor/stringize.hpp>
+
+#include <dynamic-graph/deprecated.hh>
 #include <dynamic-graph/linear-algebra.h>
 #include <dynamic-graph/real-time-logger-def.h>
-#include <fstream>
-#include <iomanip> // std::setprecision
-#include <map>
-#include <sstream>
 
 namespace dynamicgraph {
 
@@ -217,6 +221,14 @@ public:
    */
   void sendMsg(std::string msg, MsgType type, const std::string& lineId = "");
 
+  /** \deprecated instead, use
+   *  \code
+   *    stream(type, lineId) << msg << '\n';
+   *  \endcode
+   */
+  void sendMsg(std::string msg, MsgType type, const std::string& file,
+      int line) DYNAMIC_GRAPH_DEPRECATED;
+
   /** Set the sampling time at which the method countdown()
    * is going to be called. */
   bool setTimeSample(double t);
diff --git a/src/debug/logger.cpp b/src/debug/logger.cpp
index 07b537a..10c30c0 100644
--- a/src/debug/logger.cpp
+++ b/src/debug/logger.cpp
@@ -43,6 +43,13 @@ void Logger::sendMsg(std::string msg, MsgType type, const std::string &lineId) {
   stream(type, lineId) << msg << '\n';
 }
 
+void Logger::sendMsg(std::string msg, MsgType type, const std::string &file,
+                     int line) {
+  std::ostringstream oss;
+  oss << file << line;
+  stream(type, oss.str()) << msg << '\n';
+}
+
 bool Logger::setTimeSample(double t) {
   if (t <= 0.0)
     return false;
-- 
GitLab