Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

configurator.h

Go to the documentation of this file.
00001 // Module:  Log4CPLUS
00002 // File:    configurator.h
00003 // Created: 3/2003
00004 // Author:  Tad E. Smith
00005 //
00006 //
00007 // Copyright (C) Tad E. Smith  All rights reserved.
00008 //
00009 // This software is published under the terms of the Apache Software
00010 // License version 1.1, a copy of which has been included with this
00011 // distribution in the LICENSE.APL file.
00012 //
00013 
00016 #ifndef _CONFIGURATOR_HEADER_
00017 #define _CONFIGURATOR_HEADER_
00018 
00019 #include <log4cplus/config.h>
00020 #include <log4cplus/appender.h>
00021 #include <log4cplus/hierarchy.h>
00022 #include <log4cplus/logger.h>
00023 #include <log4cplus/helpers/logloguser.h>
00024 #include <log4cplus/helpers/pointer.h>
00025 #include <log4cplus/helpers/property.h>
00026 
00027 #include <map>
00028 
00029 
00030 namespace log4cplus {
00031 
00048     class LOG4CPLUS_EXPORT PropertyConfigurator : protected log4cplus::helpers::LogLogUser
00049     {
00050     public:
00051         // ctor and dtor
00052         PropertyConfigurator(const log4cplus::tstring& propertyFile,
00053                              Hierarchy& h = Logger::getDefaultHierarchy());
00054         PropertyConfigurator(const log4cplus::helpers::Properties& props,
00055                              Hierarchy& h = Logger::getDefaultHierarchy());
00056         PropertyConfigurator(log4cplus::tistream& propertyStream,
00057                              Hierarchy& h = Logger::getDefaultHierarchy());
00058         virtual ~PropertyConfigurator();
00059 
00069         static void doConfigure(const log4cplus::tstring& configFilename,
00070                                 Hierarchy& h = Logger::getDefaultHierarchy());
00071 
00217         virtual void configure();
00218 
00219     protected:
00220       // Methods
00221         void init();  // called by the ctor
00222         void reconfigure();
00223         void replaceEnvironVariables();
00224         void configureLoggers();
00225         void configureLogger(log4cplus::Logger logger, const log4cplus::tstring& config);
00226         void configureAppenders();
00227         void configureAdditivity();
00228         
00229         virtual Logger getLogger(const log4cplus::tstring& name);
00230         virtual void addAppender(Logger &logger, log4cplus::SharedAppenderPtr& appender);
00231 
00232       // Types
00233         typedef std::map<log4cplus::tstring, log4cplus::SharedAppenderPtr> AppenderMap;
00234 
00235       // Data
00236         Hierarchy& h;
00237         log4cplus::tstring propertyFilename;
00238         log4cplus::helpers::Properties properties; 
00239         AppenderMap appenders;
00240         
00241     private:
00242       // Disable copy
00243         PropertyConfigurator(const PropertyConfigurator&);
00244         PropertyConfigurator& operator=(PropertyConfigurator&);
00245     };
00246 
00247 
00248 
00253     class LOG4CPLUS_EXPORT BasicConfigurator : public PropertyConfigurator {
00254     public:
00255       // ctor and dtor
00256         BasicConfigurator(Hierarchy& h = Logger::getDefaultHierarchy());
00257         virtual ~BasicConfigurator();
00258 
00268         static void doConfigure(Hierarchy& h = Logger::getDefaultHierarchy());
00269         
00270     private:
00271       // Disable copy
00272         BasicConfigurator(const BasicConfigurator&);
00273         BasicConfigurator& operator=(BasicConfigurator&);
00274     };
00275    
00276 
00277 #if !defined(LOG4CPLUS_SINGLE_THREADED)
00278     // Forward Declarations
00279     class ConfigurationWatchDogThread;
00280     
00281     
00282     class LOG4CPLUS_EXPORT ConfigureAndWatchThread {
00283     public:
00284       // ctor and dtor
00285         ConfigureAndWatchThread(const log4cplus::tstring& propertyFile,
00286                                 unsigned int millis = 60 * 1000);
00287         virtual ~ConfigureAndWatchThread();
00288 
00289     private:
00290       // Disallow copying of instances of this class
00291        ConfigureAndWatchThread(const ConfigureAndWatchThread&);
00292        ConfigureAndWatchThread& operator=(const ConfigureAndWatchThread&);
00293        
00294       // Data
00295         log4cplus::helpers::SharedObjectPtr<ConfigurationWatchDogThread> watchDogThread;
00296     };
00297 #endif
00298 
00299 } // end namespace log4cplus
00300 
00301 #endif // _CONFIGURATOR_HEADER_
00302 

Generated on Mon Feb 9 09:10:30 2004 for log4cplus by doxygen 1.3.2