27 #include "../../logger.h"
30 inline std::ostream& stream_assert(std::ostream& os)
32 bool failed_to_short_circuit_logging_statement =
false;
33 assert(failed_to_short_circuit_logging_statement);
37 void info(
const std::string& log_message, dccl::logger::Verbosity ,
40 printf(
"%s\n", log_message.c_str());
43 int main(
int ,
char* [])
46 using namespace dccl::logger;
48 std::cout <<
"attaching info() to DEBUG3+" << std::endl;
49 dlog.
connect(DEBUG3_PLUS, &info);
50 dlog.
is(DEBUG3) && dlog <<
"debug3 ok" << std::endl;
51 dlog.
is(DEBUG2) && dlog <<
"debug2 ok" << std::endl;
52 dlog.
is(DEBUG1) && dlog <<
"debug1 ok" << std::endl;
53 dlog.
is(INFO) && dlog <<
"verbose ok" << std::endl;
54 dlog.
is(WARN) && dlog <<
"warn ok" << std::endl;
57 std::cout <<
"attaching info() to nothing" << std::endl;
58 dlog.
is(DEBUG3) && dlog << stream_assert << std::endl;
59 dlog.
is(DEBUG2) && dlog << stream_assert << std::endl;
60 dlog.
is(DEBUG1) && dlog << stream_assert << std::endl;
61 dlog.
is(INFO) && dlog << stream_assert << std::endl;
62 dlog.
is(WARN) && dlog << stream_assert << std::endl;
64 std::cout <<
"attaching info() to WARN+" << std::endl;
66 dlog.
is(DEBUG3) && dlog << stream_assert << std::endl;
67 dlog.
is(DEBUG2) && dlog << stream_assert << std::endl;
68 dlog.
is(DEBUG1) && dlog << stream_assert << std::endl;
69 dlog.
is(INFO) && dlog << stream_assert << std::endl;
70 dlog.
is(WARN) && dlog <<
"warn ok" << std::endl;
73 std::cout <<
"attaching info() to INFO+" << std::endl;
75 dlog.
is(DEBUG3) && dlog << stream_assert << std::endl;
76 dlog.
is(DEBUG2) && dlog << stream_assert << std::endl;
77 dlog.
is(DEBUG1) && dlog << stream_assert << std::endl;
78 dlog.
is(INFO) && dlog <<
"verbose ok" << std::endl;
79 dlog.
is(WARN) && dlog <<
"warn ok" << std::endl;
82 std::cout <<
"attaching info() to DEBUG1+" << std::endl;
83 dlog.
connect(DEBUG1_PLUS, &info);
84 dlog.
is(DEBUG3) && dlog << stream_assert << std::endl;
85 dlog.
is(DEBUG2) && dlog << stream_assert << std::endl;
86 dlog.
is(DEBUG1) && dlog <<
"debug1 ok" << std::endl;
87 dlog.
is(INFO) && dlog <<
"verbose ok" << std::endl;
88 dlog.
is(WARN) && dlog <<
"warn ok" << std::endl;
91 std::cout <<
"attaching info() to DEBUG2+" << std::endl;
92 dlog.
connect(DEBUG2_PLUS, &info);
93 dlog.
is(DEBUG3) && dlog << stream_assert << std::endl;
94 dlog.
is(DEBUG2) && dlog <<
"debug2 ok" << std::endl;
95 dlog.
is(DEBUG1) && dlog <<
"debug1 ok" << std::endl;
96 dlog.
is(INFO) && dlog <<
"verbose ok" << std::endl;
97 dlog.
is(WARN) && dlog <<
"warn ok" << std::endl;
100 std::cout <<
"All tests passed." << std::endl;
bool is(logger::Verbosity verbosity, logger::Group group=logger::GENERAL)
Indicates the verbosity of the Logger until the next std::flush or std::endl. The boolean return is u...
void disconnect(int verbosity_mask)
Disconnect all slots for one or more given verbosities.
void connect(int verbosity_mask, Slot slot)
Connect the output of one or more given verbosities to a slot (function pointer or similar)