Coding standard for qdebug in libs
Jaroslaw Staniek
staniek at kde.org
Sat Sep 5 11:55:28 BST 2015
Hi,
This is a proposal for some consistency for naming of debug functions,
debug headers and logging categories.
I'll be trying to achieve in code I maintain. I can put some
guidelines on the dev wiki.
Details:
After looking at recent commits such as Friedrich's 1dddbcdbceab0
"kWarning -> warnPigment" I was wondering if we want to have standards
for debug handling.
I don't use one in Kexi, not yet, but use one in
kdb/kreport/kproperty. With increasing modularity it's quite important
for our debugging needs to have logging categories.
A scheme could be like
{libnamelowercase}{Debug|Warning|Critical}()
e.g. I use kdbDebug() << ... ;
Note, for clarity () is used here too like in qDebug().
See kdb_debug.h https://quickgit.kde.org/?p=kdb.git&a=blob&f=src%2Fkdb_debug.h
Furthermore, in kde_debug.cpp
[https://quickgit.kde.org/?p=kdb.git&a=blob&f=src%2Fkdb_debug.cpp] I
have:
Q_LOGGING_CATEGORY(KDB_LOG, "org.kde.kdb.core")
Note that you can pick your scheme for string, e.g.
org.kde.calligra.{someapp} or org.calligra.{someapp}
and for libs org.kde.{somelib}. It's important to have it unique and
relatively short. Planning for future expansion is a good way too.
For tests and example apps it may be enough to use default debug or
for big code decide to add special category too.
I also propose to use a libname prefix for the header name. This is
what many bits in KF5 do. So we won't have to deal with dozens files
prefixed with "Debug" soon (so libpigment's DebugPigment.h could
become PigmentDebug.h or pigment_debug.h).
PS: I am aware e.g. KF5 has various approaches there, use qDebug()
with no categories, use qCDebug without defines.
We have not fully migrated to logging categories in apps and internal
libs so I thought it may be cool to think about consistency early
enough.
--
regards, Jaroslaw Staniek
KDE:
: A world-wide network of software engineers, artists, writers, translators
: and facilitators committed to Free Software development - http://kde.org
Calligra Suite:
: A graphic art and office suite - http://calligra.org
Kexi:
: A visual database apps builder - http://calligra.org/kexi
Qt Certified Specialist:
: http://www.linkedin.com/in/jstaniek
More information about the calligra-devel
mailing list