1 #pragma once 2 3 #include <boost/asio/posix/stream_descriptor.hpp> 4 5 #include <optional> 6 #include <string_view> 7 namespace redfish 8 { 9 10 constexpr const char* redfishEventLogFile = "/var/log/redfish"; 11 12 class FilesystemLogWatcher 13 { 14 private: 15 std::streampos redfishLogFilePosition{0}; 16 17 int dirWatchDesc = -1; 18 int fileWatchDesc = -1; 19 void onINotify(const boost::system::error_code& ec, 20 std::size_t bytesTransferred); 21 22 void resetRedfishFilePosition(); 23 24 void watchRedfishEventLogFile(); 25 26 void readEventLogsFromFile(); 27 28 void cacheRedfishLogFile(); 29 30 std::array<char, 1024> readBuffer{}; 31 // Explicit make the last item so it is canceled before the buffer goes out 32 // of scope. 33 boost::asio::posix::stream_descriptor inotifyConn; 34 35 public: 36 explicit FilesystemLogWatcher(boost::asio::io_context& iocIn); 37 }; 38 } // namespace redfish 39