00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkLoggerManager.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005/11/05 03:49:12 $ 00007 Version: $Revision: 1.5 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #ifndef __itk_LoggerManager_h 00019 #define __itk_LoggerManager_h 00020 00021 #if defined(_MSC_VER) 00022 //Warning about: identifier was truncated to '255' characters in the debug information (MVC6.0 Debug) 00023 #pragma warning( disable : 4786 ) 00024 // warning C4503: 'insert' : decorated name length exceeded, name was truncated 00025 #pragma warning ( disable : 4503 ) 00026 #endif 00027 00028 #include "itkMacro.h" 00029 #include "itkObject.h" 00030 #include "itkObjectFactory.h" 00031 #include "itkLogger.h" 00032 #include "itkThreadLogger.h" 00033 00034 #include <string> 00035 #include <map> 00036 00037 namespace itk 00038 { 00052 class ITKCommon_EXPORT LoggerManager : public Object 00053 { 00054 00055 public: 00056 00057 typedef LoggerManager Self; 00058 typedef Object Superclass; 00059 typedef SmartPointer<Self> Pointer; 00060 typedef SmartPointer<const Self> ConstPointer; 00061 00063 itkTypeMacro( LoggerManager, Object ); 00064 00066 itkNewMacro( Self ); 00067 00068 typedef Logger::PriorityLevelType PriorityLevelType; 00069 00070 typedef Logger::OutputType OutputType; 00071 00072 typedef Logger::Pointer LoggerPointer; 00073 typedef ThreadLogger::Pointer ThreadLoggerPointer; 00074 00075 typedef std::string NameType; 00076 00078 LoggerPointer CreateLogger( 00079 const NameType &name, 00080 PriorityLevelType level, 00081 PriorityLevelType levelForFlushing = LoggerBase::MUSTFLUSH ); 00082 00084 ThreadLoggerPointer CreateThreadLogger( 00085 const NameType &name, 00086 PriorityLevelType level, 00087 PriorityLevelType levelForFlushing = LoggerBase::MUSTFLUSH ); 00088 00090 void AddLogger( const NameType &name, Logger* logger ); 00091 00092 Logger* GetLogger( const NameType &name); 00093 00094 void SetPriorityLevel( PriorityLevelType level ); 00095 00096 void SetLevelForFlushing( PriorityLevelType level ); 00097 00098 void AddLogOutput( OutputType* output ); 00099 00100 void Write( PriorityLevelType level, std::string const & content); 00101 00102 void Flush(); 00103 00104 protected: 00105 00107 LoggerManager() {} 00108 00110 virtual ~LoggerManager() {} 00111 00113 void PrintSelf(std::ostream &s, Indent indent) const; 00114 00115 private: 00116 00117 typedef std::map< NameType, LoggerPointer > ContainerType; 00118 00119 ContainerType m_LoggerSet; 00120 00121 }; // class Logger 00122 00123 00124 } // namespace itk 00125 00126 00127 #endif // __itk_LoggerManager_h