commit 9328580402c24212d2daf8db4caad08159e94f27
Author: Christian Ehringfeld <c.ehringfeld@t-online.de>
Date:   Sat Sep 26 16:12:29 2015 +0200

    logger

diff --git a/EntityManager.pro b/EntityManager.pro
index 176ca18..fed2331 100644
--- a/EntityManager.pro
+++ b/EntityManager.pro
@@ -51,7 +51,8 @@ src/entity.h \
     src/validators/uniquevalidator.h \
     src/validators/patternvalidator.h \
     src/validators/lengthvalidator.h \
-    src/schema/mysqlquerybuilder.h
+    src/schema/mysqlquerybuilder.h \
+    src/entityinspector.h
 
 SOURCES += \
 src/entity.cpp \
@@ -94,7 +95,8 @@ src/entity.cpp \
     src/validators/uniquevalidator.cpp \
     src/validators/patternvalidator.cpp \
     src/validators/lengthvalidator.cpp \
-    src/schema/mysqlquerybuilder.cpp
+    src/schema/mysqlquerybuilder.cpp \
+    src/entityinspector.cpp
 
 CONFIG += c++14
 QMAKE_CXXFLAGS += -std=c++14
diff --git a/src/entityinspector.cpp b/src/entityinspector.cpp
new file mode 100644
index 0000000..a325e2a
--- /dev/null
+++ b/src/entityinspector.cpp
@@ -0,0 +1,7 @@
+#include "entityinspector.h"
+
+EntityInspector::EntityInspector()
+{
+
+}
+
diff --git a/src/entityinspector.h b/src/entityinspector.h
new file mode 100644
index 0000000..0c111fa
--- /dev/null
+++ b/src/entityinspector.h
@@ -0,0 +1,15 @@
+#ifndef ENTITYINSPECTOR_H
+#define ENTITYINSPECTOR_H
+
+
+class EntityInspector
+{
+public:
+    EntityInspector();
+
+//signals:
+
+//public slots:
+};
+
+#endif // ENTITYINSPECTOR_H
diff --git a/src/logger.cpp b/src/logger.cpp
index d9f26a7..a07043a 100644
--- a/src/logger.cpp
+++ b/src/logger.cpp
@@ -39,19 +39,15 @@ void Logger::lastError(const QSqlQuery &q, bool logQuery) {
         log.seek(log.size());
         QTextStream stream(&log);
         const QString errorMsg = this->generateLogMsg(q.lastError());
-        if (!errorMsg.isEmpty()) {
-            qWarning() << errorMsg;
-            stream << errorMsg;
-        }
         if (logQuery || !errorMsg.isEmpty()) {
-            const QString query = this->generateLogMsg(q);
-            if (!query.isEmpty()) {
-                if (errorMsg.isEmpty()) {
-                    qDebug() << query;
-                } else {
-                    qWarning() << query;
-                }
-                stream << query;
+            QString msg = "{" + QString("\"time\":\"") +
+                          QDateTime::currentDateTime().toString(Qt::ISODate) + QString("\"") + errorMsg;
+            msg += this->generateLogMsg(q) + "}";
+            stream << msg;
+            if (errorMsg.isEmpty()) {
+                qDebug() << msg.replace("\"", "'");
+            } else {
+                qWarning() << msg.replace("\"", "'");
             }
         }
         stream << "\n";
@@ -75,16 +71,22 @@ void Logger::lastError(const QSqlError &e) {
 }
 
 QString Logger::generateLogMsg(const QSqlQuery &q, bool withValues) const {
-    QString r = "<" + q.executedQuery() + ">";
+    QString r = ", \"query\":\"" + q.executedQuery() + "\"";
     if (withValues) {
         QMap<QString, QVariant> m = q.boundValues();
-        QMap<QString, QVariant>::iterator i;
         if (!m.isEmpty()) {
-            r += "Values: ";
-            for (i = m.begin(); i != m.end(); ++i) {
-                r += "{" + i.key() + "=" + i.value().toString() + "}";
+            r += ", \"values\": {";
+            bool first = true;
+            for (auto i = m.begin(); i != m.end(); ++i) {
+                if (first) {
+                    first = false;
+                }  else {
+                    r += ", ";
+                }
+                r += "\"" + i.key().mid(1) + "\":\"" + i.value().toString() + "\"";
             }
         }
+        r += "}";
     }
     return r;
 }
@@ -103,9 +105,7 @@ void Logger::setPath(const QString &value) {
 QString Logger::generateLogMsg(const QSqlError &e) const {
     QString r = "";
     if (e.isValid()) {
-        r = "ErrorUTC:" +
-            QDateTime::currentDateTime().toString("yyyy-MM-dd|hh:MM:ss") + "|" +
-            e.driverText() + "|" + e.databaseText().toLatin1();
+        r = ",\"error\":\"" + e.text() + "\",\"code\":\"" + e.number() + "\"";
     }
     return r;
 }
