00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00023 #ifndef _CONFIGURATOR_HEADER_
00024 #define _CONFIGURATOR_HEADER_
00025
00026 #include "dcmtk/oflog/config.h"
00027 #include "dcmtk/oflog/appender.h"
00028 #include "dcmtk/oflog/hierarchy.h"
00029 #include "dcmtk/oflog/logger.h"
00030 #include "dcmtk/oflog/helpers/lloguser.h"
00031 #include "dcmtk/oflog/helpers/pointer.h"
00032 #include "dcmtk/oflog/helpers/property.h"
00033
00034
00035
00036
00037 namespace log4cplus
00038 {
00039
00056 class LOG4CPLUS_EXPORT PropertyConfigurator
00057 : protected log4cplus::helpers::LogLogUser
00058 {
00059 public:
00060 enum PCFlags
00061 {
00062 fRecursiveExpansion = 0x0001,
00063 fShadowEnvironment = 0x0002,
00064 fAllowEmptyVars = 0x0004
00065 };
00066
00067
00068 PropertyConfigurator(const log4cplus::tstring& propertyFile,
00069 Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
00070 PropertyConfigurator(const log4cplus::helpers::Properties& props,
00071 Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
00072 PropertyConfigurator(log4cplus::tistream& propertyStream,
00073 Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
00074 virtual ~PropertyConfigurator();
00075
00085 static void doConfigure(const log4cplus::tstring& configFilename,
00086 Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
00087
00234 virtual void configure();
00235
00242 log4cplus::helpers::Properties const & getProperties () const;
00243
00251 log4cplus::tstring const & getPropertyFilename () const;
00252
00253 protected:
00254
00255 void init();
00256 void reconfigure();
00257 void replaceEnvironVariables();
00258 void configureLoggers();
00259 void configureLogger(log4cplus::Logger logger, const log4cplus::tstring& config);
00260 void configureAppenders();
00261 void configureAdditivity();
00262
00263 virtual Logger getLogger(const log4cplus::tstring& name);
00264 virtual void addAppender(Logger &logger, log4cplus::SharedAppenderPtr& appender);
00265
00266
00267 typedef OFMap<log4cplus::tstring, log4cplus::SharedAppenderPtr> AppenderMap;
00268
00269
00270 Hierarchy& h;
00271 log4cplus::tstring propertyFilename;
00272 log4cplus::helpers::Properties properties;
00273 AppenderMap appenders;
00274 unsigned flags;
00275
00276 private:
00277
00278 PropertyConfigurator(const PropertyConfigurator&);
00279 PropertyConfigurator& operator=(PropertyConfigurator&);
00280 };
00281
00282
00283
00291 class LOG4CPLUS_EXPORT BasicConfigurator : public PropertyConfigurator {
00292 public:
00293
00294 BasicConfigurator(Hierarchy& h = Logger::getDefaultHierarchy());
00295 virtual ~BasicConfigurator();
00296
00306 static void doConfigure(Hierarchy& h = Logger::getDefaultHierarchy());
00307
00308 private:
00309
00310 BasicConfigurator(const BasicConfigurator&);
00311 BasicConfigurator& operator=(BasicConfigurator&);
00312 };
00313
00314
00315 #if !defined(LOG4CPLUS_SINGLE_THREADED)
00316
00317 class ConfigurationWatchDogThread;
00318
00319
00320 class LOG4CPLUS_EXPORT ConfigureAndWatchThread {
00321 public:
00322
00323 ConfigureAndWatchThread(const log4cplus::tstring& propertyFile,
00324 unsigned int millis = 60 * 1000);
00325 virtual ~ConfigureAndWatchThread();
00326
00327 private:
00328
00329 ConfigureAndWatchThread(const ConfigureAndWatchThread&);
00330 ConfigureAndWatchThread& operator=(const ConfigureAndWatchThread&);
00331
00332
00333 ConfigurationWatchDogThread * watchDogThread;
00334 };
00335 #endif
00336
00337 }
00338
00339 #endif // _CONFIGURATOR_HEADER_
00340