Log test reviewed

This commit is contained in:
James Turk 2005-07-19 20:37:04 +00:00
parent d45b2d1950
commit f3d98e483a

View File

@ -5,40 +5,43 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Log_test.cpp,v 1.1 2005/05/15 02:50:07 cozman Exp $ // $Id: Log_test.cpp,v 1.2 2005/07/19 20:37:04 cozman Exp $
#include "photon.hpp" #include "photon.hpp"
using namespace photon; using namespace photon;
// extremely simple log test application
class LogTest : public Application class LogTest : public Application
{ {
public: public:
int main(const StrVec& args) int main(const StrVec& args)
{ {
// create the log and add three sinks
Log log; Log log;
LogSinkPtr a( new ConsoleSink("console") ); LogSinkPtr a( new ConsoleSink("console") ); // standard error output
LogSinkPtr b( new TextSink("text") ); LogSinkPtr b( new TextSink("textlog") ); // plaintext log
LogSinkPtr c( new HTMLSink("html") ); LogSinkPtr c( new HTMLSink("htmllog") ); // html formatted log
// logged before sinks are added, so not shown
log.note() << "this isn't seen"; log.note() << "this isn't seen";
// add the three sinks
log.addSink(a); log.addSink(a);
log.addSink(b); log.addSink(b);
log.addSink(c); log.addSink(c);
// demo of the 5 log levels
log.note() << "notice?"; log.note() << "notice?";
log.verbose() << "(insert verbosity here)"; log.verbose() << "(insert verbosity here)";
log.warning() << "consider yourself warned."; log.warning() << "consider yourself warned.";
log.error() << "erroneous!"; log.error() << "erroneous!";
log.critical() << "Al the critic?"; log.critical() << "Al the critic?";
log.removeSink(b); log.removeSink(b); // remove b and log a message to a and c
log.note() << "only seen by a and c" ; log.note() << "only seen by a and c" ;
// remove all sinks and log a message that is not shown
log.removeSinks(); log.removeSinks();
log.note() << "not seen at all!"; log.note() << "not seen at all!";
return 0; return 0;