init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
This commit is contained in:
72
Telegram/SourceFiles/logs.h
Normal file
72
Telegram/SourceFiles/logs.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "base/basic_types.h"
|
||||
#include "base/assertion.h"
|
||||
#include "base/debug_log.h"
|
||||
|
||||
namespace Logs {
|
||||
|
||||
void SetDebugEnabled(bool enabled);
|
||||
bool DebugEnabled();
|
||||
[[nodiscard]] bool WritingEntry();
|
||||
|
||||
void start();
|
||||
bool started();
|
||||
void finish();
|
||||
|
||||
bool instanceChecked();
|
||||
void multipleInstances();
|
||||
|
||||
void closeMain();
|
||||
|
||||
void writeMain(const QString &v);
|
||||
void writeDebug(const QString &v);
|
||||
void writeMtp(int32 dc, const QString &v);
|
||||
|
||||
QString full();
|
||||
|
||||
inline const char *b(bool v) {
|
||||
return v ? "[TRUE]" : "[FALSE]";
|
||||
}
|
||||
|
||||
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 += ' ';
|
||||
}
|
||||
result.chop(1);
|
||||
return result;
|
||||
}
|
||||
|
||||
const void *p;
|
||||
uint32 s;
|
||||
|
||||
};
|
||||
|
||||
inline MemoryBuffer mb(const void *ptr, uint32 size) {
|
||||
return MemoryBuffer(ptr, size);
|
||||
}
|
||||
|
||||
} // namespace Logs
|
||||
|
||||
#define MTP_LOG(dc, msg) {\
|
||||
if (Logs::DebugEnabled() || !Logs::started()) {\
|
||||
Logs::writeMtp(dc, QString msg);\
|
||||
}\
|
||||
}
|
||||
//usage MTP_LOG(dc, ("log: %1 %2").arg(1).arg(2))
|
||||
Reference in New Issue
Block a user