-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogtrigger.cpp
More file actions
43 lines (32 loc) · 872 Bytes
/
logtrigger.cpp
File metadata and controls
43 lines (32 loc) · 872 Bytes
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
41
42
43
#include "args.h"
#include "ubus.h"
#include "event.h"
#include "context.h"
#include <iostream>
static void log_callback(struct ubus_log_event* event)
{
const Logtrigger::Context& ctx {Logtrigger::Context::get_instance()};
ctx.process_event(event);
}
static void event_ubus_handler(struct ustream* s, int bytes)
{
parse_ustream_to_event_log(s, bytes, log_callback);
}
int main(int argc, char** argv)
{
using namespace Logtrigger;
auto args {Args(argc, argv)};
if (!args.is_valid())
{
std::cerr << "Must be contains at least on trigger configuration" << std::endl;
args.usage();
return 0;
}
Context ctx {Context::init_instance()};
for (const auto& item: args.triggers())
{
ctx.handler().add_event(item);
}
ubus_log_callback(args.sock_path(), event_ubus_handler);
return 0;
}