diff options
author | Kai Koehne <kai.koehne@digia.com> | 2014-02-04 16:35:26 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-02-11 20:59:15 +0100 |
commit | a2bfd114938e1fdd5067f2dac812a8d3a5d89fd3 (patch) | |
tree | 3a0341ab6973bc827c7e2c0f4787f23820d7adb3 /src/corelib/io/qloggingregistry_p.h | |
parent | dc09a02e3a4ea93388197d7f8a0cfebe194e9886 (diff) |
Allow configuration of logging rules from file system
Allow configuration of logging rules from outside of the application,
either through a configuration file (.config/QtProject/qtlogging.ini),
or through a file specified by a QT_LOGGING_CONF environment
variable.
The logging rules from the different sources are concatenated: First
the rules from QtProject/qtlogging.ini are applied, then
QLoggingCategory::setLoggingRules(), finally from the environment.
This allows an application to overwrite/augment the system wide rules,
and in turn that can be tailored for a specific run by setting a
configuration in the environment variable.
[ChangeLog][QtCore][Logging] The logging framework can now be configured
with an .ini file.
Change-Id: I442efde1b7e0a2ebe135c6f6e0a4b656483fe4b1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qloggingregistry_p.h')
-rw-r--r-- | src/corelib/io/qloggingregistry_p.h | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/corelib/io/qloggingregistry_p.h b/src/corelib/io/qloggingregistry_p.h index cbf7aecc4f..d4b97d42b8 100644 --- a/src/corelib/io/qloggingregistry_p.h +++ b/src/corelib/io/qloggingregistry_p.h @@ -60,6 +60,8 @@ #include <QtCore/qtextstream.h> #include <QtCore/qvector.h> +class tst_QLoggingRegistry; + QT_BEGIN_NAMESPACE class QLoggingRule @@ -89,45 +91,53 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QLoggingRule::PatternFlags) Q_DECLARE_TYPEINFO(QLoggingRule, Q_MOVABLE_TYPE); -class QLoggingRulesParser +class Q_AUTOTEST_EXPORT QLoggingSettingsParser { -private: - explicit QLoggingRulesParser(class QLoggingRegistry *logging); - public: - void setRules(const QString &content); + void setSection(const QString §ion) { _section = section; } -private: - void parseRules(QTextStream &stream); - QLoggingRegistry *registry; + void setContent(const QString &content); + void setContent(QTextStream &stream); + + QVector<QLoggingRule> rules() const { return _rules; } - friend class QLoggingRegistry; +private: + QString _section; + QVector<QLoggingRule> _rules; }; -class QLoggingRegistry +class Q_AUTOTEST_EXPORT QLoggingRegistry { public: QLoggingRegistry(); + void init(); + void registerCategory(QLoggingCategory *category); void unregisterCategory(QLoggingCategory *category); - void setRules(const QVector<QLoggingRule> &rules); + void setApiRules(const QString &content); QLoggingCategory::CategoryFilter installFilter(QLoggingCategory::CategoryFilter filter); static QLoggingRegistry *instance(); - QLoggingRulesParser rulesParser; - private: + void updateRules(); + static void defaultCategoryFilter(QLoggingCategory *category); QMutex registryMutex; + + QVector<QLoggingRule> configRules; + QVector<QLoggingRule> envRules; + QVector<QLoggingRule> apiRules; QVector<QLoggingRule> rules; QList<QLoggingCategory*> categories; QLoggingCategory::CategoryFilter categoryFilter; + + friend class ::tst_QLoggingRegistry; }; QT_END_NAMESPACE |