summaryrefslogtreecommitdiffstats
path: root/src/plugins/canbus/tinycan/tinycanbackend.cpp
diff options
context:
space:
mode:
authorAndre Hartmann <aha_1980@gmx.de>2017-11-05 19:15:19 +0100
committerAndré Hartmann <aha_1980@gmx.de>2017-11-13 19:29:48 +0000
commit328db7b395a1df970ccc641b2077c5c6ecbcf7de (patch)
treedd3911db9dc995797e2d8cfbba08f56c645308fd /src/plugins/canbus/tinycan/tinycanbackend.cpp
parent9de99ca2d395037a092a9003cad3dbb7bb5fde98 (diff)
CAN: Introduce categorized logging
[ChangeLog][CAN bus] Introduced categorized logging to the CAN bus module which can be enabled by the "qt.canbus" and "qt.canbus.plugins.<pluginname>" filters. Change-Id: Ib39c0b2ebcd967cd7812602190807ad3488ccb18 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src/plugins/canbus/tinycan/tinycanbackend.cpp')
-rw-r--r--src/plugins/canbus/tinycan/tinycanbackend.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/plugins/canbus/tinycan/tinycanbackend.cpp b/src/plugins/canbus/tinycan/tinycanbackend.cpp
index 2d9ea2d..0985e48 100644
--- a/src/plugins/canbus/tinycan/tinycanbackend.cpp
+++ b/src/plugins/canbus/tinycan/tinycanbackend.cpp
@@ -45,11 +45,14 @@
#include <QtCore/qtimer.h>
#include <QtCore/qmutex.h>
#include <QtCore/qcoreevent.h>
+#include <QtCore/qloggingcategory.h>
#include <algorithm>
QT_BEGIN_NAMESPACE
+Q_DECLARE_LOGGING_CATEGORY(QT_CANBUS_PLUGINS_TINYCAN)
+
#ifndef LINK_LIBMHSTCAN
Q_GLOBAL_STATIC(QLibrary, mhstcanLibrary)
#endif
@@ -344,7 +347,7 @@ void TinyCanBackendPrivate::startWrite()
::memset(&message, 0, sizeof(message));
if (Q_UNLIKELY(payload.size() > int(sizeof(message.Data.Bytes)))) {
- qWarning("Can not write frame with payload size %d, ignored", payload.size());
+ qCWarning(QT_CANBUS_PLUGINS_TINYCAN, "Cannot write frame with payload size %d.", payload.size());
} else {
message.Id = frame.frameId();
message.Flags.Flag.Len = payload.size();
@@ -392,7 +395,7 @@ void TinyCanBackendPrivate::startRead()
q->setError(systemErrorString(ret), QCanBusDevice::CanBusError::ReadError);
} else {
if (status.CanStatus == CAN_STATUS_BUS_OFF) {
- qWarning("CAN bus is in off state, trying to reset the bus");
+ qCWarning(QT_CANBUS_PLUGINS_TINYCAN, "CAN bus is in off state, trying to reset the bus.");
if (::CanSetMode(channelIndex, OP_CAN_RESET, CAN_CMD_NONE) < 0)
q->setError(systemErrorString(ret), QCanBusDevice::CanBusError::ReadError);
}
@@ -508,8 +511,8 @@ bool TinyCanBackend::open()
const QVariant param = configurationParameter(key);
const bool success = d->setConfigurationParameter(key, param);
if (Q_UNLIKELY(!success)) {
- qWarning("Cannot apply parameter: %d with value: %ls",
- key, qUtf16Printable(param.toString()));
+ qCWarning(QT_CANBUS_PLUGINS_TINYCAN, "Cannot apply parameter: %d with value: %ls.",
+ key, qUtf16Printable(param.toString()));
}
}
}