12185ddeaSEd Tanous #pragma once 22185ddeaSEd Tanous 3*7b669723SEd Tanous #include <sys/inotify.h> 42185ddeaSEd Tanous 5*7b669723SEd Tanous #include <boost/asio/posix/stream_descriptor.hpp> 6*7b669723SEd Tanous 7*7b669723SEd Tanous #include <optional> 8*7b669723SEd Tanous #include <string_view> 92185ddeaSEd Tanous namespace redfish 102185ddeaSEd Tanous { 11*7b669723SEd Tanous 12*7b669723SEd Tanous constexpr const char* redfishEventLogFile = "/var/log/redfish"; 13*7b669723SEd Tanous 14*7b669723SEd Tanous class FilesystemLogWatcher 15*7b669723SEd Tanous { 16*7b669723SEd Tanous private: 17*7b669723SEd Tanous std::streampos redfishLogFilePosition{0}; 18*7b669723SEd Tanous 19*7b669723SEd Tanous int inotifyFd = -1; 20*7b669723SEd Tanous int dirWatchDesc = -1; 21*7b669723SEd Tanous int fileWatchDesc = -1; 22*7b669723SEd Tanous boost::asio::posix::stream_descriptor inotifyConn; 23*7b669723SEd Tanous void onINotify(const boost::system::error_code& ec, 24*7b669723SEd Tanous std::size_t bytesTransferred); 25*7b669723SEd Tanous 26*7b669723SEd Tanous void resetRedfishFilePosition(); 27*7b669723SEd Tanous 28*7b669723SEd Tanous void watchRedfishEventLogFile(); 29*7b669723SEd Tanous 30*7b669723SEd Tanous void readEventLogsFromFile(); 31*7b669723SEd Tanous 32*7b669723SEd Tanous void cacheRedfishLogFile(); 33*7b669723SEd Tanous 34*7b669723SEd Tanous std::array<char, 1024> readBuffer{}; 35*7b669723SEd Tanous 36*7b669723SEd Tanous public: 37*7b669723SEd Tanous explicit FilesystemLogWatcher(boost::asio::io_context& iocIn); 38*7b669723SEd Tanous }; 392185ddeaSEd Tanous } // namespace redfish 40