OFFIS DCMTK  Version 3.6.0
configrt.h
Go to the documentation of this file.
1 // Module: Log4CPLUS
2 // File: configurator.h
3 // Created: 3/2003
4 // Author: Tad E. Smith
5 //
6 //
7 // Copyright 2003-2009 Tad E. Smith
8 //
9 // Licensed under the Apache License, Version 2.0 (the "License");
10 // you may not use this file except in compliance with the License.
11 // You may obtain a copy of the License at
12 //
13 // http://www.apache.org/licenses/LICENSE-2.0
14 //
15 // Unless required by applicable law or agreed to in writing, software
16 // distributed under the License is distributed on an "AS IS" BASIS,
17 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 // See the License for the specific language governing permissions and
19 // limitations under the License.
20 
23 #ifndef _CONFIGURATOR_HEADER_
24 #define _CONFIGURATOR_HEADER_
25 
26 #include "dcmtk/oflog/config.h"
27 #include "dcmtk/oflog/appender.h"
28 #include "dcmtk/oflog/hierarchy.h"
29 #include "dcmtk/oflog/logger.h"
33 
34 //#include <map>
35 
36 
37 namespace log4cplus
38 {
39 
56  class LOG4CPLUS_EXPORT PropertyConfigurator
58  {
59  public:
60  enum PCFlags
61  {
62  fRecursiveExpansion = 0x0001,
63  fShadowEnvironment = 0x0002,
64  fAllowEmptyVars = 0x0004
65  };
66 
67  // ctor and dtor
68  PropertyConfigurator(const log4cplus::tstring& propertyFile,
69  Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
71  Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
72  PropertyConfigurator(log4cplus::tistream& propertyStream,
73  Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
74  virtual ~PropertyConfigurator();
75 
85  static void doConfigure(const log4cplus::tstring& configFilename,
86  Hierarchy& h = Logger::getDefaultHierarchy(), unsigned flags = 0);
87 
234  virtual void configure();
235 
242  log4cplus::helpers::Properties const & getProperties () const;
243 
251  log4cplus::tstring const & getPropertyFilename () const;
252 
253  protected:
254  // Methods
255  void init(); // called by the ctor
256  void reconfigure();
257  void replaceEnvironVariables();
258  void configureLoggers();
259  void configureLogger(log4cplus::Logger logger, const log4cplus::tstring& config);
260  void configureAppenders();
261  void configureAdditivity();
262 
263  virtual Logger getLogger(const log4cplus::tstring& name);
264  virtual void addAppender(Logger &logger, log4cplus::SharedAppenderPtr& appender);
265 
266  // Types
268 
269  // Data
270  Hierarchy& h;
271  log4cplus::tstring propertyFilename;
273  AppenderMap appenders;
274  unsigned flags;
275 
276  private:
277  // Disable copy
280  };
281 
282 
283 
291  class LOG4CPLUS_EXPORT BasicConfigurator : public PropertyConfigurator {
292  public:
293  // ctor and dtor
295  virtual ~BasicConfigurator();
296 
306  static void doConfigure(Hierarchy& h = Logger::getDefaultHierarchy());
307 
308  private:
309  // Disable copy
312  };
313 
314 
315 #if !defined(LOG4CPLUS_SINGLE_THREADED)
316  // Forward Declarations
317  class ConfigurationWatchDogThread;
318 
319 
320  class LOG4CPLUS_EXPORT ConfigureAndWatchThread {
321  public:
322  // ctor and dtor
323  ConfigureAndWatchThread(const log4cplus::tstring& propertyFile,
324  unsigned int millis = 60 * 1000);
325  virtual ~ConfigureAndWatchThread();
326 
327  private:
328  // Disallow copying of instances of this class
331 
332  // Data
333  ConfigurationWatchDogThread * watchDogThread;
334  };
335 #endif
336 
337 } // end namespace log4cplus
338 
339 #endif // _CONFIGURATOR_HEADER_
340 


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2