clutchlog/tests/t-log.cpp
nojhan 243b22e4c1 feat: optimize out in Release builds
- fix: fastest scope matching,
- feat: try to allow the compiler to optimize out as many conditional statements as possible,
        which allow to use clutchlog for progress-only messages in Release mode.
- feat: build_all.sh test script,
- fix: typo in macro declarations in builds without clutchlog,
- update the README accordingly.
2020-09-15 23:12:19 +02:00

58 lines
1.2 KiB
C++

#include <iostream>
#include "../clutchlog/clutchlog.h"
void h()
{
CLUTCHLOG(info, "!");
std::clog << "--" << std::endl;
}
void g()
{
CLUTCHLOG(warning, "world");
h();
}
void f()
{
CLUTCHLOG(error, "hello ");
g();
}
int main(/*const int argc, char* argv[]*/)
{
auto& log = clutchlog::logger();
log.out(std::clog);
std::clog << "depth: 99; threshold: xdebug; location: .*" << std::endl;
log.depth(99);
log.threshold(clutchlog::level::xdebug);
log.location(".*",".*");
f();
std::clog << "depth: 4; threshold: xdebug; location: ,*" << std::endl;
log.depth(4);
log.threshold(clutchlog::level::xdebug);
log.location(".*");
f();
std::clog << "depth: 99; threshold: warning; location: .*" << std::endl;
log.depth(99);
log.threshold(clutchlog::level::warning);
log.location(".*");
f();
std::clog << "depth: 99; threshold: xdebug; location: 'core','g'" << std::endl;
log.depth(99);
log.threshold(clutchlog::level::xdebug);
log.location("core","g");
f();
std::clog << "depth: 99; threshold: debug; location: '.*','(g|h)'" << std::endl;
log.depth(99);
log.threshold(clutchlog::level::debug);
log.location(".*","(g|h)");
f();
}