cpp_photon/test/Log_test.cpp

53 lines
1.5 KiB
C++
Raw Normal View History

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