26 #include "../../logger.h"
29 inline std::ostream& stream_assert(std::ostream& os)
31 bool failed_to_short_circuit_logging_statement =
false;
32 assert(failed_to_short_circuit_logging_statement);
36 void info(
const std::string& log_message, dccl::logger::Verbosity ,
39 printf(
"%s\n", log_message.c_str());
42 int main(
int ,
char* [])
45 using namespace dccl::logger;
47 std::cout <<
"attaching info() to DEBUG3+" << std::endl;
48 dlog.
connect(DEBUG3_PLUS, &info);
49 dlog.
is(DEBUG3) && dlog <<
"debug3 ok" << std::endl;
50 dlog.
is(DEBUG2) && dlog <<
"debug2 ok" << std::endl;
51 dlog.
is(DEBUG1) && dlog <<
"debug1 ok" << std::endl;
52 dlog.
is(INFO) && dlog <<
"verbose ok" << std::endl;
53 dlog.
is(WARN) && dlog <<
"warn ok" << std::endl;
56 std::cout <<
"attaching info() to nothing" << std::endl;
57 dlog.
is(DEBUG3) && dlog << stream_assert << std::endl;
58 dlog.
is(DEBUG2) && dlog << stream_assert << std::endl;
59 dlog.
is(DEBUG1) && dlog << stream_assert << std::endl;
60 dlog.
is(INFO) && dlog << stream_assert << std::endl;
61 dlog.
is(WARN) && dlog << stream_assert << std::endl;
63 std::cout <<
"attaching info() to WARN+" << std::endl;
65 dlog.
is(DEBUG3) && dlog << stream_assert << std::endl;
66 dlog.
is(DEBUG2) && dlog << stream_assert << std::endl;
67 dlog.
is(DEBUG1) && dlog << stream_assert << std::endl;
68 dlog.
is(INFO) && dlog << stream_assert << std::endl;
69 dlog.
is(WARN) && dlog <<
"warn ok" << std::endl;
72 std::cout <<
"attaching info() to INFO+" << std::endl;
74 dlog.
is(DEBUG3) && dlog << stream_assert << std::endl;
75 dlog.
is(DEBUG2) && dlog << stream_assert << std::endl;
76 dlog.
is(DEBUG1) && dlog << stream_assert << std::endl;
77 dlog.
is(INFO) && dlog <<
"verbose ok" << std::endl;
78 dlog.
is(WARN) && dlog <<
"warn ok" << std::endl;
81 std::cout <<
"attaching info() to DEBUG1+" << std::endl;
82 dlog.
connect(DEBUG1_PLUS, &info);
83 dlog.
is(DEBUG3) && dlog << stream_assert << std::endl;
84 dlog.
is(DEBUG2) && dlog << stream_assert << std::endl;
85 dlog.
is(DEBUG1) && dlog <<
"debug1 ok" << std::endl;
86 dlog.
is(INFO) && dlog <<
"verbose ok" << std::endl;
87 dlog.
is(WARN) && dlog <<
"warn ok" << std::endl;
90 std::cout <<
"attaching info() to DEBUG2+" << std::endl;
91 dlog.
connect(DEBUG2_PLUS, &info);
92 dlog.
is(DEBUG3) && dlog << stream_assert << std::endl;
93 dlog.
is(DEBUG2) && dlog <<
"debug2 ok" << std::endl;
94 dlog.
is(DEBUG1) && dlog <<
"debug1 ok" << std::endl;
95 dlog.
is(INFO) && dlog <<
"verbose ok" << std::endl;
96 dlog.
is(WARN) && dlog <<
"warn ok" << std::endl;
99 std::cout <<
"All tests passed." << std::endl;