Singleton Log

This commit is contained in:
James Turk 2005-02-27 05:53:01 +00:00
parent 09e1107207
commit fb54348ea7
2 changed files with 11 additions and 17 deletions

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Log.hpp,v 1.2 2005/02/16 06:58:05 cozman Exp $ // $Id: Log.hpp,v 1.3 2005/02/27 05:53:01 cozman Exp $
#ifndef PHOTON_LOG_HPP #ifndef PHOTON_LOG_HPP
#define PHOTON_LOG_HPP #define PHOTON_LOG_HPP
@ -14,6 +14,7 @@
#include <list> #include <list>
#include <sstream> #include <sstream>
#include "util/Singleton.hpp"
#include "LogSink.hpp" #include "LogSink.hpp"
namespace photon namespace photon
@ -22,13 +23,8 @@ namespace photon
// Class: Log // Class: Log
// Log class for photon, Log passes all messages to any attached <LogSinks>, // Log class for photon, Log passes all messages to any attached <LogSinks>,
// which can then take care of any output which is desired. // which can then take care of any output which is desired.
class Log class Log : public util::Singleton<Log>
{ {
public:
Log();
~Log();
// Group: Sink Maintenance // Group: Sink Maintenance
public: public:
@ -111,14 +107,14 @@ private:
LogLevel lastLevel_; LogLevel lastLevel_;
std::list<LogSinkPtr> sinks_; std::list<LogSinkPtr> sinks_;
//assignment left undefined // singleton stuff
Log(const Log &rhs); private:
Log& operator=(const Log &rhs); friend class util::Singleton<Log>;
friend class std::auto_ptr<Log>;
Log();
~Log();
}; };
//Define a log to be used throughout photon
extern Log log;
} }
#endif //PHOTON_LOG_HPP #endif //PHOTON_LOG_HPP

View File

@ -5,7 +5,7 @@
// James Turk (jpt2433@rit.edu) // James Turk (jpt2433@rit.edu)
// //
// Version: // Version:
// $Id: Log.cpp,v 1.5 2005/02/16 06:58:26 cozman Exp $ // $Id: Log.cpp,v 1.6 2005/02/27 05:53:01 cozman Exp $
#include "Log.hpp" #include "Log.hpp"
@ -128,6 +128,4 @@ std::ostream& Log::critical()
return buffer_; return buffer_;
} }
Log log;
} }