17 #ifndef _GAZEBO_UTIL_LOGRECORD_PRIVATE_HH_
18 #define _GAZEBO_UTIL_LOGRECORD_PRIVATE_HH_
24 #include <condition_variable>
25 #include <boost/filesystem.hpp>
49 public:
Log(
LogRecord *_parent,
const std::string &_relativeFilename,
50 std::function<
bool (std::ostringstream &)> _logCB);
53 public:
virtual ~Log();
57 public:
void Start(
const boost::filesystem::path &_path);
67 public:
unsigned int Update();
89 public: std::function<bool (std::ostringstream &)>
logCB;
106 public:
typedef std::map<std::string, Log*>
Log_M;
std::string logSubDir
Subdirectory for log files.
Definition: LogRecordPrivate.hh:162
bool pauseState
Simulation pause state.
Definition: LogRecordPrivate.hh:198
std::ofstream logFile
The log file.
Definition: LogRecordPrivate.hh:95
virtual ~Log()
Destructor.
transport::SubscriberPtr logControlSub
Subscriber to log control messages.
Definition: LogRecordPrivate.hh:189
boost::filesystem::path completePath
Complete file path.
Definition: LogRecordPrivate.hh:101
bool paused
True to pause recording.
Definition: LogRecordPrivate.hh:171
std::string CompleteFilename() const
Get the complete filename.
std::string buffer
Data buffer.
Definition: LogRecordPrivate.hh:92
virtual ~LogRecordPrivate()=default
Destructor (makes style checker happy)
std::condition_variable updateCondition
Condition used to trigger an update.
Definition: LogRecordPrivate.hh:121
LogRecord * parent
Pointer to the log record parent.
Definition: LogRecordPrivate.hh:86
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
bool running
True if logging is running.
Definition: LogRecordPrivate.hh:127
std::mutex writeMutex
Mutex to protect against parallel calls to Write()
Definition: LogRecordPrivate.hh:139
bool initialized
True if initialized.
Definition: LogRecordPrivate.hh:168
std::unique_ptr< std::thread > updateThread
Thread used to update data.
Definition: LogRecordPrivate.hh:133
bool stopThread
Flag used to stop the write thread.
Definition: LogRecordPrivate.hh:177
Log(LogRecord *_parent, const std::string &_relativeFilename, std::function< bool(std::ostringstream &)> _logCB)
Constructor.
transport::NodePtr node
Transportation node.
Definition: LogRecordPrivate.hh:186
std::string relativeFilename
Relative log filename.
Definition: LogRecordPrivate.hh:98
common::Time startTime
Start simulation time.
Definition: LogRecordPrivate.hh:180
std::condition_variable cleanupCondition
Used by the cleanupThread to wait for a cleanup signal.
Definition: LogRecordPrivate.hh:124
boost::filesystem::path logBasePath
The base pathname for all the logs.
Definition: LogRecordPrivate.hh:155
Log_M logs
All the log objects.
Definition: LogRecordPrivate.hh:109
boost::filesystem::path logCompletePath
The complete pathname for all the logs.
Definition: LogRecordPrivate.hh:158
Definition: LogRecordPrivate.hh:35
std::mutex updateMutex
Mutex to synchronize with RunUpdate()
Definition: LogRecordPrivate.hh:145
std::condition_variable dataAvailableCondition
Used by the write thread to know when data needs to be written to disk.
Definition: LogRecordPrivate.hh:152
std::function< bool(std::ostringstream &)> logCB
Callback from which to get data.
Definition: LogRecordPrivate.hh:89
addtogroup gazebo_util
Definition: LogRecord.hh:56
std::condition_variable startThreadCondition
Condition used to start threads.
Definition: LogRecordPrivate.hh:118
Log_M::iterator updateIter
Iterator used to update the log objects.
Definition: LogRecordPrivate.hh:112
Log helper class.
Definition: LogRecordPrivate.hh:41
bool readyToStart
True if the logger is ready to start, and the previous run has finished.
Definition: LogRecordPrivate.hh:202
void Write()
Write data to disk.
std::map< std::string, Log * > Log_M
Definition: LogRecordPrivate.hh:106
void Start(const boost::filesystem::path &_path)
Start the log.
std::vector< ConnectionPtr > Connection_V
Definition: CommonTypes.hh:157
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
common::Time currTime
Current simulation time.
Definition: LogRecordPrivate.hh:183
unsigned int Update()
Update the data buffer.
bool firstUpdate
Used to indicate the first update callback.
Definition: LogRecordPrivate.hh:174
std::mutex runWriteMutex
Mutex to synchronize with RunWrite()
Definition: LogRecordPrivate.hh:142
void ClearBuffer()
Clear the data buffer.
event::Connection_V connections
All the event connections.
Definition: LogRecordPrivate.hh:195
std::unique_ptr< std::thread > cleanupThread
Thread to cleanup log recording.
Definition: LogRecordPrivate.hh:136
std::mutex controlMutex
Mutex to protect logging control.
Definition: LogRecordPrivate.hh:148
transport::PublisherPtr logStatusPub
Publisher of log status messages.
Definition: LogRecordPrivate.hh:192
std::string encoding
Encoding format for each chunk.
Definition: LogRecordPrivate.hh:165
std::string RelativeFilename() const
Get the relative filename.
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
Log_M::iterator logsEnd
Convenience iterator to the end of the log objects map.
Definition: LogRecordPrivate.hh:115
unsigned int BufferSize()
Get the byte size of the buffer.
std::unique_ptr< std::thread > writeThread
Thread used to write data to disk.
Definition: LogRecordPrivate.hh:130
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44