summaryrefslogtreecommitdiff
path: root/wsd/TraceFile.hpp
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-02-05 12:13:32 -0500
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-02-05 21:59:23 -0500
commita7afc59e517e20183c0632ce374ad93bde576c59 (patch)
tree1f3eaa30326b43a24f260e16a282212a7013cc1d /wsd/TraceFile.hpp
parent0476d1d9f234e25423b01bce37edf9a96ab6d4a2 (diff)
wsd: trace files support timestamp to prevent overwritting on restart
Change-Id: Ided928e7428d35f9ed322720ea306e090bdd0c38
Diffstat (limited to 'wsd/TraceFile.hpp')
-rw-r--r--wsd/TraceFile.hpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/wsd/TraceFile.hpp b/wsd/TraceFile.hpp
index 62616ac2e..059cbc300 100644
--- a/wsd/TraceFile.hpp
+++ b/wsd/TraceFile.hpp
@@ -13,6 +13,8 @@
#include <string>
#include <vector>
+#include <Poco/DateTime.h>
+#include <Poco/DateTimeFormatter.h>
#include <Poco/DeflatingStream.h>
#include <Poco/InflatingStream.h>
@@ -55,7 +57,7 @@ public:
_recordOutgoing(recordOugoing),
_compress(compress),
_filter(true),
- _stream(path, compress ? std::ios::binary : std::ios::out),
+ _stream(processPath(path), compress ? std::ios::binary : std::ios::out),
_deflater(_stream, Poco::DeflatingStreamBuf::STREAM_GZIP)
{
for (const auto& f : filters)
@@ -140,6 +142,20 @@ private:
}
}
+ static std::string processPath(const std::string& path)
+ {
+ const auto pos = path.find('%');
+ if (pos == std::string::npos)
+ {
+ return path;
+ }
+
+ std::string res = path.substr(0, pos);
+ res += Poco::DateTimeFormatter::format(Poco::DateTime(), "%Y-%m-%d_%H:%M:%S");
+ res += path.substr(pos + 1);
+ return res;
+ }
+
private:
const Poco::Int64 _epochStart;
const bool _recordOutgoing;