Rigid Body Dynamics Library
Logging.h
Go to the documentation of this file.
1 /*
2  * RBDL - Rigid Body Dynamics Library
3  * Copyright (c) 2011-2018 Martin Felis <martin@fysx.org>
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 
22 #ifndef RBDL_ENABLE_LOGGING
23 #define LOG if (false) LogOutput
24 #define SUPPRESS_LOGGING ;
25 #else
26 #define LOG LogOutput
27 #define SUPPRESS_LOGGING LoggingGuard _nolog
28 #endif
29 
30 extern RBDL_DLLAPI std::ostringstream LogOutput;
31 RBDL_DLLAPI void ClearLogOutput ();
32 
58 class RBDL_DLLAPI LoggingGuard {
59  public:
61  log_backup.str("");
62  log_backup << LogOutput.str();
63  }
65  LogOutput.str("");
66  LogOutput << log_backup.str();
67  }
68 
69  private:
70  std::ostringstream log_backup;
71 };
72 
73 /* RBDL_LOGGING_H */
74 #endif
std::ostringstream log_backup
Definition: Logging.h:70
RBDL_DLLAPI std::ostringstream LogOutput
Definition: Logging.cc:10
~LoggingGuard()
Definition: Logging.h:64
RBDL_DLLAPI void ClearLogOutput()
Definition: Logging.cc:12
Helper object to ignore any logs that happen during its lifetime.
Definition: Logging.h:58
LoggingGuard()
Definition: Logging.h:60