Rigid Body Dynamics Library
Logging.h
Go to the documentation of this file.
1 /*
2  * RBDL - Rigid Body Dynamics Library
3  * Copyright (c) 2011-2016 Martin Felis <martin.felis@iwr.uni-heidelberg.de>
4  *
5  * Licensed under the zlib license. See LICENSE for more details.
6  */
7 
8 #ifndef RBDL_LOGGING_H
9 #define RBDL_LOGGING_H
10 
11 #include <sstream>
12 #include <rbdl/rbdl_config.h>
13 
14 class LoggingGuard;
15 
23 #ifndef RBDL_ENABLE_LOGGING
24 #define LOG if (false) LogOutput
25 #define SUPPRESS_LOGGING ;
26 #else
27 #define LOG LogOutput
28 #define SUPPRESS_LOGGING LoggingGuard _nolog
29 #endif
30 
31 extern RBDL_DLLAPI std::ostringstream LogOutput;
32 RBDL_DLLAPI void ClearLogOutput ();
33 
59 class RBDL_DLLAPI LoggingGuard {
60  public:
62  log_backup.str("");
63  log_backup << LogOutput.str();
64  }
66  LogOutput.str("");
67  LogOutput << log_backup.str();
68  }
69 
70  private:
71  std::ostringstream log_backup;
72 };
73 
74 /* RBDL_LOGGING_H */
75 #endif
std::ostringstream log_backup
Definition: Logging.h:71
RBDL_DLLAPI std::ostringstream LogOutput
Definition: Logging.cc:10
~LoggingGuard()
Definition: Logging.h:65
RBDL_DLLAPI void ClearLogOutput()
Definition: Logging.cc:12
Helper object to ignore any logs that happen during its lifetime.
Definition: Logging.h:59
LoggingGuard()
Definition: Logging.h:61