2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop 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, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It 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.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2015-10-03 13:16:42 +00:00
|
|
|
Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
#define OUTPUT_LOG(msg) (OutputDebugString((QString msg + "\n").toStdWString().c_str()))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (defined _DEBUG || defined _WITH_DEBUG)
|
|
|
|
|
|
|
|
struct DebugLogMemoryBuffer {
|
|
|
|
DebugLogMemoryBuffer(const void *ptr, uint32 size) : p(ptr), s(size) {
|
|
|
|
}
|
|
|
|
QString str() const {
|
|
|
|
QString result;
|
|
|
|
const uchar *buf((const uchar*)p);
|
|
|
|
const char *hex = "0123456789ABCDEF";
|
|
|
|
result.reserve(s * 3);
|
|
|
|
for (uint32 i = 0; i < s; ++i) {
|
|
|
|
result += hex[(buf[i] >> 4)];
|
|
|
|
result += hex[buf[i] & 0x0F];
|
|
|
|
result += ' ';
|
|
|
|
}
|
|
|
|
result.chop(1);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
const void *p;
|
|
|
|
uint32 s;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline DebugLogMemoryBuffer mb(const void *ptr, uint32 size) {
|
|
|
|
return DebugLogMemoryBuffer(ptr, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void debugLogWrite(const char *file, int32 line, const QString &v);
|
2014-10-20 22:49:37 +00:00
|
|
|
#define DEBUG_LOG(msg) { if (cDebug()) debugLogWrite(__FILE__, __LINE__, QString msg); }
|
2014-05-30 08:53:19 +00:00
|
|
|
//usage DEBUG_LOG(("log: %1 %2").arg(1).arg(2))
|
|
|
|
|
|
|
|
void tcpLogWrite(const QString &v);
|
2014-10-20 22:49:37 +00:00
|
|
|
#define TCP_LOG(msg) { if (cDebug()) tcpLogWrite(QString msg); }
|
2014-05-30 08:53:19 +00:00
|
|
|
//usage TCP_LOG(("log: %1 %2").arg(1).arg(2))
|
|
|
|
|
|
|
|
void mtpLogWrite(int32 dc, const QString &v);
|
2014-10-20 22:49:37 +00:00
|
|
|
#define MTP_LOG(dc, msg) { if (cDebug()) mtpLogWrite(dc, QString msg); }
|
2014-05-30 08:53:19 +00:00
|
|
|
//usage MTP_LOG(dc, ("log: %1 %2").arg(1).arg(2))
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define DEBUG_LOG(msg) (void(0))
|
|
|
|
#define TCP_LOG(msg) (void(0))
|
|
|
|
#define MTP_LOG(dc, msg) (void(0))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
inline const char *logBool(bool v) {
|
|
|
|
return v ? "[TRUE]" : "[FALSE]";
|
|
|
|
}
|
|
|
|
|
|
|
|
class MTPlong;
|
|
|
|
QString logVectorLong(const QVector<MTPlong> &ids);
|
2014-11-05 17:43:32 +00:00
|
|
|
QString logVectorLong(const QVector<uint64> &ids);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
#define LOG(msg) (logWrite(QString msg))
|
|
|
|
//usage LOG(("log: %1 %2").arg(1).arg(2))
|
|
|
|
|
|
|
|
void logWrite(const QString &v);
|
|
|
|
|
|
|
|
void logsInit();
|
|
|
|
void logsInitDebug();
|
|
|
|
void logsClose();
|