24 #ifndef ETHANLOGLOOP_H
25 #define ETHANLOGLOOP_H
27 #include "ContainerId.h"
28 #include "IDobbyUtils.h"
30 #include <systemd/sd-event.h>
40 typedef struct sd_event_source sd_event_source;
48 explicit EthanLogLoop(
const std::string& memCgroupMountPoint);
52 unsigned allowedLevels,
53 uint64_t rate = 0, uint64_t burstSize = 0);
62 uint32_t revents,
void *userData);
66 const std::string mMemCgroupMountPoint;
74 enum Type { Terminate, AddClient, SetClientBasePid } type;
80 unsigned allowedLevels;
85 explicit Event(Type type_)
86 : type(type_), id(), pipeFd(-1), basePid(-1)
87 , allowedLevels(0), rate(0), burstSize(0)
91 unsigned levels, uint64_t rate, uint64_t burst)
92 : type(type_), id(id_), pipeFd(fd), basePid(-1), tag(name)
93 , allowedLevels(levels) , rate(rate), burstSize(burst)
97 : type(type_), id(id_), pipeFd(-1), basePid(basePid_), tag()
98 , allowedLevels(0) , rate(0), burstSize(0)
112 unsigned levels, uint64_t rate, uint64_t burst)
113 :
Event(AddClient,
id, name, fd, levels, rate, burst)
120 :
Event(SetClientBasePid,
id, basePid)
124 std::deque<Event> mEvents;
126 std::list< std::unique_ptr<EthanLogClient> > mClients;
A wrapper around a std::string, used to add some type definition to to an id and also to sanity check...
Definition: ContainerId.h:41
Definition: EthanLogClient.h:43
Definition: EthanLogLoop.h:46
void eventLoop()
Event loop thread function.
Definition: EthanLogLoop.cpp:298
void wakeLoop()
Wakes the event loop.
Definition: EthanLogLoop.cpp:178
void setClientBasePid(const ContainerId &id, pid_t basePid)
Sets the base pid number for the given container.
Definition: EthanLogLoop.cpp:149
static int eventFdHandler(sd_event_source *source, int fd, uint32_t revents, void *userData)
Handler for wake ups from the event fd.
Definition: EthanLogLoop.cpp:206
int addClient(const ContainerId &id, const std::string &tag, unsigned allowedLevels, uint64_t rate=0, uint64_t burstSize=0)
Creates a new logging client, which is just pipe with some meta data stored.
Definition: EthanLogLoop.cpp:102
Definition: EthanLogLoop.h:110
Definition: EthanLogLoop.h:73
Definition: EthanLogLoop.h:118
Definition: EthanLogLoop.h:103