clutchlog 0.17
t-log.cpp
1#include <iostream>
2
3#include "../clutchlog/clutchlog.h"
4
5void h()
6{
7 CLUTCHLOG(info, "!");
8 std::clog << "--" << std::endl;
9}
10
11void g()
12{
13 CLUTCHLOG(warning, "world");
14 h();
15}
16
17void f()
18{
19 CLUTCHLOG(error, "hello ");
20 g();
21}
22
23int main(/*const int argc, char* argv[]*/)
24{
25 auto& log = clutchlog::logger();
26
27 log.out(std::clog);
28
29 std::clog << "depth: 99; threshold: xdebug; location: .*" << std::endl;
30#if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
31 log.depth(99);
32#endif
33 log.threshold(clutchlog::level::xdebug);
34 log.location(".*",".*");
35 f();
36
37 std::clog << "depth: 4; threshold: xdebug; location: ,*" << std::endl;
38#if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
39 log.depth(4);
40#endif
41 assert(log.levels().find("XDebug") != std::end(log.levels())); // contains
42 assert(log.levels().find("Xdebug") == std::end(log.levels())); // not contains
43 log.threshold("XDebug");
44 log.location(".*");
45 f();
46
47 std::clog << "depth: 99; threshold: warning; location: .*" << std::endl;
48#if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
49 log.depth(99);
50#endif
51 log.threshold(clutchlog::level::warning);
52 log.location(".*");
53 f();
54
55 std::clog << "depth: 99; threshold: xdebug; location: 'core','g'" << std::endl;
56#if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
57 log.depth(99);
58#endif
59 log.threshold(clutchlog::level::xdebug);
60 log.location("core","g");
61 f();
62
63 std::clog << "depth: 99; threshold: debug; location: '.*','(g|h)'" << std::endl;
64#if CLUTCHLOG_HAVE_UNIX_SYSINFO == 1
65 log.depth(99);
66#endif
67 log.threshold("Debug");
68 log.location(".*","(g|h)");
69 f();
70}
static clutchlog & logger()
Get the logger instance.
Definition: clutchlog.h:307
#define CLUTCHLOG(LEVEL, WHAT)
Log a message at the given level.
Definition: clutchlog.h:99