Merge lp:~mrqtros/ubuntu-docviewer-app/ubuntu-docviewer-app-adv-logging into lp:ubuntu-docviewer-app

Proposed by Roman Shchekin
Status: Needs review
Proposed branch: lp:~mrqtros/ubuntu-docviewer-app/ubuntu-docviewer-app-adv-logging
Merge into: lp:ubuntu-docviewer-app
Diff against target: 243 lines (+34/-19)
6 files modified
src/app/renderengine.cpp (+3/-1)
src/app/renderengine.h (+3/-0)
src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp (+11/-9)
src/plugin/libreofficetoolkit-qml-plugin/lodocument.h (+3/-0)
src/plugin/libreofficetoolkit-qml-plugin/loview.cpp (+11/-9)
src/plugin/libreofficetoolkit-qml-plugin/loview.h (+3/-0)
To merge this branch: bzr merge lp:~mrqtros/ubuntu-docviewer-app/ubuntu-docviewer-app-adv-logging
Reviewer Review Type Date Requested Status
Stefano Verzegnassi Needs Information
Jenkins Bot continuous-integration Approve
Review via email: mp+282846@code.launchpad.net

Commit message

New style of logging.

Description of the change

New style of logging.

To post a comment you must log in.
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Stefano Verzegnassi (verzegnassi-stefano) wrote :

Hey Roman!
In order to go on with the review, I need to ask you some question.

1) I see you've kept the #ifdef's. Shouldn't they be removed?

   Having a look at the KDE wiki at:
       https://techbase.kde.org/Development/Tutorials/Debugging/Using_Error_Messages#Improving_Logging_Output

   It looks like we'd need two steps in order to enable debugging output:
       1) Uncomment a #define entry in config.h
       2) Enable logging for a specific category (by default they're all disabled)

    I'd suggest to remove all the #define's and #ifdef's, and eventually add e.g.:
        QLoggingCategory::setFilterRules(QStringLiteral("RenderEngine.debug = true"));

    somewhere inside the plugin.

2) How do we like to filter the debug log? By class as you propose (e.g. "RenderEngine", "LODocument", etc.) or by scope (e.g. "TileBenchmark", "TileManagement", "Zoom", etc.)

3) Some of the debug in LODocument
       e.g. qCDebug(LoDoc) << "Loading document...";

   is information output rather than debug (I badly used qDebug() instead of qInfo()).

   Do we still want to make it optional? Could we use qInfo() or qCInfo()?

   I'm thinking at a scenario where something unexpected happens, and a user opens a bug report on Launchpad and upload the application log.
   Those basic informations wouldn't be available, and we would have to ask her to enable logging[1] for being able to say which area could generate the issue, and then (eventually) asking to enable some further category again.

   I consider this output useful for orienting my focus at first. I might as well be wrong!

[1] How can that be easily done on Ubuntu Touch, since everything is so confined?

review: Needs Information
Revision history for this message
Roman Shchekin (mrqtros) wrote :

Let's discuss it then :)

1) I should explore possibilities... To be honest, I was satisfied with text in output during debug, I thought that it was enough for us...
2) Seems that we should filter our output with groups. RenderEngine itself is a good category, LoDocument and LoView can be rethinked... The using of class name can be very handy since we have not so much classes and all of them are "core".
3) There is a thin difference between info and debug, I think, so every case is discussable, but not critical

Revision history for this message
Stefano Verzegnassi (verzegnassi-stefano) wrote :

1) Yes! If we could remove those #ifdef's from the code, it would look more linear/less bulky(TM) and it would be a great "double win".
However, I'd like to have something similar to the current config.h, so that we can toggle a more verbose output by uncommenting a single line. Which could be a suitable place for that?

2) Agree! "RenderEngine" is a good category. Others could be:
   - "TileBenchmark" in LODocument paint functions
   - "TileManagement" in LOView, for providing output about creation/removal/changes about the tile map and the visible/buffer areas
   - "ZoomEvents" for the automatic zoom management and events triggered by a change in the zoom value[1]
   - "VerboseOutput" for general information (e.g. error warnings) and something else we could add in future

3) "Loading document ..." and "Document loaded successfully !" may stay always visible.
   LODocument::loadDocument() is the place where the magical things happen (all the LibreOffice stuff are loaded there, and many 'events' in the plugin depend on a successful/failure of its execution).
   Having those two lines at the beginning/end of the function is more confortable for me. :)

[1] See for example "Zoom value of tiles is different than the current zoom value. Erasing cache..."
    This string could also be filtered by a "TileManagement" category, but it's not possible to assign a string to multiple categories, for what I see.

Unmerged revisions

261. By Roman Shchekin

New style of logging.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/app/renderengine.cpp'
--- src/app/renderengine.cpp 2015-12-12 10:06:55 +0000
+++ src/app/renderengine.cpp 2016-01-16 13:18:10 +0000
@@ -2,6 +2,8 @@
2#include <QtConcurrent/QtConcurrent>2#include <QtConcurrent/QtConcurrent>
3#include <QThread>3#include <QThread>
44
5Q_LOGGING_CATEGORY(RndEng, "RenderEngine")
6
5RenderEngine* RenderEngine::s_instance = nullptr;7RenderEngine* RenderEngine::s_instance = nullptr;
68
7RenderEngine::RenderEngine():9RenderEngine::RenderEngine():
@@ -65,7 +67,7 @@
65void RenderEngine::doNextTask()67void RenderEngine::doNextTask()
66{68{
67#ifdef DEBUG_VERBOSE69#ifdef DEBUG_VERBOSE
68 qDebug() << " ---- doNextTask" << m_activeTaskCount << m_queue.count();70 qCDebug(RndEng) << " ---- doNextTask" << m_activeTaskCount << m_queue.count();
69#endif71#endif
7072
71 // Check for too much threads or empty queue.73 // Check for too much threads or empty queue.
7274
=== modified file 'src/app/renderengine.h'
--- src/app/renderengine.h 2015-12-12 10:06:55 +0000
+++ src/app/renderengine.h 2016-01-16 13:18:10 +0000
@@ -8,10 +8,13 @@
8#include <QQueue>8#include <QQueue>
9#include <QAtomicInt>9#include <QAtomicInt>
10#include <QList>10#include <QList>
11#include <QLoggingCategory>
1112
12//#include "lodocument.h"13//#include "lodocument.h"
13#include "rendertask.h"14#include "rendertask.h"
1415
16Q_DECLARE_LOGGING_CATEGORY(RndEng)
17
15class RenderEngine : public QObject18class RenderEngine : public QObject
16{19{
17 Q_OBJECT20 Q_OBJECT
1821
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp'
--- src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2015-12-14 00:40:55 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.cpp 2016-01-16 13:18:10 +0000
@@ -30,6 +30,8 @@
30#include <QElapsedTimer>30#include <QElapsedTimer>
31#endif31#endif
3232
33Q_LOGGING_CATEGORY(LoDoc, "LODocument")
34
33lok::Office *LODocument::s_office = nullptr;35lok::Office *LODocument::s_office = nullptr;
3436
35LODocument::LODocument()37LODocument::LODocument()
@@ -62,11 +64,11 @@
62// Load the document64// Load the document
63void LODocument::loadDocument(const QString &pathName)65void LODocument::loadDocument(const QString &pathName)
64{66{
65 qDebug() << "Loading document...";67 qCDebug(LoDoc) << "Loading document...";
66 setError(LibreOfficeError::NoError);68 setError(LibreOfficeError::NoError);
6769
68 if (pathName.isEmpty()) {70 if (pathName.isEmpty()) {
69 qDebug() << "Can't load the document, path is empty.";71 qCWarning(LoDoc) << "Can't load the document, path is empty.";
70 return;72 return;
71 }73 }
7274
@@ -86,7 +88,7 @@
8688
87 if (!s_office) {89 if (!s_office) {
88 setError(LibreOfficeError::LibreOfficeNotInitialized);90 setError(LibreOfficeError::LibreOfficeNotInitialized);
89 qDebug() << "[lok-qml]: LibreOffice not initialized.";91 qCWarning(LoDoc) << "[lok-qml]: LibreOffice not initialized.";
90 return;92 return;
91 }93 }
9294
@@ -96,7 +98,7 @@
9698
97 if (!m_lokDocument) {99 if (!m_lokDocument) {
98 setError(LibreOfficeError::DocumentNotLoaded);100 setError(LibreOfficeError::DocumentNotLoaded);
99 qDebug() << "[lok-qml]: Document not loaded.";101 qCWarning(LoDoc) << "[lok-qml]: Document not loaded.";
100 return;102 return;
101 }103 }
102104
@@ -106,7 +108,7 @@
106 Q_EMIT documentTypeChanged();108 Q_EMIT documentTypeChanged();
107109
108 m_lokDocument->initializeForRendering();110 m_lokDocument->initializeForRendering();
109 qDebug() << "Document loaded successfully !";111 qCDebug(LoDoc) << "Document loaded successfully !";
110112
111 return;113 return;
112}114}
@@ -173,7 +175,7 @@
173 Twips::convertPixelsToTwips(tileSize.height(), zoom));175 Twips::convertPixelsToTwips(tileSize.height(), zoom));
174176
175#ifdef DEBUG_TILE_BENCHMARK177#ifdef DEBUG_TILE_BENCHMARK
176 qDebug() << "Time to render the tile:" << renderTimer.elapsed() << "ms";178 qCDebug(LoDoc) << "Time to render the tile:" << renderTimer.elapsed() << "ms";
177#endif179#endif
178180
179 return result.rgbSwapped();181 return result.rgbSwapped();
@@ -209,7 +211,7 @@
209 0, 0, tWidth, tHeight);211 0, 0, tWidth, tHeight);
210212
211#ifdef DEBUG_TILE_BENCHMARK213#ifdef DEBUG_TILE_BENCHMARK
212 qDebug() << "Time to render the thumbnail:" << renderTimer.elapsed() << "ms";214 qCDebug(LoDoc) << "Time to render the thumbnail:" << renderTimer.elapsed() << "ms";
213#endif215#endif
214216
215 return result.rgbSwapped();217 return result.rgbSwapped();
@@ -241,7 +243,7 @@
241bool LODocument::saveAs(QString url, QString format = QString(), QString filterOptions = QString())243bool LODocument::saveAs(QString url, QString format = QString(), QString filterOptions = QString())
242{244{
243 if (!m_lokDocument) {245 if (!m_lokDocument) {
244 qDebug() << "No loaded document. It's not possible to save this file.";246 qCWarning(LoDoc) << "No loaded document. It's not possible to save this file.";
245 return false;247 return false;
246 }248 }
247249
@@ -254,6 +256,6 @@
254{256{
255 delete m_lokDocument;257 delete m_lokDocument;
256#ifdef DEBUG_VERBOSE258#ifdef DEBUG_VERBOSE
257 qDebug() << " ---- ~LODocument";259 qCDebug(LoDoc) << " ---- ~LODocument";
258#endif260#endif
259}261}
260262
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/lodocument.h'
--- src/plugin/libreofficetoolkit-qml-plugin/lodocument.h 2015-12-14 00:40:55 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/lodocument.h 2016-01-16 13:18:10 +0000
@@ -19,6 +19,9 @@
19#define LODOCUMENT_H19#define LODOCUMENT_H
2020
21#include <QObject>21#include <QObject>
22#include <QLoggingCategory>
23
24Q_DECLARE_LOGGING_CATEGORY(LoDoc)
2225
23#include "loerror.h"26#include "loerror.h"
2427
2528
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.cpp'
--- src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2015-12-14 00:40:55 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/loview.cpp 2016-01-16 13:18:10 +0000
@@ -24,6 +24,8 @@
24#include <QTimer>24#include <QTimer>
25#include <QtCore/qmath.h>25#include <QtCore/qmath.h>
2626
27Q_LOGGING_CATEGORY(LoVi, "LOView")
28
27static qreal zoomValueToFitWidth;29static qreal zoomValueToFitWidth;
2830
29static qreal getZoomToFitWidth(const qreal &width, int documentWidth)31static qreal getZoomToFitWidth(const qreal &width, int documentWidth)
@@ -210,7 +212,7 @@
210 m_document->documentSize().width());212 m_document->documentSize().width());
211213
212 setZoomFactor(zoomValueToFitWidth);214 setZoomFactor(zoomValueToFitWidth);
213 qDebug() << "Adjust zoom to width - value:" << zoomValueToFitWidth;215 qCDebug(LoVi) << "Adjust zoom to width - value:" << zoomValueToFitWidth;
214}216}
215217
216void LOView::updateViewSize()218void LOView::updateViewSize()
@@ -247,7 +249,7 @@
247 if (m_zoomFactor != zoomValueToFitWidth) {249 if (m_zoomFactor != zoomValueToFitWidth) {
248 setZoomFactor(zoomValueToFitWidth);250 setZoomFactor(zoomValueToFitWidth);
249251
250 qDebug() << "Adjust automatic zoom to width - value:" << zoomValueToFitWidth;252 qCDebug(LoVi) << "Adjust automatic zoom to width - value:" << zoomValueToFitWidth;
251 return;253 return;
252 }254 }
253 }255 }
@@ -260,7 +262,7 @@
260 clearView();262 clearView();
261263
262#ifdef DEBUG_VERBOSE264#ifdef DEBUG_VERBOSE
263 qDebug() << "Zoom value of tiles is different than the current zoom value. Erasing cache...";265 qCDebug(LoVi) << "Zoom value of tiles is different than the current zoom value. Erasing cache...";
264#endif266#endif
265 }267 }
266 }268 }
@@ -298,7 +300,7 @@
298300
299 // Out of buffer - we should delete this item.301 // Out of buffer - we should delete this item.
300#ifdef DEBUG_VERBOSE302#ifdef DEBUG_VERBOSE
301 qDebug() << "Removing tile indexed as" << i.key();303 qCDebug(LoVi) << "Removing tile indexed as" << i.key();
302#endif304#endif
303305
304 RenderEngine::instance()->dequeueTask(sgtile->id());306 RenderEngine::instance()->dequeueTask(sgtile->id());
@@ -324,8 +326,8 @@
324 int bufferToHeight = qCeil(qreal(m_bufferArea.bottom()) / TILE_SIZE);326 int bufferToHeight = qCeil(qreal(m_bufferArea.bottom()) / TILE_SIZE);
325327
326#ifdef DEBUG_VERBOSE328#ifdef DEBUG_VERBOSE
327 qDebug() << "Visible area - Left:" << visiblesFromWidth << "Right:" << visiblesToWidth << "Top:" << visiblesFromHeight << "Bottom:" << visiblesToHeight;329 qCDebug(LoVi) << "Visible area - Left:" << visiblesFromWidth << "Right:" << visiblesToWidth << "Top:" << visiblesFromHeight << "Bottom:" << visiblesToHeight;
328 qDebug() << "Buffer area - Left:" << bufferFromWidth << "Right:" << bufferToWidth << "Top:" << bufferFromHeight << "Bottom:" << bufferToHeight;330 qCDebug(LoVi) << "Buffer area - Left:" << bufferFromWidth << "Right:" << bufferToWidth << "Top:" << bufferFromHeight << "Bottom:" << bufferToHeight;
329#endif331#endif
330332
331 this->generateTiles(visiblesFromWidth, visiblesFromHeight, visiblesToWidth, visiblesToHeight, tilesPerWidth, tilesPerHeight);333 this->generateTiles(visiblesFromWidth, visiblesFromHeight, visiblesToWidth, visiblesToHeight, tilesPerWidth, tilesPerHeight);
@@ -350,7 +352,7 @@
350 createTile(index, tileRect);352 createTile(index, tileRect);
351353
352#ifdef DEBUG_VERBOSE354#ifdef DEBUG_VERBOSE
353 qDebug() << "Generating tile - Index:" << index << "X:" << x << "Y:" << y;355 qCDebug(LoVi) << "Generating tile - Index:" << index << "X:" << x << "Y:" << y;
354#endif356#endif
355 }357 }
356 }358 }
@@ -375,7 +377,7 @@
375{377{
376 if (!m_tiles.contains(index)) {378 if (!m_tiles.contains(index)) {
377#ifdef DEBUG_VERBOSE379#ifdef DEBUG_VERBOSE
378 qDebug() << "Creating tile indexed as" << index << "- Rect:" << rect;380 qCDebug(LoVi) << "Creating tile indexed as" << index << "- Rect:" << rect;
379#endif381#endif
380382
381 auto tile = new SGTileItem(rect, m_zoomFactor, RenderEngine::getNextId(), this);383 auto tile = new SGTileItem(rect, m_zoomFactor, RenderEngine::getNextId(), this);
@@ -384,7 +386,7 @@
384 }386 }
385#ifdef DEBUG_VERBOSE387#ifdef DEBUG_VERBOSE
386 else {388 else {
387 qDebug() << "tile" << index << "already exists";389 qCDebug(LoVi) << "tile" << index << "already exists";
388 }390 }
389#endif391#endif
390}392}
391393
=== modified file 'src/plugin/libreofficetoolkit-qml-plugin/loview.h'
--- src/plugin/libreofficetoolkit-qml-plugin/loview.h 2016-01-07 11:23:50 +0000
+++ src/plugin/libreofficetoolkit-qml-plugin/loview.h 2016-01-16 13:18:10 +0000
@@ -22,6 +22,9 @@
22#include <QSharedPointer>22#include <QSharedPointer>
23#include <QQmlContext>23#include <QQmlContext>
24#include <QQmlEngine>24#include <QQmlEngine>
25#include <QLoggingCategory>
26
27Q_DECLARE_LOGGING_CATEGORY(LoVi)
2528
26#include "loerror.h"29#include "loerror.h"
27#include "lorendertask.h"30#include "lorendertask.h"

Subscribers

People subscribed via source and target branches