[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-frameworks-devel
Subject: Re: Categorized logging in KDE?
From: Mark <markg85 () gmail ! com>
Date: 2013-10-12 12:55:32
Message-ID: CAPd6JnG_dxbATk_4d-3FXdn0MPWXJax4S_bAJHXO=mLPpJwJPQ () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
On Sat, Oct 12, 2013 at 10:42 AM, David Faure <faure@kde.org> wrote:
> On Wednesday 09 October 2013 15:29:56 Mark wrote:
> > Hi,
> >
> > As you all probably know by now, Qt has included of categorized logging
> [1]
> > as of 5.2.
> > In KDE we've had categorized logging for ages, but while porting to
> > Frameworks we started using the "simple" Qt logging q<Debug, Notice and
> > Warning>.
> >
> > However, we now again have categorized logging from within Qt. That makes
> > me wonder, do we still need to port back to q<Debug, Notice and Warning>
> or
> > are we now going to use the categorized versions: qC<Debug, Notice and
> > Warning>?
>
> The latter, especially in libraries. Feel free to start porting kdelibs to
> that.
>
> Ok, cool.
But i still miss one tiny detail.. How can we toggle logging at runtime by
using for example kdebugdialog?
The example looks like this:
// in a header
Q_DECLARE_LOGGING_CATEGORY(QT_DRIVER_USB)
// in one source file
Q_LOGGING_CATEGORY(QT_DRIVER_USB, "qt.driver.usb")
// usbEntries() will only be called if QT_DRIVER_USB category is enabled
qCDebug(QT_DRIVER_USB) << "devices: " << usbEntries();
It's not even clear to me how to add a new category and enable it with the
above macro examples.
I can get it working if i do this:
QLoggingCategory usbCategory("qt.driver.usb");
usbCategory.setEnabled(QtDebugMsg, true);
qCDebug(usbCategory) << "USB driver logging...";
So that works.. but getting "qCDebug(QT_DRIVER_USB)..." to work is
something i'm still having trouble with.
Still playing with this to get it working.
[Attachment #5 (text/html)]
<div dir="ltr">On Sat, Oct 12, 2013 at 10:42 AM, David Faure <span dir="ltr"><<a \
href="mailto:faure@kde.org" target="_blank">faure@kde.org</a>></span> \
wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On Wednesday 09 October 2013 15:29:56 Mark wrote:<br>
> Hi,<br>
><br>
> As you all probably know by now, Qt has included of categorized logging [1]<br>
> as of 5.2.<br>
> In KDE we've had categorized logging for ages, but while porting to<br>
> Frameworks we started using the "simple" Qt logging q<Debug, Notice \
and<br> > Warning>.<br>
><br>
> However, we now again have categorized logging from within Qt. That makes<br>
> me wonder, do we still need to port back to q<Debug, Notice and Warning> \
or<br> > are we now going to use the categorized versions: qC<Debug, Notice \
and<br> > Warning>?<br>
<br>
</div>The latter, especially in libraries. Feel free to start porting kdelibs to<br>
that.<br><br></blockquote><div>Ok, cool. </div></div><br></div><div \
class="gmail_extra">But i still miss one tiny detail.. How can we toggle logging at \
runtime by using for example kdebugdialog?</div><div class="gmail_extra">
The example looks like this:</div><div class="gmail_extra"><br></div><div \
class="gmail_extra"><div class="gmail_extra">// in a header</div><div \
class="gmail_extra">Q_DECLARE_LOGGING_CATEGORY(QT_DRIVER_USB)</div><div \
class="gmail_extra">
<br></div><div class="gmail_extra">// in one source file</div><div \
class="gmail_extra">Q_LOGGING_CATEGORY(QT_DRIVER_USB, \
"qt.driver.usb")</div><div class="gmail_extra"><br></div><div \
class="gmail_extra"><div class="gmail_extra">
// usbEntries() will only be called if QT_DRIVER_USB category is enabled</div><div \
class="gmail_extra">qCDebug(QT_DRIVER_USB) << "devices: " << \
usbEntries();</div><div class="gmail_extra"><br></div> <div class="gmail_extra">
It's not even clear to me how to add a new category and enable it with the above \
macro examples.</div><div class="gmail_extra">I can get it working if i do \
this:</div><div class="gmail_extra"><br></div><div class="gmail_extra">
<div class="gmail_extra">QLoggingCategory \
usbCategory("qt.driver.usb");</div><div \
class="gmail_extra">usbCategory.setEnabled(QtDebugMsg, true);</div><div \
class="gmail_extra">qCDebug(usbCategory) << "USB driver \
logging...";<br>
</div><div class="gmail_extra"><br></div><div class="gmail_extra">So that works.. but \
getting "qCDebug(QT_DRIVER_USB)..." to work is something i'm still \
having trouble with.</div><div class="gmail_extra">Still playing with this to get it \
working.</div>
</div></div></div></div>
_______________________________________________
Kde-frameworks-devel mailing list
Kde-frameworks-devel@kde.org
https://mail.kde.org/mailman/listinfo/kde-frameworks-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic