summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Weimer <bernd.weimer@pelagicore.com>2018-02-20 11:19:22 +0100
committerRobert Griebl <robert.griebl@pelagicore.com>2018-02-28 20:35:31 +0000
commit10bd05d531720140c649331104dd5351224d1336 (patch)
tree4740eca9c76d3bb91cba1c695e2766af83712fd5
parentcef9818e5c757115d023d9c97c0f83fe00c4285f (diff)
Add new "deployment" logging category
This new logging category has been introduced in order to get finer control on warnings at startup. Also logging is delayed until rules are set. Change-Id: I311d8ba929f474120665c96f854bae4a48f9ebb9 Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
-rw-r--r--examples/custom-appman/custom-appman.cpp5
-rw-r--r--src/common-lib/logging.cpp8
-rw-r--r--src/common-lib/logging.h1
-rw-r--r--src/installer-lib/sudo.cpp12
-rw-r--r--src/installer-lib/sudo.h2
-rw-r--r--src/launchers/qml/main.cpp15
-rw-r--r--src/main-lib/configuration.cpp4
-rw-r--r--src/main-lib/main.cpp14
-rw-r--r--src/main-lib/main.h2
-rw-r--r--src/tools/appman/appman.cpp5
10 files changed, 44 insertions, 24 deletions
diff --git a/examples/custom-appman/custom-appman.cpp b/examples/custom-appman/custom-appman.cpp
index 9b07ec3a..ea23421b 100644
--- a/examples/custom-appman/custom-appman.cpp
+++ b/examples/custom-appman/custom-appman.cpp
@@ -70,7 +70,8 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
Package::ensureCorrectLocale();
QString error;
- if (Q_UNLIKELY(!forkSudoServer(DropPrivilegesPermanently, &error))) {
+ QStringList warnings;
+ if (Q_UNLIKELY(!forkSudoServer(DropPrivilegesPermanently, &error, &warnings))) {
qCCritical(LogSystem) << "ERROR:" << qPrintable(error);
return 2;
}
@@ -81,7 +82,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
DefaultConfiguration cfg;
cfg.parse();
- a.setup(&cfg);
+ a.setup(&cfg, &warnings);
a.loadQml(cfg.loadDummyData());
a.showWindow(cfg.fullscreen() && !cfg.noFullscreen());
diff --git a/src/common-lib/logging.cpp b/src/common-lib/logging.cpp
index c93b668d..acab9936 100644
--- a/src/common-lib/logging.cpp
+++ b/src/common-lib/logging.cpp
@@ -74,13 +74,14 @@ QT_BEGIN_NAMESPACE_AM
/*
//! [am-logging-categories]
\list
+\li \c am.system - General system messages
+\li \c am.runtime.qml - QML runtime
+\li \c am.graphics - OpenGL/Wayland related messages
+\li \c am.deployment - Deployment hints"
\li \c am.installer - Installer sub-system
\li \c am.notify - Notification sub-system
\li \c am.qml - QML messages
\li \c am.qml.ipc - QML IPC
-\li \c am.runtime.qml - QML runtime
-\li \c am.system - General system messages
-\li \c am.graphics - OpenGL/Wayland related messages
\li \c general - General messages not part of any ApplicationManager sub-system
\endlist
//! [am-logging-categories]
@@ -94,6 +95,7 @@ QDLT_LOGGING_CATEGORY(LogQml, "am.qml", "QML", "QML messages")
QDLT_LOGGING_CATEGORY(LogNotifications, "am.notify", "NTFY", "Notification sub-system")
QDLT_LOGGING_CATEGORY(LogQmlRuntime, "am.runtime.qml", "QMRT", "QML runtime")
QDLT_LOGGING_CATEGORY(LogQmlIpc, "am.qml.ipc", "QMIP", "QML IPC")
+QDLT_LOGGING_CATEGORY(LogDeployment, "am.deployment", "DPLM", "Deployment hints")
QDLT_LOGGING_CATEGORY(LogGeneral, "general", "GEN", "General messages not part of any ApplicationManager sub-system")
QDLT_FALLBACK_CATEGORY(LogGeneral)
diff --git a/src/common-lib/logging.h b/src/common-lib/logging.h
index 58c66cfc..a969261c 100644
--- a/src/common-lib/logging.h
+++ b/src/common-lib/logging.h
@@ -53,6 +53,7 @@ Q_DECLARE_LOGGING_CATEGORY(LogQml)
Q_DECLARE_LOGGING_CATEGORY(LogNotifications)
Q_DECLARE_LOGGING_CATEGORY(LogQmlRuntime)
Q_DECLARE_LOGGING_CATEGORY(LogQmlIpc)
+Q_DECLARE_LOGGING_CATEGORY(LogDeployment)
class Logging
{
diff --git a/src/installer-lib/sudo.cpp b/src/installer-lib/sudo.cpp
index c8fba80a..09c4623f 100644
--- a/src/installer-lib/sudo.cpp
+++ b/src/installer-lib/sudo.cpp
@@ -126,7 +126,7 @@ QT_END_NAMESPACE_AM
QT_BEGIN_NAMESPACE_AM
-bool forkSudoServer(SudoDropPrivileges dropPrivileges, QString *errorString)
+bool forkSudoServer(SudoDropPrivileges dropPrivileges, QString *errorString, QStringList *warnings)
{
bool canSudo = false;
int loopControlFd = -1;
@@ -138,8 +138,8 @@ bool forkSudoServer(SudoDropPrivileges dropPrivileges, QString *errorString)
// check for new style loopback device control
loopControlFd = EINTR_LOOP(open("/dev/loop-control", O_RDWR));
- if (canSudo && (loopControlFd < 0))
- qCCritical(LogSystem) << "WARNING: could not open /dev/loop-control, which is needed by the installer for SD-Card installations";
+ if (warnings && canSudo && (loopControlFd < 0))
+ *warnings << qSL("Could not open /dev/loop-control, which is needed by the installer for SD-Card installations");
#else
Q_UNUSED(errorString)
Q_UNUSED(dropPrivileges)
@@ -148,8 +148,10 @@ bool forkSudoServer(SudoDropPrivileges dropPrivileges, QString *errorString)
if (!canSudo) {
SudoServer::initialize(-1, loopControlFd);
SudoClient::initialize(-1, SudoServer::instance());
- qCCritical(LogSystem) << "WARNING: for the installer to work correctly, the executable needs to be run either as root via sudo or SUID (preferred)";
- qCCritical(LogSystem) << " (using fallback implementation - you might experience permission errors on installer operations)";
+ if (warnings) {
+ *warnings << qSL("For the installer to work correctly, the executable needs to be run either as root via sudo or SUID (preferred)");
+ *warnings << qSL("(using fallback implementation - you might experience permission errors on installer operations)");
+ }
return true;
}
diff --git a/src/installer-lib/sudo.h b/src/installer-lib/sudo.h
index d1cfceed..40517439 100644
--- a/src/installer-lib/sudo.h
+++ b/src/installer-lib/sudo.h
@@ -63,7 +63,7 @@ enum SudoDropPrivileges {
DropPrivilegesRegainable, // only use this for auto-tests
};
-bool forkSudoServer(SudoDropPrivileges dropPrivileges, QString *errorString);
+bool forkSudoServer(SudoDropPrivileges dropPrivileges, QString *errorString, QStringList *warnings = nullptr);
class SudoInterface
{
diff --git a/src/launchers/qml/main.cpp b/src/launchers/qml/main.cpp
index 45213756..9a63ccb2 100644
--- a/src/launchers/qml/main.cpp
+++ b/src/launchers/qml/main.cpp
@@ -224,17 +224,22 @@ Controller::Controller(LauncherMain *a, bool quickLaunched, const QString &direc
m_configuration = a->runtimeConfiguration();
+ QString absolutePath;
QStringList importPaths = variantToStringList(m_configuration.value(qSL("importPaths")));
for (QString &path : importPaths) {
- if (QFileInfo(path).isRelative()) {
+ if (QFileInfo(path).isRelative())
path.prepend(a->baseDir());
- } else {
- qCWarning(LogQmlRuntime) << "Absolute import paths in the runtime configuration can lead to problems inside containers:"
- << path;
- }
+ else if (absolutePath.isEmpty())
+ absolutePath = path;
+
m_engine.addImportPath(path);
}
+ if (!absolutePath.isEmpty()) {
+ qCWarning(LogDeployment).nospace() << "Absolute import path in the runtime configuration "
+ "can lead to problems inside containers (e.g. " << absolutePath << ")";
+ }
+
StartupTimer::instance()->checkpoint("after application config initialization");
// This is a bit of a hack to make ApplicationManagerWindow known as a sub-class
diff --git a/src/main-lib/configuration.cpp b/src/main-lib/configuration.cpp
index 4771ccd0..763dd473 100644
--- a/src/main-lib/configuration.cpp
+++ b/src/main-lib/configuration.cpp
@@ -312,7 +312,7 @@ void Configuration::parse()
qCDebug(LogSystem) << "Config parsing: cache loaded after" << (timer.nsecsElapsed() / 1000) << "usec";
#endif
} catch (const Exception &e) {
- qCWarning(LogSystem) << "Failed to read config cache:" << e.what();
+ qCDebug(LogSystem) << "Failed to read config cache:" << e.what();
}
}
}
@@ -331,7 +331,7 @@ void Configuration::parse()
QByteArray checksum = QCryptographicHash::hash(cf.content, QCryptographicHash::Sha1);
if (useCache && (checksum != cf.checksum)) {
- qCWarning(LogSystem) << "Failed to read config cache: cached config file checksums do not match current set";
+ qCDebug(LogSystem) << "Failed to read config cache: cached config file checksums do not match current set";
useCache = false;
}
cf.checksum = checksum;
diff --git a/src/main-lib/main.cpp b/src/main-lib/main.cpp
index 5e9a5be9..fb85cb14 100644
--- a/src/main-lib/main.cpp
+++ b/src/main-lib/main.cpp
@@ -194,7 +194,7 @@ Main::~Main()
The caller has to make sure that cfg will be available even after this function returns:
we will access the cfg object from delayed init functions via lambdas!
*/
-void Main::setup(const DefaultConfiguration *cfg) Q_DECL_NOEXCEPT_EXPR(false)
+void Main::setup(const DefaultConfiguration *cfg, QStringList *deploymentWarnings) Q_DECL_NOEXCEPT_EXPR(false)
{
// basics that are needed in multiple setup functions below
m_noSecurity = cfg->noSecurity();
@@ -205,6 +205,14 @@ void Main::setup(const DefaultConfiguration *cfg) Q_DECL_NOEXCEPT_EXPR(false)
setupLoggingRules(cfg->verbose(), cfg->loggingRules());
setupQmlDebugging(cfg->qmlDebugging());
Logging::registerUnregisteredDltContexts();
+
+ // dump accumulated warnings, now that logging rules are set
+ if (deploymentWarnings) {
+ for (const QString &warning : *deploymentWarnings)
+ qCWarning(LogDeployment).noquote() << warning;
+ deploymentWarnings->clear();
+ }
+
setupOpenGL(cfg->openGLConfiguration());
loadStartupPlugins(cfg->pluginFilePaths("startup"));
@@ -475,8 +483,8 @@ void Main::setupInstaller(const QString &appImageMountDir, const QStringList &ca
#if !defined(AM_DISABLE_INSTALLER)
if (!Package::checkCorrectLocale()) {
// we should really throw here, but so many embedded systems are badly set up
- qCCritical(LogSystem) << "WARNING: the appman installer needs a UTF-8 locale to work correctly:\n"
- " even automatically switching to C.UTF-8 or en_US.UTF-8 failed.";
+ qCWarning(LogDeployment) << "The appman installer needs a UTF-8 locale to work correctly:\n"
+ "even automatically switching to C.UTF-8 or en_US.UTF-8 failed.";
}
if (Q_UNLIKELY(hardwareId().isEmpty()))
diff --git a/src/main-lib/main.h b/src/main-lib/main.h
index dc983686..9354d1d2 100644
--- a/src/main-lib/main.h
+++ b/src/main-lib/main.h
@@ -93,7 +93,7 @@ public:
bool isSingleProcessMode() const;
- void setup(const DefaultConfiguration *cfg) Q_DECL_NOEXCEPT_EXPR(false);
+ void setup(const DefaultConfiguration *cfg, QStringList *deploymentWarnings = nullptr) Q_DECL_NOEXCEPT_EXPR(false);
void loadQml(bool loadDummyData) Q_DECL_NOEXCEPT_EXPR(false);
void showWindow(bool showFullscreen);
diff --git a/src/tools/appman/appman.cpp b/src/tools/appman/appman.cpp
index cfd7d229..213d9dfd 100644
--- a/src/tools/appman/appman.cpp
+++ b/src/tools/appman/appman.cpp
@@ -84,7 +84,8 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
Package::ensureCorrectLocale();
QString error;
- if (Q_UNLIKELY(!forkSudoServer(DropPrivilegesPermanently, &error))) {
+ QStringList warnings;
+ if (Q_UNLIKELY(!forkSudoServer(DropPrivilegesPermanently, &error, &warnings))) {
qCCritical(LogSystem) << "ERROR:" << qPrintable(error);
return 2;
}
@@ -111,7 +112,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
#if defined(AM_TESTRUNNER)
TestRunner::initialize(cfg.testRunnerArguments());
#endif
- a.setup(&cfg);
+ a.setup(&cfg, &warnings);
#if defined(AM_TESTRUNNER)
a.qmlEngine()->rootContext()->setContextProperty("buildConfig", cfg.buildConfig());
#endif