1 // Module:  Log4CPLUS
2 // File:    factory.cxx
3 // Created: 2/2002
4 // Author:  Tad E. Smith
5 //
6 //
7 // Copyright 2002-2010 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 
21 #include "dcmtk/oflog/spi/factory.h"
22 #include "dcmtk/oflog/spi/logfact.h"
23 #include "dcmtk/oflog/helpers/loglog.h"
24 #include "dcmtk/oflog/helpers/threadcf.h"
25 #include "dcmtk/oflog/helpers/property.h"
26 #include "dcmtk/oflog/asyncap.h"
27 #include "dcmtk/oflog/consap.h"
28 #include "dcmtk/oflog/fileap.h"
29 #include "dcmtk/oflog/ntelogap.h"
30 #include "dcmtk/oflog/nullap.h"
31 #include "dcmtk/oflog/socketap.h"
32 #include "dcmtk/oflog/syslogap.h"
33 #include "dcmtk/oflog/windebap.h"
34 #include "dcmtk/oflog/winconap.h"
35 #include "dcmtk/oflog/log4judp.h"
36 
37 
38 ///////////////////////////////////////////////////////////////////////////////
39 // LOCAL file class definitions
40 ///////////////////////////////////////////////////////////////////////////////
41 
42 namespace dcmtk {
43 namespace log4cplus {
44 
45 namespace spi {
46 
~BaseFactory()47 BaseFactory::~BaseFactory()
48 { }
49 
50 
AppenderFactory()51 AppenderFactory::AppenderFactory()
52 { }
53 
~AppenderFactory()54 AppenderFactory::~AppenderFactory()
55 { }
56 
57 
LayoutFactory()58 LayoutFactory::LayoutFactory()
59 { }
60 
~LayoutFactory()61 LayoutFactory::~LayoutFactory()
62 { }
63 
64 
FilterFactory()65 FilterFactory::FilterFactory()
66 { }
67 
~FilterFactory()68 FilterFactory::~FilterFactory()
69 { }
70 
71 
LocaleFactory()72 LocaleFactory::LocaleFactory()
73 { }
74 
~LocaleFactory()75 LocaleFactory::~LocaleFactory()
76 { }
77 
78 
~LoggerFactory()79 LoggerFactory::~LoggerFactory()
80 { }
81 
82 
83 namespace
84 {
85 
86 class GlobalLocale
87     : public LocalFactoryBase<LocaleFactory>
88 {
89 public:
GlobalLocale(tchar const * n)90     GlobalLocale (tchar const * n)
91         : LocalFactoryBase<LocaleFactory> (n)
92     { }
93 
94     virtual
95     ProductPtr
createObject(const log4cplus::helpers::Properties &)96     createObject (const log4cplus::helpers::Properties &)
97     {
98         return STD_NAMESPACE locale ();
99     }
100 };
101 
102 
103 class UserLocale
104     : public LocalFactoryBase<LocaleFactory>
105 {
106 public:
UserLocale(tchar const * n)107     UserLocale (tchar const * n)
108         : LocalFactoryBase<LocaleFactory> (n)
109     { }
110 
111     virtual
112     ProductPtr
createObject(const log4cplus::helpers::Properties &)113     createObject (const log4cplus::helpers::Properties &)
114     {
115         return STD_NAMESPACE locale ("");
116     }
117 };
118 
119 
120 class ClassicLocale
121     : public LocalFactoryBase<LocaleFactory>
122 {
123 public:
ClassicLocale(tchar const * n)124     ClassicLocale (tchar const * n)
125         : LocalFactoryBase<LocaleFactory> (n)
126     { }
127 
128     virtual
129     ProductPtr
createObject(const log4cplus::helpers::Properties &)130     createObject (const log4cplus::helpers::Properties &)
131     {
132         return STD_NAMESPACE locale::classic ();
133     }
134 };
135 
136 
137 } // namespace
138 
139 
140 
141 
142 } // namespace spi
143 
144 
145 void initializeFactoryRegistry();
initializeFactoryRegistry()146 void initializeFactoryRegistry()
147 {
148     spi::AppenderFactoryRegistry& reg = spi::getAppenderFactoryRegistry();
149     DCMTK_LOG4CPLUS_REG_APPENDER (reg, ConsoleAppender);
150     DCMTK_LOG4CPLUS_REG_APPENDER (reg, NullAppender);
151     DCMTK_LOG4CPLUS_REG_APPENDER (reg, FileAppender);
152     DCMTK_LOG4CPLUS_REG_APPENDER (reg, RollingFileAppender);
153     DCMTK_LOG4CPLUS_REG_APPENDER (reg, DailyRollingFileAppender);
154     DCMTK_LOG4CPLUS_REG_APPENDER (reg, SocketAppender);
155 #if defined(_WIN32)
156 #  if defined(DCMTK_LOG4CPLUS_HAVE_NT_EVENT_LOG)
157     DCMTK_LOG4CPLUS_REG_APPENDER (reg, NTEventLogAppender);
158 #  endif
159 #  if defined(DCMTK_LOG4CPLUS_HAVE_WIN32_CONSOLE)
160     DCMTK_LOG4CPLUS_REG_APPENDER (reg, Win32ConsoleAppender);
161 #  endif
162     DCMTK_LOG4CPLUS_REG_APPENDER (reg, Win32DebugAppender);
163 #endif
164     DCMTK_LOG4CPLUS_REG_APPENDER (reg, SysLogAppender);
165 #ifndef DCMTK_LOG4CPLUS_SINGLE_THREADED
166     DCMTK_LOG4CPLUS_REG_APPENDER (reg, AsyncAppender);
167 #endif
168     DCMTK_LOG4CPLUS_REG_APPENDER (reg, Log4jUdpAppender);
169 
170     spi::LayoutFactoryRegistry& reg2 = spi::getLayoutFactoryRegistry();
171     DCMTK_LOG4CPLUS_REG_LAYOUT (reg2, SimpleLayout);
172     DCMTK_LOG4CPLUS_REG_LAYOUT (reg2, TTCCLayout);
173     DCMTK_LOG4CPLUS_REG_LAYOUT (reg2, PatternLayout);
174 
175     spi::FilterFactoryRegistry& reg3 = spi::getFilterFactoryRegistry();
176     DCMTK_LOG4CPLUS_REG_FILTER (reg3, DenyAllFilter);
177     DCMTK_LOG4CPLUS_REG_FILTER (reg3, LogLevelMatchFilter);
178     DCMTK_LOG4CPLUS_REG_FILTER (reg3, LogLevelRangeFilter);
179     DCMTK_LOG4CPLUS_REG_FILTER (reg3, StringMatchFilter);
180 
181     spi::LocaleFactoryRegistry& reg4 = spi::getLocaleFactoryRegistry();
182     DCMTK_LOG4CPLUS_REG_LOCALE (reg4, DCMTK_LOG4CPLUS_TEXT("GLOBAL"), spi::GlobalLocale);
183     DCMTK_LOG4CPLUS_REG_LOCALE (reg4, DCMTK_LOG4CPLUS_TEXT("DEFAULT"), spi::GlobalLocale);
184     DCMTK_LOG4CPLUS_REG_LOCALE (reg4, DCMTK_LOG4CPLUS_TEXT("USER"), spi::UserLocale);
185     DCMTK_LOG4CPLUS_REG_LOCALE (reg4, DCMTK_LOG4CPLUS_TEXT("CLASSIC"), spi::ClassicLocale);
186 }
187 
188 
189 } // namespace log4cplus
190 } // end namespace dcmtk
191