12185ddeaSEd Tanous #pragma once 22185ddeaSEd Tanous 3*d7857201SEd Tanous #include <boost/asio/io_context.hpp> 47b669723SEd Tanous #include <boost/asio/posix/stream_descriptor.hpp> 57b669723SEd Tanous 6*d7857201SEd Tanous #include <array> 7*d7857201SEd Tanous #include <cstddef> 8*d7857201SEd Tanous #include <iosfwd> 92185ddeaSEd Tanous namespace redfish 102185ddeaSEd Tanous { 117b669723SEd Tanous 127b669723SEd Tanous constexpr const char* redfishEventLogFile = "/var/log/redfish"; 137b669723SEd Tanous 147b669723SEd Tanous class FilesystemLogWatcher 157b669723SEd Tanous { 167b669723SEd Tanous private: 177b669723SEd Tanous std::streampos redfishLogFilePosition{0}; 187b669723SEd Tanous 197b669723SEd Tanous int dirWatchDesc = -1; 207b669723SEd Tanous int fileWatchDesc = -1; 217b669723SEd Tanous void onINotify(const boost::system::error_code& ec, 227b669723SEd Tanous std::size_t bytesTransferred); 237b669723SEd Tanous 247b669723SEd Tanous void resetRedfishFilePosition(); 257b669723SEd Tanous 267b669723SEd Tanous void watchRedfishEventLogFile(); 277b669723SEd Tanous 287b669723SEd Tanous void readEventLogsFromFile(); 297b669723SEd Tanous 307b669723SEd Tanous void cacheRedfishLogFile(); 317b669723SEd Tanous 327b669723SEd Tanous std::array<char, 1024> readBuffer{}; 33fda37f9bSEd Tanous // Explicit make the last item so it is canceled before the buffer goes out 34fda37f9bSEd Tanous // of scope. 35fda37f9bSEd Tanous boost::asio::posix::stream_descriptor inotifyConn; 367b669723SEd Tanous 377b669723SEd Tanous public: 387b669723SEd Tanous explicit FilesystemLogWatcher(boost::asio::io_context& iocIn); 397b669723SEd Tanous }; 402185ddeaSEd Tanous } // namespace redfish 41