UniSet  2.0.0
LogAgregator.h
00001 #ifndef LogAgregator_H_
00002 #define LogAgregator_H_
00003 // -------------------------------------------------------------------------
00004 #include <string>
00005 #include <list>
00006 #include "DebugStream.h"
00007 #include "LogServerTypes.h"
00008 // -------------------------------------------------------------------------
00009 class LogAgregator:
00010     public DebugStream
00011 {
00012     public:
00013 
00014         explicit LogAgregator( Debug::type t = Debug::NONE );
00015         explicit LogAgregator( char const * f, Debug::type t = Debug::NONE );
00016 
00017         virtual ~LogAgregator();
00018 
00019         virtual void logFile( const std::string& f );
00020 
00021         void add( DebugStream& log );
00022 
00023         // Управление "подчинёнными" логами
00024         void addLevel( const std::string& logname, Debug::type t );
00025         void delLevel( const std::string& logname, Debug::type t );
00026         void level( const std::string& logname, Debug::type t );
00027 
00028 
00029         struct LogInfo
00030         {
00031             LogInfo():log(0),logfile(""){}
00032             LogInfo( DebugStream* l ):log(l),logfile(l->getLogFile()){}
00033             DebugStream* log;
00034             std::string logfile;
00035         };
00036 
00037         DebugStream* getLog( const std::string& logname );
00038         LogInfo getLogInfo( const std::string& logname );
00039 
00040     protected:
00041         void logOnEvent( const std::string& s );
00042 
00043 
00044     private:
00045         typedef std::list<LogInfo> LogList;
00046         LogList llst;
00047 };
00048 // -------------------------------------------------------------------------
00049 #endif // LogAgregator_H_
00050 // -------------------------------------------------------------------------