2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
namespace Core {
|
|
|
|
class Launcher;
|
|
|
|
} // namespace Core
|
|
|
|
|
2016-01-11 15:43:29 +00:00
|
|
|
namespace Logs {
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-06-05 13:32:26 +00:00
|
|
|
void SetDebugEnabled(bool enabled);
|
|
|
|
bool DebugEnabled();
|
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
void start(not_null<Core::Launcher*> launcher);
|
|
|
|
bool started();
|
|
|
|
void finish();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
bool instanceChecked();
|
|
|
|
void multipleInstances();
|
2016-01-17 05:01:14 +00:00
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
void closeMain();
|
2016-02-08 10:50:56 +00:00
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
void writeMain(const QString &v);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
void writeDebug(const char *file, int32 line, const QString &v);
|
|
|
|
void writeTcp(const QString &v);
|
|
|
|
void writeMtp(int32 dc, const QString &v);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
QString full();
|
2016-01-17 05:01:14 +00:00
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
inline const char *b(bool v) {
|
|
|
|
return v ? "[TRUE]" : "[FALSE]";
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
struct MemoryBuffer {
|
|
|
|
MemoryBuffer(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 += ' ';
|
2016-01-11 15:43:29 +00:00
|
|
|
}
|
2017-12-11 14:45:29 +00:00
|
|
|
result.chop(1);
|
|
|
|
return result;
|
2016-01-11 15:43:29 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
const void *p;
|
|
|
|
uint32 s;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline MemoryBuffer mb(const void *ptr, uint32 size) {
|
|
|
|
return MemoryBuffer(ptr, size);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2017-12-11 14:45:29 +00:00
|
|
|
} // namespace Logs
|
|
|
|
|
2016-01-11 15:43:29 +00:00
|
|
|
#define LOG(msg) (Logs::writeMain(QString msg))
|
2014-05-30 08:53:19 +00:00
|
|
|
//usage LOG(("log: %1 %2").arg(1).arg(2))
|
|
|
|
|
2018-06-05 13:32:26 +00:00
|
|
|
#define DEBUG_LOG(msg) { if (Logs::DebugEnabled() || !Logs::started()) Logs::writeDebug(__FILE__, __LINE__, QString msg); }
|
2016-01-11 15:43:29 +00:00
|
|
|
//usage DEBUG_LOG(("log: %1 %2").arg(1).arg(2))
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-06-05 13:32:26 +00:00
|
|
|
#define TCP_LOG(msg) { if (Logs::DebugEnabled() || !Logs::started()) Logs::writeTcp(QString msg); }
|
2016-01-11 15:43:29 +00:00
|
|
|
//usage TCP_LOG(("log: %1 %2").arg(1).arg(2))
|
|
|
|
|
2018-06-05 13:32:26 +00:00
|
|
|
#define MTP_LOG(dc, msg) { if (Logs::DebugEnabled() || !Logs::started()) Logs::writeMtp(dc, QString msg); }
|
2016-01-11 15:43:29 +00:00
|
|
|
//usage MTP_LOG(dc, ("log: %1 %2").arg(1).arg(2))
|