[Pkg-owncloud-commits] [owncloud-client] 235/333: Add a class to write a machine readable sync log file.
Sandro Knauß
hefee-guest at moszumanska.debian.org
Thu Apr 17 23:16:58 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit c41935d49dad5e38785225b1a1f9ea87669b84c9
Author: Klaas Freitag <freitag at owncloud.com>
Date: Wed Mar 26 18:01:26 2014 +0100
Add a class to write a machine readable sync log file.
---
src/CMakeLists.txt | 1 +
src/mirall/syncrunfilelog.cpp | 139 ++++++++++++++++++++++++++++++++++++++++++
src/mirall/syncrunfilelog.h | 48 +++++++++++++++
3 files changed, 188 insertions(+)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e2ea0b1..acbf9b3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -102,6 +102,7 @@ set(libsync_SRCS
mirall/account.cpp
mirall/quotainfo.cpp
mirall/clientproxy.cpp
+ mirall/syncrunfilelog.cpp
creds/dummycredentials.cpp
creds/abstractcredentials.cpp
creds/credentialsfactory.cpp
diff --git a/src/mirall/syncrunfilelog.cpp b/src/mirall/syncrunfilelog.cpp
new file mode 100644
index 0000000..9d63eca
--- /dev/null
+++ b/src/mirall/syncrunfilelog.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) by Klaas Freitag <freitag at owncloud.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include "mirall/syncrunfilelog.h"
+#include "mirall/utility.h"
+#include "mirall/mirallconfigfile.h"
+
+namespace Mirall {
+
+SyncRunFileLog::SyncRunFileLog()
+{
+}
+
+QString SyncRunFileLog::dateTimeStr( const QDateTime& dt )
+{
+ return dt.toString(Qt::ISODate);
+}
+
+QString SyncRunFileLog::instructionToStr( csync_instructions_e inst )
+{
+ QString re;
+
+ switch( inst ) {
+ case CSYNC_INSTRUCTION_NONE:
+ re = "INST_NONE";
+ break;
+ case CSYNC_INSTRUCTION_EVAL:
+ re = "INST_EVAL";
+ break;
+ case CSYNC_INSTRUCTION_REMOVE:
+ re = "INST_REMOVE";
+ break;
+ case CSYNC_INSTRUCTION_RENAME:
+ re = "INST_RENAME";
+ break;
+ case CSYNC_INSTRUCTION_EVAL_RENAME:
+ re = "INST_EVAL_RENAME";
+ break;
+ case CSYNC_INSTRUCTION_NEW:
+ re = "INST_NEW";
+ break;
+ case CSYNC_INSTRUCTION_CONFLICT:
+ re = "INST_CONFLICT";
+ break;
+ case CSYNC_INSTRUCTION_IGNORE:
+ re = "INST_IGNORE";
+ break;
+ case CSYNC_INSTRUCTION_SYNC:
+ re = "INST_SYNC";
+ break;
+ case CSYNC_INSTRUCTION_STAT_ERROR:
+ re = "INST_STAT_ERR";
+ break;
+ case CSYNC_INSTRUCTION_ERROR:
+ re = "INST_ERROR";
+ break;
+ case CSYNC_INSTRUCTION_DELETED:
+ re = "INST_DELETED";
+ break;
+ case CSYNC_INSTRUCTION_UPDATED:
+ re = "INST_UPDATED";
+ break;
+ }
+
+ return re;
+}
+
+
+void SyncRunFileLog::start( Utility::StopWatch stopWatch )
+{
+ MirallConfigFile cfg;
+ _file.reset(new QFile(cfg.configPath() + QLatin1String("sync_log") ));
+
+ _file->open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text);
+ _out.setDevice( _file.data() );
+
+ QDateTime dt = stopWatch.startTime();
+ QDateTime de = stopWatch.timeOfLap(QLatin1String("Sync Finished"));
+
+ _out << "#=#=#=# Syncrun started " << dateTimeStr(dt) << " until " << dateTimeStr(de) << " ("
+ << stopWatch.durationOfLap(QLatin1String("Sync Finished")) << " msec)" << endl;
+ _start = true;
+}
+
+#define L QLatin1String("|")
+
+void SyncRunFileLog::logItem( const SyncFileItem& item )
+{
+ // don't log the directory items that are in the list
+ if( item._direction == SyncFileItem::None ) {
+ return;
+ }
+
+ // log a list of fields if the log really adds lines.
+ if( _start ) {
+ _out << "# timestamp | duration | file | instruction | modtime | etag | "
+ "size | fileId | status | errorString | http result code | "
+ "other size | other modtime | other etag | other fileId | "
+ "other instruction" << endl;
+ _start = false;
+ }
+
+ _out << item._responseTimeStamp << L;
+ _out << QString::number(item._requestDuration) << L;
+ _out << item._file << L;
+ _out << instructionToStr( item._instruction ) << L;
+ _out << QString::number(item._modtime) << L;
+ _out << item._etag << L;
+ _out << QString::number(item._size) << L;
+ _out << item._fileId << L;
+ _out << item._status << L;
+ _out << item._errorString << L;
+ _out << QString::number(item._httpErrorCode) << L;
+ _out << QString::number(item.other._size) << L;
+ _out << QString::number(item.other._modtime) << L;
+ _out << item.other._etag << L;
+ _out << item.other._fileId << L;
+ _out << instructionToStr(item.other._instruction) << L;
+
+ _out << endl;
+
+}
+
+void SyncRunFileLog::close()
+{
+ _file->close();
+}
+
+}
diff --git a/src/mirall/syncrunfilelog.h b/src/mirall/syncrunfilelog.h
new file mode 100644
index 0000000..6682cf5
--- /dev/null
+++ b/src/mirall/syncrunfilelog.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) by Klaas Freitag <freitag at owncloud.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#ifndef SYNCRUNFILELOG_H
+#define SYNCRUNFILELOG_H
+
+#include <QFile>
+#include <QTextStream>
+#include <QScopedPointer>
+
+#include "mirall/syncfileitem.h"
+#include "mirall/utility.h"
+
+namespace Mirall {
+class SyncFileItem;
+
+class SyncRunFileLog
+{
+public:
+ SyncRunFileLog();
+ void start( Utility::StopWatch stopWatch );
+ void logItem( const SyncFileItem& item );
+ void close();
+
+protected:
+
+private:
+ QString dateTimeStr( const QDateTime& dt );
+ QString instructionToStr( csync_instructions_e inst );
+
+ QScopedPointer<QFile> _file;
+ QTextStream _out;
+ bool _start;
+
+};
+}
+
+#endif // SYNCRUNFILELOG_H
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list