| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkLoggerManager.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:41 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
|
| 18 |
DEF |
#ifndef __itk_LoggerManager_h |
| 19 |
DEF |
#define __itk_LoggerManager_h |
| 20 |
|
|
| 21 |
|
#if defined(_MSC_VER) |
| 22 |
LEN,IND |
***//Warning about: identifier was truncated to '255' characters in the debug information (MVC6.0 Debug) |
| 23 |
IND |
***#pragma warning( disable : 4786 ) |
| 24 |
LEN,IND |
**// warning C4503: 'insert' : decorated name length exceeded, name was truncated |
| 25 |
IND |
**#pragma warning ( disable : 4503 ) |
| 26 |
|
#endif |
| 27 |
|
|
| 28 |
|
#include "itkMacro.h" |
| 29 |
|
#include "itkObject.h" |
| 30 |
|
#include "itkObjectFactory.h" |
| 31 |
|
#include "itkLogger.h" |
| 32 |
|
#include "itkThreadLogger.h" |
| 33 |
|
|
| 34 |
|
#include <string> |
| 35 |
|
#include <map> |
| 36 |
|
|
| 37 |
|
namespace itk |
| 38 |
|
{ |
| 39 |
|
/** \class LoggerManager |
| 40 |
|
* \brief Class LoggerManager is meant for centrally managing loggers. |
| 41 |
|
* |
| 42 |
|
* |
| 43 |
|
* |
| 44 |
|
* \author Hee-Su Kim, Compute Science Dept. Kyungpook National University, |
| 45 |
|
* ISIS Center, Georgetown University. |
| 46 |
|
* |
| 47 |
|
* |
| 48 |
|
* \ingroup OSSystemObjects LoggingObjects |
| 49 |
|
* |
| 50 |
|
*/ |
| 51 |
|
|
| 52 |
|
class ITKCommon_EXPORT LoggerManager : public Object |
| 53 |
|
{ |
| 54 |
|
|
| 55 |
|
public: |
| 56 |
|
|
| 57 |
|
typedef LoggerManager Self; |
| 58 |
TDA |
typedef Object Superclass; |
| 59 |
TDA |
typedef SmartPointer<Self> Pointer; |
| 60 |
TDA |
typedef SmartPointer<const Self> ConstPointer; |
| 61 |
|
|
| 62 |
|
/** Run-time type information (and related methods). */ |
| 63 |
|
itkTypeMacro( LoggerManager, Object ); |
| 64 |
|
|
| 65 |
|
/** New macro for creation of through a Smart Pointer */ |
| 66 |
|
itkNewMacro( Self ); |
| 67 |
|
|
| 68 |
|
typedef Logger::PriorityLevelType PriorityLevelType; |
| 69 |
|
|
| 70 |
|
typedef Logger::OutputType OutputType; |
| 71 |
|
|
| 72 |
|
typedef Logger::Pointer LoggerPointer; |
| 73 |
|
typedef ThreadLogger::Pointer ThreadLoggerPointer; |
| 74 |
|
|
| 75 |
|
typedef std::string NameType; |
| 76 |
|
|
| 77 |
|
/** create a logger and add it into LoggerManager */ |
| 78 |
|
LoggerPointer CreateLogger( |
| 79 |
|
const NameType &name, |
| 80 |
|
PriorityLevelType level, |
| 81 |
LEN |
PriorityLevelType levelForFlushing = LoggerBase::MUSTFLUSH ); |
| 82 |
|
|
| 83 |
|
/** create a thread logger and add it into LoggerManager */ |
| 84 |
|
ThreadLoggerPointer CreateThreadLogger( |
| 85 |
|
const NameType &name, |
| 86 |
|
PriorityLevelType level, |
| 87 |
LEN |
PriorityLevelType levelForFlushing = LoggerBase::MUSTFLUSH ); |
| 88 |
|
|
| 89 |
|
/** Registers a logger */ |
| 90 |
|
void AddLogger( const NameType &name, Logger* logger ); |
| 91 |
|
|
| 92 |
|
Logger* GetLogger( const NameType &name); |
| 93 |
|
|
| 94 |
|
void SetPriorityLevel( PriorityLevelType level ); |
| 95 |
|
|
| 96 |
|
void SetLevelForFlushing( PriorityLevelType level ); |
| 97 |
|
|
| 98 |
|
void AddLogOutput( OutputType* output ); |
| 99 |
|
|
| 100 |
|
void Write( PriorityLevelType level, std::string const & content); |
| 101 |
|
|
| 102 |
|
void Flush(); |
| 103 |
|
|
| 104 |
|
protected: |
| 105 |
|
|
| 106 |
|
/** Constructor */ |
| 107 |
|
LoggerManager() {} |
| 108 |
|
|
| 109 |
|
/** Destructor */ |
| 110 |
|
virtual ~LoggerManager() {} |
| 111 |
|
|
| 112 |
|
/** Print contents of a LoggerManager */ |
| 113 |
|
void PrintSelf(std::ostream &s, Indent indent) const; |
| 114 |
|
|
| 115 |
|
private: |
| 116 |
|
|
| 117 |
|
typedef std::map< NameType, LoggerPointer > ContainerType; |
| 118 |
|
|
| 119 |
|
ContainerType m_LoggerSet; |
| 120 |
|
|
| 121 |
|
}; // class Logger |
| 122 |
|
|
| 123 |
|
|
| 124 |
|
} // namespace itk |
| 125 |
|
|
| 126 |
|
|
| 127 |
|
#endif // __itk_LoggerManager_h |
| 128 |
|
|