1 /*----------------------------------------------------------------------------
2 Name: LogManager.h
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 -----------------------------------------------------------------------------*/
6
7 #ifndef _ORG_XMLBLASTER_UTIL_LOGMANAGER_H
8 #define _ORG_XMLBLASTER_UTIL_LOGMANAGER_H
9
10 #include <util/xmlBlasterDef.h>
11 #include <string>
12 #include <map>
13 #include <util/I_LogFactory.h>
14 #include <util/I_Log.h>
15
16 namespace org { namespace xmlBlaster { namespace util {
17
18 class DefaultLogFactory; // forward declaration
19
20
21 /**
22 * Manages the logging framework.
23 * <p />
24 * The logManager uses xmlBlasters own logging functionality
25 * as a default setting.
26 * You can change this and add your own logging library by providing your
27 * implementation of I_LogFactory.
28 *
29 * @author <a href="mailto:xmlBlaster@marcelruff.info">Marcel Ruff</a>
30 */
31 class Dll_Export LogManager {
32
33 public:
34 typedef org::xmlBlaster::util::I_LogFactory::PropMap PropMap;
35 typedef std::map<std::string, org::xmlBlaster::util::I_LogFactory *> LogFactoryMap;
36
37 private:
38 I_LogFactory *logFactory_;
39
40 /**
41 * Copy constructor
42 */
43 LogManager(const LogManager& rhs);
44
45 /**
46 * Assignment constructor
47 */
48 LogManager& operator=(const LogManager& rhs);
49
50 public:
51 LogManager();
52
53 virtual ~LogManager();
54
55 /**
56 * Should be called directly after the constructor.
57 */
58 void initialize(const PropMap& propMap);
59
60 /**
61 * Return the current LogFactory implementation.
62 * @param name Log implementation name (currently not supported)
63 */
64 I_LogFactory& getLogFactory(const std::string& name="DEFAULT") const;
65
66 /**
67 * Add your own LogFactory implementation.
68 * <p />
69 * We will delete it when the LogManager is destroyed or when
70 * setLogFactory() is called again.
71 * @param name Log implementation name (currently not supported, pass "")
72 * @param logFactory Your factory for your logging framework
73 */
74 void setLogFactory(const std::string& name, I_LogFactory* logFactory);
75
76 }; // end of class LogManager
77
78
79
80 /**
81 * Default implementation of our log factory.
82 * It returns the xmlBlaster native console logger with colored output on UNIX
83 */
84 class Dll_Export DefaultLogFactory : public I_LogFactory {
85 public:
86 typedef std::map<std::string, org::xmlBlaster::util::I_Log *> LogMap;
87 private:
88 LogMap logMap_;
89 public:
90 //void initialize(const PropMap& propMap);
91 //DefaultLogFactory(){};
92 virtual ~DefaultLogFactory();
93 I_Log& getLog(const std::string& name="");
94 void releaseLog(const std::string& name="");
95 }; // end of class DefaultLogFactory
96
97
98 }}} // end of namespace util
99
100 #endif // _ORG_XMLBLASTER_UTIL_LOGMANAGER_H
syntax highlighted by Code2HTML, v. 0.9.1