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