##

LogRecord.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef _GAZEBO_UTIL_LOGRECORD_HH_
#define _GAZEBO_UTIL_LOGRECORD_HH_
#include <fstream>
#include <set>
#include <string>
#include "gazebo/msgs/msgs.hh"
#include "gazebo/common/SingletonT.hh"
#include "gazebo/util/system.hh"
#define GZ_LOG_VERSION "1.0"
GZ_SINGLETON_DECLARE(GZ_UTIL_VISIBLE, gazebo, util, LogRecord)
namespace gazebo
{
namespace util
{
class LogRecordParams
{
public: std::string encoding = "zlib";
public: std::string path;
public: double period = -1;
public: std::string filter;
};
// Forward declare private data class
class LogRecordPrivate;
class GZ_UTIL_VISIBLE LogRecord : public SingletonT<LogRecord>
{
private: LogRecord();
private: virtual ~LogRecord();
public: bool Init(const std::string &_subdir);
public: void Add(const std::string &_name, const std::string &_filename,
std::function<bool (std::ostringstream &)> _logCallback);
public: bool Remove(const std::string &_name);
public: void Stop();
public: void Notify();
public: void SetPaused(const bool _paused);
public: bool Paused() const;
public: double Period() const;
public: void SetPeriod(const double _period);
public: std::string Filter() const;
public: void SetFilter(const std::string &_filter);
public: bool RecordResources() const;
public: void SetRecordResources(const bool _record);
// \return True if logger is ready to start.
public: bool IsReadyToStart() const;
public: bool Running() const;
public: bool Start(const LogRecordParams &_params);
public: bool Start(const std::string &_encoding="zlib",
const std::string &_path="");
public: const std::string &Encoding() const;
public: std::string Filename(const std::string &_name = "") const;
public: unsigned int FileSize(const std::string &_name = "") const;
public: void SetBasePath(const std::string &_path);
public: std::string BasePath() const;
public: common::Time RunTime() const;
public: void Fini();
public: bool FirstUpdate() const;
public: bool SaveModels(const std::set<std::string> &models);
public: bool SaveFiles(const std::set<std::string> &resources);
public: void Write(const bool _force = false);
public: unsigned int BufferSize() const;
private: void Update();
private: void RunUpdate();
private: void RunWrite();
private: void ClearLogs();
private: void PublishLogStatus();
private: void OnLogControl(ConstLogControlPtr &_data);
private: void Cleanup();
private: void OnPause(const bool _pause);
private: friend class SingletonT<LogRecord>;
private: std::unique_ptr<LogRecordPrivate> dataPtr;
};
}
}
#endif
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::common::Time
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:47
gazebo::util::LogRecordParams::filter
std::string filter
Log filter string.
Definition: LogRecord.hh:52
SingletonT
Singleton template class.
Definition: SingletonT.hh:33
util
util
Definition: LogRecord.hh:31
system.hh
gazebo::util::LogRecordParams::period
double period
Recording period.
Definition: LogRecord.hh:49
msgs.hh
gazebo::util::LogRecordParams::encoding
std::string encoding
The type of encoding (txt, zlib, or bz2).
Definition: LogRecord.hh:42
gazebo::util::LogRecord
addtogroup gazebo_util
Definition: LogRecord.hh:78
gazebo::util::LogRecordParams::path
std::string path
Path in which to store log files.
Definition: LogRecord.hh:45
gazebo::util::LogRecordParams
Log recording parameters.
Definition: LogRecord.hh:39
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
GZ_SINGLETON_DECLARE
#define GZ_SINGLETON_DECLARE(visibility, n1, n2, singletonType)
Helper to declare typed SingletonT.
Definition: SingletonT.hh:61
SingletonT.hh
gazebo
gazebo
Definition: LogRecord.hh:31