clutchlog  0.12
t-assert.cpp
1 #include <iostream>
2 #include <cassert>
3 
4 #include "../clutchlog/clutchlog.h"
5 
6 // Make asserts (de)clutchable.
7 #define ASSERT(...) CLUTCHFUNC(error, assert, __VA_ARGS__);
8 
9 void h()
10 {
11  CLUTCHLOG(info, "!");
12  ASSERT(true == true);
13  std::clog << "--" << std::endl;
14 }
15 
16 void g()
17 {
18  CLUTCHLOG(warning, "world");
19  ASSERT(strcmp("life","life") == 0);
20  h();
21 }
22 
23 void f()
24 {
25  CLUTCHLOG(error, "hello ");
26  ASSERT(strcmp("no more","please")!=0);
27  g();
28 }
29 
30 int main(/*const int argc, char* argv[]*/)
31 {
32  auto& log = clutchlog::logger();
33 
34  log.func("f");
35  f();
36 
37  log.func("g");
38  f();
39 
40  log.func("h");
41  f();
42 }
clutchlog::logger
static clutchlog & logger()
Get the logger instance.
Definition: clutchlog.h:296
CLUTCHLOG
#define CLUTCHLOG(LEVEL, WHAT)
Log a message at the given level.
Definition: clutchlog.h:81