MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3-linux / main

Function main

src/tests/misc/journal-log-parse-test.cpp:21–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19using namespace Log::Journald;
20
21int main(int argc, char **argv)
22{
23 Parse jrn;
24
25 if ((argc - 1) % 2 != 0)
26 {
27 std::cerr << "Usage: " << argv[0]
28 << " <filter_mode> <filter_value> [<filter_mode> <filter_value>...]"
29 << std::endl;
30 std::cerr << std::endl
31 << "filter_mode = timestamp, logtag, session-token, path, sender, interface"
32 << std::endl
33 << std::endl;
34 return 1;
35 }
36
37 for (int i = 1; i < argc;)
38 {
39 std::string mode(argv[i]);
40 std::string value(argv[i + 1]);
41 i += 2;
42
43 Parse::FilterType ft = {};
44 if ("timestamp" == mode)
45 {
46 ft = Parse::FilterType::TIMESTAMP;
47 }
48 else if ("logtag" == mode)
49 {
50 ft = Parse::FilterType::LOGTAG;
51 }
52 else if ("session-token" == mode)
53 {
54 ft = Parse::FilterType::SESSION_TOKEN;
55 }
56 else if ("path" == mode)
57 {
58 ft = Parse::FilterType::OBJECT_PATH;
59 }
60 else if ("sender" == mode)
61 {
62 ft = Parse::FilterType::SENDER;
63 }
64 else if ("interface" == mode)
65 {
66 ft = Parse::FilterType::INTERFACE;
67 }
68 else
69 {
70 std::cout << "** ERROR ** Unknown filter mode: " << mode << std::endl;
71 return 2;
72 }
73 jrn.AddFilter(ft, value);
74 }
75
76 LogEntries l = jrn.Retrieve();
77 // std::cout << l;
78 std::cout << l.GetJSON() << std::endl;

Callers

nothing calls this directly

Calls 3

AddFilterMethod · 0.80
GetJSONMethod · 0.80
RetrieveMethod · 0.45

Tested by

no test coverage detected