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