42 lines
1.2 KiB
C++
42 lines
1.2 KiB
C++
#pragma once
|
|
#include "util.h"
|
|
|
|
#ifdef __APPLE__
|
|
#define LOG(M,...) { printf(M"\n", ##__VA_ARGS__); LogRemote::I.log(M, ##__VA_ARGS__); }
|
|
#elif __ANDROID__
|
|
#define LOG(...) { ((void)__android_log_print(ANDROID_LOG_INFO, "PanoPainterCPP", __VA_ARGS__)); LogRemote::I.log(__VA_ARGS__); }
|
|
#elif _WIN32
|
|
#define LOG(M,...) { printf(M"\n", ##__VA_ARGS__); LogRemote::I.log(M, ##__VA_ARGS__); }
|
|
#define LOGW(M,...) { wprintf(M"\n", ##__VA_ARGS__); LogRemote::I.log(M, ##__VA_ARGS__); }
|
|
#endif
|
|
|
|
class LogRemote
|
|
{
|
|
public:
|
|
static LogRemote I;
|
|
bool m_running = false;
|
|
bool m_error = false;
|
|
std::thread m_thread;
|
|
std::mutex m_mutex;
|
|
BlockingQueue<std::string> m_mq;
|
|
// Store messages until the file is open
|
|
std::vector<std::string> m_tmp;
|
|
CURL *curl = nullptr;
|
|
CURLcode res;
|
|
std::string readBuffer;
|
|
std::string m_url = "http://omigamedev.ddns.net:8083";
|
|
int m_session;
|
|
std::ofstream m_logfile;
|
|
|
|
void start();
|
|
void stop();
|
|
void net_init();
|
|
std::string net_request(std::string cmd, std::string data = "");
|
|
void net_close();
|
|
void file_init();
|
|
void file_close();
|
|
void log(const char* format, ...);
|
|
void log(const wchar_t* format, ...);
|
|
~LogRemote();
|
|
};
|