00001 #ifndef BT_FILE_LOGGER_H 00002 #define BT_FILE_LOGGER_H 00003 00004 #include <fstream> 00005 #include <deque> 00006 #include <array> 00007 #include "abstract_logger.h" 00008 00009 namespace BT 00010 { 00011 class FileLogger : public StatusChangeLogger 00012 { 00013 public: 00014 FileLogger(TreeNode* root_node, const char* filename, uint16_t buffer_size = 10); 00015 00016 virtual ~FileLogger() override; 00017 00018 virtual void callback(Duration timestamp, const TreeNode& node, NodeStatus prev_status, 00019 NodeStatus status) override; 00020 00021 virtual void flush() override; 00022 00023 private: 00024 std::ofstream file_os_; 00025 00026 std::chrono::high_resolution_clock::time_point start_time; 00027 00028 std::vector<SerializedTransition> buffer_; 00029 00030 bool buffer_max_size_; 00031 }; 00032 00033 } // end namespace 00034 00035 #endif // BT_FILE_LOGGER_H