WvStreams
wvlogbufex.cc
00001 /*
00002  * A WvLogBuf example.
00003  *
00004  * The expected output is :
00005  *
00006  * 1043174856 logA<*1>: a message+
00007  * 1043174856 logB<*2>: b message+
00008  * 1043174856 logC<*3>: c message with extra newline+
00009  * 1043174856 logC<*4>: c2 message+
00010  * 1043174856 logA<Info>: a info message+
00011  * 1043174856 logA<*1>: a normal message with [07][08] control chars+
00012  * 1043174856 logA<*1>: a split+
00013  * 1043174856 logB<*2>: message with stuff+
00014  * 1043174856 logB<Info>: and other stuff.+
00015  * 1043174856 logC<*3>: another split message.+
00016  *
00017  *
00018  * 1043174856 logA<*1>: a message+
00019  * 1043174856 logB<*2>: b message+
00020  * 1043174856 logC<*3>: c message with extra newline+
00021  * 1043174856 logC<*4>: c2 message+
00022  * 1043174856 logA<Info>: a info message+
00023  * 1043174856 logA<*1>: a normal message with [07][08] control chars+
00024  * 1043174856 logA<*1>: a split+
00025  * 1043174856 logB<*2>: message with stuff+
00026  * 1043174856 logB<Info>: and other stuff.+
00027  * 1043174856 logC<*3>: another split message.+
00028  * 1043174856 logC<*3>: .. and it's wonky!+
00029  *
00030  */
00031 
00032 #include "wvlogbuffer.h"
00033 
00034 int main()
00035 {
00036     WvLogBuffer rc(4);
00037 
00038     WvLog a("logA", WvLog::Debug), b("logB", WvLog::Debug2);
00039     WvLog c("logC", WvLog::Debug3), c2 = c.split(WvLog::Debug4);
00040 
00041     a("a message\n");
00042     b("b message\n");
00043     c("c message with extra newline\n\n\n"); // extra newline discarded
00044     c2("c2 message\n");
00045 
00046     // the second line should be back at WvLog::Debug
00047     a(WvLog::Info, "a info message\n");
00048     a("a normal message with \a\b control chars\r\n");
00049 
00050     // should display like this:
00051     //  a split // message with stuff // and other stuff
00052     a("a split ");
00053     b("message ");
00054     b("with stuff ");
00055     b(WvLog::Info, "and other stuff.\n");
00056 
00057     // should display all on one line
00058     c("another split ");
00059     c2(WvLog::Debug3, "message.");
00060 
00061     // should auto-terminate line on display
00062     rc.dump(*wvcon);
00063     wvcon->print("\n\n");
00064 
00065     c2(WvLog::Debug3, "  .. and it's wonky!  \n");
00066     rc.dump(*wvcon);
00067 
00068     return 0;
00069 }