aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorGergely Risko <gergely+context@risko.hu>2009-09-08 15:39:18 +0300
committerGergely Risko <gergely+context@risko.hu>2009-09-08 15:39:18 +0300
commit62f9a85f798a1fcdc74b0d25d11220bebed557e5 (patch)
treed18dd8dfe80b2b96b39a180b24bcece0aafb8657 /common
parent3827d8ca07d16daafbf7c29020e58a96381a0e28 (diff)
Logging simplifications and support for everything supported by QDebug().
Diffstat (limited to 'common')
-rw-r--r--common/logging.cpp110
-rw-r--r--common/logging.h36
2 files changed, 8 insertions, 138 deletions
diff --git a/common/logging.cpp b/common/logging.cpp
index de0ac527..72c5b0fb 100644
--- a/common/logging.cpp
+++ b/common/logging.cpp
@@ -309,11 +309,11 @@ ContextRealLogger::ContextRealLogger(int type, const char *module, const char *f
// Add timestamp
if (! hideTimestamps && ! vanilla)
- *this << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
+ *this << QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss").toLocal8Bit().data();
// Module name
if (! vanilla)
- *this << QString("[" + QString(module) + "]");
+ *this << QString("[" + QString(module) + "]").toLocal8Bit().data();
// Message name
switch(type) {
@@ -338,7 +338,7 @@ ContextRealLogger::ContextRealLogger(int type, const char *module, const char *f
// File, line and function...
if (! vanilla)
- *this << QString("[" + QString(file) + ":" + QString::number(line) + ":" + QString(func) + "]");
+ *this << QString("[" + QString(file) + ":" + QString::number(line) + ":" + QString(func) + "]").toLocal8Bit().data();
}
bool ContextRealLogger::shouldPrint()
@@ -419,107 +419,3 @@ ContextRealLogger::~ContextRealLogger()
setDevice(NULL);
}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (QChar v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (signed short v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (unsigned short v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (signed int v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (unsigned int v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (signed long v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (unsigned long v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (float v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (double v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (void *v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (const QString &v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (const char *v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
-
-/// Standard QTextStream operators. Automatically adds whitespace.
-ContextRealLogger& ContextRealLogger::operator<< (char v)
-{
- QTextStream::operator<<(v);
- QTextStream::operator<<(' ');
- return *this;
-}
diff --git a/common/logging.h b/common/logging.h
index 65a5cc16..23be7b15 100644
--- a/common/logging.h
+++ b/common/logging.h
@@ -27,7 +27,6 @@
#include <QStringList>
#include <QTextStream>
#include <QBuffer>
-#include <QSet>
#include <QDebug>
#define CONTEXT_LOG_MSG_TYPE_TEST 1
@@ -72,23 +71,12 @@ public:
ContextRealLogger &operator<< (const ContextFeature&);
- virtual ContextRealLogger &operator<< (QChar);
- virtual ContextRealLogger &operator<< (signed short);
- virtual ContextRealLogger &operator<< (unsigned short);
- virtual ContextRealLogger &operator<< (signed int);
- virtual ContextRealLogger &operator<< (unsigned int);
- virtual ContextRealLogger &operator<< (signed long);
- virtual ContextRealLogger &operator<< (unsigned long);
- virtual ContextRealLogger &operator<< (float);
- virtual ContextRealLogger &operator<< (double);
- virtual ContextRealLogger &operator<< (void *);
- virtual ContextRealLogger &operator<< (const QString&);
- virtual ContextRealLogger &operator<< (const char *);
- virtual ContextRealLogger &operator<< (char);
- template <typename T> ContextRealLogger &operator<< (const QSet<T>& set)
+// ContextRealLogger &operator<< (const char *str);
+
+ template <typename T> ContextRealLogger &operator<< (const T& qSomething)
{
QString out;
- QDebug(&out) << set;
+ QDebug(&out) << qSomething;
QTextStream::operator<<(out);
return *this;
}
@@ -122,21 +110,7 @@ public:
inline ContextZeroLogger() {}
/* Stubby ops */
- inline ContextZeroLogger &operator<< (QChar) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (char) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (signed short) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (unsigned short) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (signed int) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (unsigned int) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (signed long) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (unsigned long) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (float) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (double) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (const char *) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (const QString&) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (void *) { return *this;} ///< Does nothing.
- inline ContextZeroLogger &operator<< (const ContextFeature&) { return *this;} ///< Does nothing.
- template <typename T> inline ContextZeroLogger &operator<< (const QSet<T>&) { return *this;} ///< Does nothing.
+ template <typename T> inline ContextZeroLogger &operator<< (const T&) { return *this;} ///< Does nothing.
};
/* Macro defs */