1 |
|
|
// Copyright 2019, Olivier Stasse, LAAS-CNRS. |
2 |
|
|
// |
3 |
|
|
// See LICENSE |
4 |
|
|
|
5 |
|
|
#include <iostream> |
6 |
|
|
|
7 |
|
|
#define ENABLE_RT_LOG |
8 |
|
|
#include <dynamic-graph/entity.h> |
9 |
|
|
#include <dynamic-graph/pool.h> |
10 |
|
|
#include <dynamic-graph/real-time-logger.h> |
11 |
|
|
|
12 |
|
|
#include <boost/shared_ptr.hpp> |
13 |
|
|
#include <map> |
14 |
|
|
#include <vector> |
15 |
|
|
|
16 |
|
|
#include "dynamic-graph/python/dynamic-graph-py.hh" |
17 |
|
|
|
18 |
|
|
typedef boost::shared_ptr<std::ofstream> ofstreamShrPtr; |
19 |
|
|
|
20 |
|
|
namespace dynamicgraph { |
21 |
|
|
namespace python { |
22 |
|
|
|
23 |
|
|
namespace debug { |
24 |
|
|
|
25 |
|
|
std::map<std::string, ofstreamShrPtr> mapOfFiles_; |
26 |
|
|
|
27 |
|
1 |
void addLoggerFileOutputStream(const char* filename) { |
28 |
✓✗✓✗
|
1 |
std::ofstream* aofs = new std::ofstream; |
29 |
✓✗ |
1 |
ofstreamShrPtr ofs_shrptr = boost::shared_ptr<std::ofstream>(aofs); |
30 |
✓✗ |
1 |
aofs->open(filename, std::ofstream::out); |
31 |
✓✗ |
1 |
dynamicgraph::RealTimeLogger::instance(); |
32 |
✓✗✓✗ ✓✗✓✗
|
1 |
dgADD_OSTREAM_TO_RTLOG(*aofs); |
33 |
✓✗✓✗ ✓✗✓✗ ✓✗ |
1 |
dgRTLOG() << "Added " << filename << " as an output stream \n"; |
34 |
✓✗✓✗
|
1 |
mapOfFiles_[filename] = ofs_shrptr; |
35 |
|
1 |
} |
36 |
|
|
|
37 |
|
1 |
void closeLoggerFileOutputStream() { |
38 |
✓✓✓✗
|
2 |
for (const auto& el : mapOfFiles_) el.second->close(); |
39 |
|
1 |
} |
40 |
|
|
|
41 |
✓✗ |
1 |
void addLoggerCoutOutputStream() { dgADD_OSTREAM_TO_RTLOG(std::cout); } |
42 |
|
|
|
43 |
|
1 |
void realTimeLoggerDestroy() { RealTimeLogger::destroy(); } |
44 |
|
|
|
45 |
|
25 |
void realTimeLoggerSpinOnce() { RealTimeLogger::instance().spinOnce(); } |
46 |
|
|
|
47 |
|
|
void realTimeLoggerInstance() { RealTimeLogger::instance(); } |
48 |
|
|
|
49 |
|
|
} // namespace debug |
50 |
|
|
} // namespace python |
51 |
|
|
} // namespace dynamicgraph |