Telegram-Android/TMessagesProj/jni/tgnet/FileLog.h

43 lines
1.3 KiB
C
Raw Normal View History

2015-09-24 22:52:02 +02:00
/*
2018-07-30 04:07:02 +02:00
* This is the source code of tgnet library v. 1.1
2015-09-24 22:52:02 +02:00
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
2018-07-30 04:07:02 +02:00
* Copyright Nikolai Kudashov, 2015-2018.
2015-09-24 22:52:02 +02:00
*/
#ifndef FILELOG_H
#define FILELOG_H
#include "Defines.h"
class FileLog {
public:
2018-07-30 04:07:02 +02:00
FileLog();
void init(std::string path);
2022-09-16 20:48:21 +02:00
static void fatal(const char *message, ...) __attribute__((format (printf, 1, 2)));
2015-09-24 22:52:02 +02:00
static void e(const char *message, ...) __attribute__((format (printf, 1, 2)));
static void w(const char *message, ...) __attribute__((format (printf, 1, 2)));
static void d(const char *message, ...) __attribute__((format (printf, 1, 2)));
2023-03-24 12:38:14 +01:00
static void ref(const char *message, ...) __attribute__((format (printf, 1, 2)));
static void delref(const char *message, ...) __attribute__((format (printf, 1, 2)));
2018-07-30 04:07:02 +02:00
static FileLog &getInstance();
private:
FILE *logFile = nullptr;
pthread_mutex_t mutex;
2015-09-24 22:52:02 +02:00
};
2019-01-23 18:03:33 +01:00
extern bool LOGS_ENABLED;
2022-09-16 20:48:21 +02:00
#define DEBUG_FATAL FileLog::getInstance().fatal
2018-07-30 04:07:02 +02:00
#define DEBUG_E FileLog::getInstance().e
#define DEBUG_W FileLog::getInstance().w
#define DEBUG_D FileLog::getInstance().d
2015-09-24 22:52:02 +02:00
2023-03-24 12:38:14 +01:00
#define DEBUG_REF FileLog::getInstance().ref
#define DEBUG_DELREF FileLog::getInstance().delref
2015-09-24 22:52:02 +02:00
#endif