addtogroup gazebo_common More...
#include <common/common.hh>
Public Member Functions | |
void | Add (const std::string &_name, const std::string &_filename, boost::function< bool(std::ostringstream &)> _logCallback) |
Add an object to a log file. | |
void | Fini () |
Finialize, and shutdown. | |
std::string | GetBasePath () const |
Get the base path for a log recording. | |
const std::string & | GetEncoding () const |
Get the encoding used. | |
std::string | GetFilename (const std::string &_name) const |
Get the filename for a log object. | |
unsigned int | GetFileSize (const std::string &_name) const |
Get the file size for a log object. | |
bool | GetFirstUpdate () const |
Return true if an Update has not yet been completed. | |
bool | GetPaused () const |
Get whether logging is paused. | |
bool | GetRunning () const |
Get whether logging is running. | |
common::Time | GetRunTime () const |
Get the run time in sim time. | |
bool | Init (const std::string &_subdir) |
Initialize logging into a subdirectory. | |
bool | Remove (const std::string &_name) |
Remove an entity from a log. | |
void | SetBasePath (const std::string &_path) |
Set the base path. | |
void | SetPaused (bool _paused) |
Set whether logging should pause. | |
bool | Start (const std::string &_encoding="bz2") |
Start the logger. | |
void | Stop () |
Stop the logger. | |
Additional Inherited Members | |
Static Public Member Functions inherited from SingletonT< T > | |
static T * | Instance () |
Get an instance of the singleton. | |
Protected Member Functions inherited from SingletonT< T > | |
SingletonT () | |
Constructor. | |
virtual | ~SingletonT () |
Destructor. | |
addtogroup gazebo_common
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::common::LogRecord::Add | ( | const std::string & | _name, |
const std::string & | _filename, | ||
boost::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 |
void gazebo::common::LogRecord::Fini | ( | ) |
Finialize, and shutdown.
std::string gazebo::common::LogRecord::GetBasePath | ( | ) | const |
Get the base path for a log recording.
const std::string& gazebo::common::LogRecord::GetEncoding | ( | ) | const |
Get the encoding used.
std::string gazebo::common::LogRecord::GetFilename | ( | const std::string & | _name | ) | const |
Get the filename for a log object.
[in] | _name | Name of the log object. |
unsigned int gazebo::common::LogRecord::GetFileSize | ( | const std::string & | _name | ) | const |
Get the file size for a log object.
[in] | _name | Name of the log object. |
bool gazebo::common::LogRecord::GetFirstUpdate | ( | ) | const |
Return true if an Update has not yet been completed.
bool gazebo::common::LogRecord::GetPaused | ( | ) | const |
bool gazebo::common::LogRecord::GetRunning | ( | ) | const |
Get whether logging is running.
common::Time gazebo::common::LogRecord::GetRunTime | ( | ) | const |
Get the run time in sim time.
bool gazebo::common::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::common::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 |
void gazebo::common::LogRecord::SetBasePath | ( | const std::string & | _path | ) |
Set the base path.
[in] | _path | Path to the new logging location. |
void gazebo::common::LogRecord::SetPaused | ( | 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::common::LogRecord::Start | ( | const std::string & | _encoding = "bz2" | ) |
Start the logger.
[in] | _encoding | The type of encoding (txt, or bz2). |
void gazebo::common::LogRecord::Stop | ( | ) |
Stop the logger.