From 3b46382550c6ff08b14330c921fc624f5a44d810 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 7 May 2017 18:40:37 +0300 Subject: [PATCH] Add logging for libtgvoip when we have DebugLogs. --- Telegram/SourceFiles/calls/calls_call.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index 6bce0085d..e270768f6 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -419,6 +419,18 @@ void Call::createAndStartController(const MTPDphoneCall &call) { config.enableAGC = true; config.init_timeout = Global::CallConnectTimeoutMs() / 1000; config.recv_timeout = Global::CallPacketTimeoutMs() / 1000; + if (cDebug()) { + auto callLogFolder = cWorkingDir() + qsl("DebugLogs"); + auto callLogPath = callLogFolder + qsl("/last_call_log.txt"); + auto callLogNative = QFile::encodeName(QDir::toNativeSeparators(callLogPath)); + auto callLogBytesSrc = gsl::as_bytes(gsl::make_span(callLogNative)); + auto callLogBytesDst = gsl::as_writeable_bytes(gsl::make_span(config.logFilePath)); + if (callLogBytesSrc.size() + 1 <= callLogBytesDst.size()) { // +1 - zero-terminator + QFile(callLogPath).remove(); + QDir().mkpath(callLogFolder); + base::copy_bytes(callLogBytesDst, callLogBytesSrc); + } + } std::vector endpoints; ConvertEndpoint(endpoints, call.vconnection.c_phoneConnection());