-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogTest.cpp
More file actions
93 lines (71 loc) · 1.83 KB
/
LogTest.cpp
File metadata and controls
93 lines (71 loc) · 1.83 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <iostream>
#include <cstdlib>
#include <chrono>
#include <boost/format.hpp>
enum foobar {FOO_FOO, FOO_BAR, FOO_BAZ};
namespace LogXX
{
boost::format &print(boost::format &fmt, const foobar fb)
{
switch(fb)
{
case FOO_FOO:
return fmt % "foo";
case FOO_BAR:
return fmt % "bar";
case FOO_BAZ:
return fmt % "baz";
}
return fmt % "unknown enum";
}
}
#include "log_message.h"
#include "log_manager.h"
using namespace std::chrono_literals;
class foo
{
public:
foo()
{
_trace("Hello");
}
~foo()
{
_trace("bar");
}
void foobar()
{
_trace("foobar");
}
};
int main(void)
{
std::cout << "Starting log test";
auto logManager(std::make_shared<LogXX::manager>());
logManager->addTarget(std::make_shared<LogXX::logCLog>());
logManager->Run();
foo f;
_trace("trace");
_info("info");
_warn("warning");
_err("error");
_sev("severe");
_trace("bool test %1%", true);
_trace("enum test 1 %1%", LogXX::LOG_WARNING);
_trace("enum test 2 %1% %2% %3%", FOO_FOO, FOO_BAR, FOO_BAZ);
f.foobar();
std::this_thread::sleep_for(1s);
f.foobar();
auto func = []
{
_trace("bar");
};
func();
_trace("trace: %d %s", std::rand(), "foo bar baz");
_info("info: %d %s", std::rand(), "foo bar baz");
_warn("warn: %d %s", std::rand(), "foo bar baz");
_err("err: %d %s", std::rand(), "foo bar baz");
_sev("sev: %d %s", std::rand(), "foo bar baz");
logManager->Shutdown();
logManager.reset();
}