1//
2// LoggingFactory.h
3//
4// Library: Foundation
5// Package: Logging
6// Module: LoggingFactory
7//
8// Definition of the LoggingFactory class.
9//
10// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// SPDX-License-Identifier: BSL-1.0
14//
15
16
17#ifndef Foundation_LoggingFactory_INCLUDED
18#define Foundation_LoggingFactory_INCLUDED
19
20
21#include "Poco/Foundation.h"
22#include "Poco/DynamicFactory.h"
23#include "Poco/Channel.h"
24#include "Poco/Formatter.h"
25
26
27namespace Poco {
28
29
30class Foundation_API LoggingFactory
31 /// An extensible factory for channels and formatters.
32 ///
33 /// The following channel classes are pre-registered:
34 /// - AsyncChannel
35 /// - ConsoleChannel
36 /// - EventLogChannel (Windows platforms only)
37 /// - FileChannel
38 /// - FormattingChannel
39 /// - NullChannel
40 /// - SplitterChannel
41 /// - SyslogChannel (Unix platforms only)
42 ///
43 /// The following formatter classes are pre-registered:
44 /// - PatternFormatter
45{
46public:
47 typedef AbstractInstantiator<Channel> ChannelInstantiator;
48 typedef AbstractInstantiator<Formatter> FormatterFactory;
49
50 LoggingFactory();
51 /// Creates the LoggingFactory.
52 ///
53 /// Automatically registers class factories for the
54 /// built-in channel and formatter classes.
55
56 ~LoggingFactory();
57 /// Destroys the LoggingFactory.
58
59 void registerChannelClass(const std::string& className, ChannelInstantiator* pFactory);
60 /// Registers a channel class with the LoggingFactory.
61
62 void registerFormatterClass(const std::string& className, FormatterFactory* pFactory);
63 /// Registers a formatter class with the LoggingFactory.
64
65 Channel::Ptr createChannel(const std::string& className) const;
66 /// Creates a new Channel instance from specified class.
67 ///
68 /// Throws a NotFoundException if the specified channel class
69 /// has not been registered.
70
71 Formatter::Ptr createFormatter(const std::string& className) const;
72 /// Creates a new Formatter instance from specified class.
73 ///
74 /// Throws a NotFoundException if the specified formatter class
75 /// has not been registered.
76
77 static LoggingFactory& defaultFactory();
78 /// Returns a reference to the default
79 /// LoggingFactory.
80
81private:
82 void registerBuiltins();
83
84 DynamicFactory<Channel> _channelFactory;
85 DynamicFactory<Formatter> _formatterFactory;
86};
87
88
89} // namespace Poco
90
91
92#endif // Foundation_LoggingFactory_INCLUDED
93