<table><tr><td style="">sebas created this revision.<br />sebas added a reviewer: Plasma.<br />Restricted Application added a project: Plasma.<br />Restricted Application added a subscriber: plasma-devel.</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D2295" rel="noreferrer">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>Debugging kscreen is generally really hard since it's spread across different <br />
processes, not all of which are easy to look into.</p>

<p>With this change, we collect all of kscreen's debug output (from kcm, kded <br />
and backendlauncher) and write them to a log file.</p>

<p>This means that we can look into one log file, and see exactly what's going <br />
on, and in which component. It makes collecting debug info much easier.</p>

<p>This is implemented in the form of a QMessageHandler, hooking into the <br />
qCDebug calls. This is a pretty neat solution, since:</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">we can make use of the stream operators from qDebug</li>
<li class="remarkup-list-item">we don't need to rewrite all the debug statements</li>
<li class="remarkup-list-item">normal debug is otherwise still working</li>
</ul>

<p>The general idea is that we cache file names and initialization from the<br />
env vars on first creation, allow subsequent context changes. The log file <br />
is opened and closed right away, since other processes may want to also <br />
write to it.</p>

<p>We don't do any file-locking to keep things simple. The logging isn't<br />
mission-critical, but rather a debugging tool for users. If we end up<br />
with corrupt logs, that's bad luck (but can happen due to multi-process<br />
race conditions). More advanced multi-process locking and delayed<br />
writing is just going to give us headaches, so we avoid that at the<br />
price of logs not being 100% reliably formatted.</p>

<p>Also:</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">disable logging for most autotests</li>
<li class="remarkup-list-item">all messages are then passed to the previously installed messagehandler.</li>
</ul></div></div><br /><div><strong>TEST PLAN</strong><div><p>new code comes with autotests</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>rLIBKSCREEN KScreen Library</div></div></div><br /><div><strong>BRANCH</strong><div><div>sebas/log</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D2295" rel="noreferrer">https://phabricator.kde.org/D2295</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>autotests/CMakeLists.txt<br />
autotests/testbackendloader.cpp<br />
autotests/testconfigmonitor.cpp<br />
autotests/testinprocess.cpp<br />
autotests/testkwaylandbackend.cpp<br />
autotests/testkwaylandconfig.cpp<br />
autotests/testlog.cpp<br />
autotests/testqscreenbackend.cpp<br />
autotests/testscreenconfig.cpp<br />
src/CMakeLists.txt<br />
src/backendlauncher/main.cpp<br />
src/backendmanager.cpp<br />
src/getconfigoperation.cpp<br />
src/log.cpp<br />
src/log.h</div></div></div><br /><div><strong>EMAIL PREFERENCES</strong><div><a href="https://phabricator.kde.org/settings/panel/emailpreferences/" rel="noreferrer">https://phabricator.kde.org/settings/panel/emailpreferences/</a></div></div><br /><div><strong>To: </strong>sebas, Plasma<br /><strong>Cc: </strong>plasma-devel, jensreuterberg, abetts, sebas<br /></div>