00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef LOG4QT_PROPERTYCONFIGURATOR_H
00026 #define LOG4QT_PROPERTYCONFIGURATOR_H
00027
00028
00029
00030
00031
00032
00033
00034 #include <QtCore/QHash>
00035 #include "log4qt/helpers/logobjectptr.h"
00036 #include "log4qt/log4qt.h"
00037
00038
00039
00040
00041
00042
00043 class QSettings;
00044
00045 namespace Log4Qt
00046 {
00047
00048 class Appender;
00049 class Layout;
00050 class ListAppender;
00051 class Logger;
00052 class Properties;
00053 class LoggerRepository;
00054
00061 class PropertyConfigurator
00062 {
00063 public:
00064 PropertyConfigurator();
00065
00066 private:
00067 PropertyConfigurator(const PropertyConfigurator &rOther);
00068 PropertyConfigurator &operator=(const PropertyConfigurator &rOther);
00069
00070 public:
00074 bool doConfigure(const Properties &rProperties,
00075 LoggerRepository *pLoggerRepository = 0);
00076
00080 bool doConfigure(const QString &rConfigFileName,
00081 LoggerRepository *pLoggerRepository = 0);
00082
00090 bool doConfigure(const QSettings &rSettings,
00091 LoggerRepository *pLoggerRepository = 0);
00092
00093
00094
00098 static bool configure(const Properties &rProperties);
00099
00103 static bool configure(const QString &rConfigFilename);
00104
00113 static bool configure(const QSettings &rSettings);
00114
00115
00116
00121 static bool configureAndWatch(const QString &rConfigFilename);
00122
00123 private:
00124 void configureFromFile(const QString &rConfigFileName,
00125 LoggerRepository *pLoggerRepository);
00126 void configureFromProperties(const Properties &rProperties,
00127 LoggerRepository *pLoggerRepository);
00128 void configureFromSettings(const QSettings &rSettings,
00129 LoggerRepository *pLoggerRepository);
00130 void configureGlobalSettings(const Properties &rProperties,
00131 LoggerRepository *pLoggerRepository) const;
00132 void configureNonRootElements(const Properties &rProperties,
00133 LoggerRepository *pLoggerRepository);
00134 void configureRootLogger(const Properties &rProperties,
00135 LoggerRepository *pLoggerRepository);
00136 void parseAdditivityForLogger(const Properties &rProperties,
00137 Logger *pLogger,
00138 const QString &rLog4jName) const;
00139 LogObjectPtr<Appender> parseAppender(const Properties &rProperties,
00140 const QString &rName);
00141 LogObjectPtr<Layout> parseLayout(const Properties &rProperties,
00142 const QString &rAppenderName);
00143 void parseLogger(const Properties &rProperties,
00144 Logger *pLogger,
00145 const QString &rKey,
00146 const QString &rValue);
00147 void setProperties(const Properties &rProperties,
00148 const QString &rPrefix,
00149 const QStringList &rExclusions,
00150 QObject *pObject);
00151 void startCaptureErrors();
00152 bool stopCaptureErrors();
00153
00154 private:
00155 LogObjectPtr<ListAppender> mpConfigureErrors;
00156 QHash< QString, LogObjectPtr<Appender> > mAppenderRegistry;
00157 };
00158
00159
00160
00161
00162
00163 #ifndef QT_NO_DEBUG_STREAM
00164
00175 QDebug operator<<(QDebug debug,
00176 const PropertyConfigurator &rPropertyConfigurator);
00177 #endif
00178
00179
00180
00181
00182
00183
00184 inline PropertyConfigurator::PropertyConfigurator()
00185 {}
00186
00187
00188 }
00189
00190
00191
00192
00193
00194 #endif // LOG4QT_PROPERTYCONFIGURATOR_H