Commit 92d96603 authored by Michal Policht's avatar Michal Policht

Update debug and logging macros.

parent 4098ddde
......@@ -3,33 +3,33 @@
#include <QLoggingCategory>
#define CUTEHMI_LOG_FLF " [file: " << __FILE__ << " line: " << __LINE__ << " function: " << __FUNCTION__ << "]"
#define CUTEHMI_FLF " [file: " << __FILE__ << " line: " << __LINE__ << " function: " << __FUNCTION__ << "]"
#ifndef CUTEHMI_NO_LOG_DEBUG
#define CUTEHMI_LOG_DEBUG(EXPR) qCDebug(loggingCategory()).nospace().noquote() << "[debug] " << EXPR << CUTEHMI_LOG_FLF
#ifndef CUTEHMI_NDEBUG
#define CUTEHMI_DEBUG(EXPR) qCDebug(loggingCategory()).nospace().noquote() << "[debug] " << EXPR << CUTEHMI_FLF
#else
#define CUTEHMI_LOG_DEBUG(EXPR) (void)0
#define CUTEHMI_DEBUG(EXPR) (void)0
#endif
#ifndef CUTEHMI_NO_LOG_INFO
#define CUTEHMI_LOG_INFO(EXPR) qCInfo(loggingCategory()).nospace().noquote() << "[note] " << EXPR << CUTEHMI_LOG_FLF
#ifndef CUTEHMI_NINFO
#define CUTEHMI_INFO(EXPR) qCInfo(loggingCategory()).nospace().noquote() << "[note] " << EXPR << CUTEHMI_FLF
#else
#define CUTEHMI_LOG_INFO(EXPR) (void)0
#define CUTEHMI_INFO(EXPR) (void)0
#endif
#ifndef CUTEHMI_NO_LOG_WARNING
#define CUTEHMI_LOG_WARNING(EXPR) qCWarning(loggingCategory()).nospace().noquote() << "[warning] " << EXPR << CUTEHMI_LOG_FLF
#ifndef CUTEHMI_NWARNING
#define CUTEHMI_WARNING(EXPR) qCWarning(loggingCategory()).nospace().noquote() << "[warning] " << EXPR << CUTEHMI_FLF
#else
#define CUTEHMI_LOG_WARNING(EXPR) (void)0
#define CUTEHMI_WARNING(EXPR) (void)0
#endif
#ifndef CUTEHMI_NO_LOG_CRITICAL
#define CUTEHMI_LOG_CRITICAL(EXPR) qCCritical(loggingCategory()).nospace().noquote() << "[critical] " << EXPR << CUTEHMI_LOG_FLF
#ifndef CUTEHMI_NCRITICAL
#define CUTEHMI_CRITICAL(EXPR) qCCritical(loggingCategory()).nospace().noquote() << "[critical] " << EXPR << CUTEHMI_FLF
#else
#define CUTEHMI_LOG_CRITICAL(EXPR) (void)0
#define CUTEHMI_CRITICAL(EXPR) (void)0
#endif
#ifdef CUTEHMI_DEBUG
#ifndef CUTEHMI_NDEBUG
#define CUTEHMI_ASSERT(EXPR, MSG) Q_ASSERT_X(EXPR, __FILE__, MSG)
#else
#define CUTEHMI_ASSERT(EXPR, MSG) (void)0
......
......@@ -32,20 +32,20 @@ void NotificationManager::add(Notification * notification_l)
{
QMutexLocker locker(& m->modelMutex);
#ifdef CUTEHMI_DEBUG
#ifndef CUTEHMI_NDEBUG
switch (notification_l->type()) {
case Notification::NOTE:
CUTEHMI_LOG_INFO("[NOTIFICATION] " << notification_l->text());
CUTEHMI_INFO("[NOTIFICATION] " << notification_l->text());
break;
case Notification::WARNING:
CUTEHMI_LOG_WARNING("[NOTIFICATION] " << notification_l->text());
CUTEHMI_WARNING("[NOTIFICATION] " << notification_l->text());
break;
case Notification::CRITICAL:
CUTEHMI_LOG_CRITICAL("[NOTIFICATION] " << notification_l->text());
CUTEHMI_CRITICAL("[NOTIFICATION] " << notification_l->text());
break;
default:
CUTEHMI_LOG_CRITICAL("Unrecognized code ('" << notification_l->type() << "') of 'Notification::type()'. Assuming 'Notification::CRITICAL'.");
CUTEHMI_LOG_CRITICAL("[NOTIFICATION] " << notification_l->text());
CUTEHMI_CRITICAL("Unrecognized code ('" << notification_l->type() << "') of 'Notification::type()'. Assuming 'Notification::CRITICAL'.");
CUTEHMI_CRITICAL("[NOTIFICATION] " << notification_l->text());
}
#endif
......
......@@ -97,10 +97,10 @@ Prompt::Button Prompt::response() const
void Prompt::acceptResponse(Button response)
{
if (m->response != NO_BUTTON)
CUTEHMI_LOG_WARNING("Ignoring new arrival '" << response << "', as response '" << m->response << "' has been already accepted.");
CUTEHMI_WARNING("Ignoring new arrival '" << response << "', as response '" << m->response << "' has been already accepted.");
else {
if (!(response & buttons()))
CUTEHMI_LOG_WARNING("Forcibly accepting response '" << response << "', which should not be available.");
CUTEHMI_WARNING("Forcibly accepting response '" << response << "', which should not be available.");
emit responseArrived(response);
m->response = response;
emit responseChanged();
......
......@@ -29,7 +29,7 @@
#define CUTEHMI_LOG_CRITICAL(EXPR) (void)0
#endif
#ifdef CUTEHMI_DEBUG
#ifndef CUTEHMI_NDEBUG
#define CUTEHMI_ASSERT(EXPR, MSG) Q_ASSERT_X(EXPR, __FILE__, MSG)
#else
#define CUTEHMI_ASSERT(EXPR, MSG) (void)0
......
......@@ -5,7 +5,7 @@ namespace cutehmi {
QString Plugin::NameToBinary(const QString & name)
{
QString binary(name);
#ifdef CUTEHMI_DEBUG
#ifndef CUTEHMI_NDEBUG
binary.append('d');
#endif
return binary;
......@@ -14,7 +14,7 @@ QString Plugin::NameToBinary(const QString & name)
QString Plugin::NameFromBinary(const QString & binary)
{
QString name(binary);
#ifdef CUTEHMI_DEBUG
#ifndef CUTEHMI_NDEBUG
name.chop(1);
#endif
return name;
......
......@@ -68,7 +68,7 @@ class CUTEHMI_AUTHSSH_API Session:
//</workaround>
private:
#ifdef CUTEHMI_DEBUG
#ifndef CUTEHMI_NDEBUG
static const int INITIAL_LIBSSH_VERBOSITY = SSH_LOG_FUNCTIONS;
#else
static const int INITIAL_LIBSSH_VERBOSITY = SSH_LOG_NOLOG;
......
......@@ -27,14 +27,9 @@ Product {
property int micro ///< Micro version number (deprecated).
Properties {
condition: qbs.buildVariant.contains("debug")
cpp.defines: outer.concat(["CUTEHMI_DEBUG"])
}
Properties {
condition: !qbs.buildVariant.contains("debug")
cpp.defines: outer.concat(["CUTEHMI_RELEASE", "QT_NO_DEBUG_OUTPUT"])
cpp.defines: outer.concat(["CUTEHMI_NDEBUG", "QT_NO_DEBUG_OUTPUT"])
}
Depends { name: "cpp" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment