WvStreams
wvlogbufex.cc
1/*
2 * A WvLogBuf example.
3 *
4 * The expected output is :
5 *
6 * 1043174856 logA<*1>: a message+
7 * 1043174856 logB<*2>: b message+
8 * 1043174856 logC<*3>: c message with extra newline+
9 * 1043174856 logC<*4>: c2 message+
10 * 1043174856 logA<Info>: a info message+
11 * 1043174856 logA<*1>: a normal message with [07][08] control chars+
12 * 1043174856 logA<*1>: a split+
13 * 1043174856 logB<*2>: message with stuff+
14 * 1043174856 logB<Info>: and other stuff.+
15 * 1043174856 logC<*3>: another split message.+
16 *
17 *
18 * 1043174856 logA<*1>: a message+
19 * 1043174856 logB<*2>: b message+
20 * 1043174856 logC<*3>: c message with extra newline+
21 * 1043174856 logC<*4>: c2 message+
22 * 1043174856 logA<Info>: a info message+
23 * 1043174856 logA<*1>: a normal message with [07][08] control chars+
24 * 1043174856 logA<*1>: a split+
25 * 1043174856 logB<*2>: message with stuff+
26 * 1043174856 logB<Info>: and other stuff.+
27 * 1043174856 logC<*3>: another split message.+
28 * 1043174856 logC<*3>: .. and it's wonky!+
29 *
30 */
31
32#include "wvlogbuffer.h"
33
34int main()
35{
36 WvLogBuffer rc(4);
37
38 WvLog a("logA", WvLog::Debug), b("logB", WvLog::Debug2);
39 WvLog c("logC", WvLog::Debug3), c2 = c.split(WvLog::Debug4);
40
41 a("a message\n");
42 b("b message\n");
43 c("c message with extra newline\n\n\n"); // extra newline discarded
44 c2("c2 message\n");
45
46 // the second line should be back at WvLog::Debug
47 a(WvLog::Info, "a info message\n");
48 a("a normal message with \a\b control chars\r\n");
49
50 // should display like this:
51 // a split // message with stuff // and other stuff
52 a("a split ");
53 b("message ");
54 b("with stuff ");
55 b(WvLog::Info, "and other stuff.\n");
56
57 // should display all on one line
58 c("another split ");
59 c2(WvLog::Debug3, "message.");
60
61 // should auto-terminate line on display
62 rc.dump(*wvcon);
63 wvcon->print("\n\n");
64
65 c2(WvLog::Debug3, " .. and it's wonky! \n");
66 rc.dump(*wvcon);
67
68 return 0;
69}
WvLogBuffer is a descendant of WvLogRcv that buffers log messages for later use.
Definition wvlogbuffer.h:18
A WvLog stream accepts log messages from applications and forwards them to all registered WvLogRcv's.
Definition wvlog.h:57
WvLog split(LogLevel _loglevel) const
split off a new WvLog object with the requested loglevel.
Definition wvlog.h:142