addtogroup gazebo_util More...
#include <util/util.hh>
Public Member Functions | |
void | Add (const std::string &_name, const std::string &_filename, std::function< bool(std::ostringstream &)> _logCallback) |
Add an object to a log file. More... | |
std::string | BasePath () const |
Get the base path for a log recording. More... | |
unsigned int | BufferSize () const |
Get the size of the buffer. More... | |
const std::string & | Encoding () const |
Get the encoding used. More... | |
std::string | Filename (const std::string &_name="") const |
Get the filename for a log object. More... | |
unsigned int | FileSize (const std::string &_name="") const |
Get the file size for a log object. More... | |
void | Fini () |
Finialize, and shutdown. More... | |
bool | FirstUpdate () const |
Return true if an Update has not yet been completed. More... | |
std::string | GetBasePath () const GAZEBO_DEPRECATED(7.0) |
Get the base path for a log recording. More... | |
unsigned int | GetBufferSize () const GAZEBO_DEPRECATED(7.0) |
Get the size of the buffer. More... | |
const std::string & | GetEncoding () const GAZEBO_DEPRECATED(7.0) |
Get the encoding used. More... | |
std::string | GetFilename (const std::string &_name="") const GAZEBO_DEPRECATED(7.0) |
Get the filename for a log object. More... | |
unsigned int | GetFileSize (const std::string &_name="") const GAZEBO_DEPRECATED(7.0) |
Get the file size for a log object. More... | |
bool | GetFirstUpdate () const GAZEBO_DEPRECATED(7.0) |
Return true if an Update has not yet been completed. More... | |
bool | GetPaused () const GAZEBO_DEPRECATED(7.0) |
Get whether logging is paused. More... | |
bool | GetRunning () const GAZEBO_DEPRECATED(7.0) |
Get whether logging is running. More... | |
common::Time | GetRunTime () const GAZEBO_DEPRECATED(7.0) |
Get the run time in sim time. More... | |
bool | Init (const std::string &_subdir) |
Initialize logging into a subdirectory. More... | |
bool | IsReadyToStart () const |
Get whether the logger is ready to start, which implies that any previous runs have finished. More... | |
void | Notify () |
Tell the recorder that an update should occur. More... | |
bool | Paused () const |
Get whether logging is paused. More... | |
bool | Remove (const std::string &_name) |
Remove an entity from a log. More... | |
bool | Running () const |
Get whether logging is running. More... | |
common::Time | RunTime () const |
Get the run time in sim time. More... | |
void | SetBasePath (const std::string &_path) |
Set the base path. More... | |
void | SetPaused (const bool _paused) |
Set whether logging should pause. More... | |
bool | Start (const std::string &_encoding="zlib", const std::string &_path="") |
Start the logger. More... | |
void | Stop () |
Stop the logger. More... | |
void | Write (const bool _force=false) |
Write all logs. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from SingletonT< LogRecord > | |
static LogRecord * | Instance () |
Get an instance of the singleton. More... | |
Protected Member Functions inherited from SingletonT< LogRecord > | |
SingletonT () | |
Constructor. More... | |
virtual | ~SingletonT () |
Destructor. More... | |
addtogroup gazebo_util
Handles logging of data to disk
The LogRecord class is a Singleton that manages data logging of any entity within a running simulation. An entity may be a World, Model, or any of their child entities. This class only writes log files, see LogPlay for playback functionality.
State information for an entity may be logged through the LogRecord::Add function, and stopped through the LogRecord::Remove function. Data may be logged into a single file, or split into many separate files by specifying different filenames for the LogRecord::Add function.
The LogRecord is updated at the start of each simulation step. This guarantees that all data is stored.
void gazebo::util::LogRecord::Add | ( | const std::string & | _name, |
const std::string & | _filename, | ||
std::function< bool(std::ostringstream &)> | _logCallback | ||
) |
Add an object to a log file.
Add a new object to a log. An object can be any valid named object in simulation, including the world itself. Duplicate additions are ignored. Objects can be added to the same file by specifying the same _filename.
[in] | _name | Name of the object to log. |
[in] | _filename | Filename of the log file. |
[in] | _logCallback | Function used to log data for the object. Typically an object will have a log function that outputs data to the provided ofstream. |
Exception |
std::string gazebo::util::LogRecord::BasePath | ( | ) | const |
Get the base path for a log recording.
unsigned int gazebo::util::LogRecord::BufferSize | ( | ) | const |
Get the size of the buffer.
const std::string& gazebo::util::LogRecord::Encoding | ( | ) | const |
Get the encoding used.
std::string gazebo::util::LogRecord::Filename | ( | const std::string & | _name = "" | ) | const |
Get the filename for a log object.
[in] | _name | Name of the log object. |
unsigned int gazebo::util::LogRecord::FileSize | ( | const std::string & | _name = "" | ) | const |
Get the file size for a log object.
[in] | _name | Name of the log object. |
void gazebo::util::LogRecord::Fini | ( | ) |
Finialize, and shutdown.
bool gazebo::util::LogRecord::FirstUpdate | ( | ) | const |
Return true if an Update has not yet been completed.
std::string gazebo::util::LogRecord::GetBasePath | ( | ) | const |
Get the base path for a log recording.
unsigned int gazebo::util::LogRecord::GetBufferSize | ( | ) | const |
const std::string& gazebo::util::LogRecord::GetEncoding | ( | ) | const |
Get the encoding used.
std::string gazebo::util::LogRecord::GetFilename | ( | const std::string & | _name = "" | ) | const |
Get the filename for a log object.
[in] | _name | Name of the log object. |
unsigned int gazebo::util::LogRecord::GetFileSize | ( | const std::string & | _name = "" | ) | const |
Get the file size for a log object.
[in] | _name | Name of the log object. |
bool gazebo::util::LogRecord::GetFirstUpdate | ( | ) | const |
Return true if an Update has not yet been completed.
bool gazebo::util::LogRecord::GetPaused | ( | ) | const |
bool gazebo::util::LogRecord::GetRunning | ( | ) | const |
Get whether logging is running.
common::Time gazebo::util::LogRecord::GetRunTime | ( | ) | const |
bool gazebo::util::LogRecord::Init | ( | const std::string & | _subdir | ) |
Initialize logging into a subdirectory.
Init may only be called once, False will be returned if called multiple times.
[in] | _subdir | Directory to record to |
bool gazebo::util::LogRecord::IsReadyToStart | ( | ) | const |
Get whether the logger is ready to start, which implies that any previous runs have finished.
void gazebo::util::LogRecord::Notify | ( | ) |
Tell the recorder that an update should occur.
bool gazebo::util::LogRecord::Paused | ( | ) | const |
bool gazebo::util::LogRecord::Remove | ( | const std::string & | _name | ) |
Remove an entity from a log.
Removes an entity from the logger. The stops data recording for the entity and all its children. For example, specifying a world will stop all data logging.
[in] | _name | Name of the log |
bool gazebo::util::LogRecord::Running | ( | ) | const |
Get whether logging is running.
common::Time gazebo::util::LogRecord::RunTime | ( | ) | const |
Get the run time in sim time.
void gazebo::util::LogRecord::SetBasePath | ( | const std::string & | _path | ) |
Set the base path.
[in] | _path | Path to the new logging location. |
void gazebo::util::LogRecord::SetPaused | ( | const bool | _paused | ) |
Set whether logging should pause.
A paused state means the log file is still open, but data is not written to it.
[in] | _paused | True to pause data logging. |
bool gazebo::util::LogRecord::Start | ( | const std::string & | _encoding = "zlib" , |
const std::string & | _path = "" |
||
) |
Start the logger.
[in] | _encoding | The type of encoding (txt, zlib, or bz2). |
[in] | _path | Path in which to store log files. |
void gazebo::util::LogRecord::Stop | ( | ) |
Stop the logger.
void gazebo::util::LogRecord::Write | ( | const bool | _force = false | ) |
Write all logs.
[in] | _force | True to skip waiting on dataAvailableCondition. |