mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-28 12:22:37 +00:00
Fix incorrect URL Enocde process. Fix Emoji switch in URL argument. Remove module detection for importing Surge 2 subscription. Add timestamp in debug info.
41 lines
856 B
C++
41 lines
856 B
C++
#include <string>
|
|
#include <iostream>
|
|
#include <sys/time.h>
|
|
|
|
#include "logger.h"
|
|
|
|
extern bool print_debug_info;
|
|
|
|
std::string getTime(int type)
|
|
{
|
|
time_t lt;
|
|
char tmpbuf[32], cMillis[7];
|
|
std::string format;
|
|
timeval tv;
|
|
gettimeofday(&tv, NULL);
|
|
snprintf(cMillis, 7, "%.6ld", (long)tv.tv_usec);
|
|
lt = time(NULL);
|
|
struct tm *local = localtime(<);
|
|
switch(type)
|
|
{
|
|
case 1:
|
|
format = "%Y%m%d-%H%M%S";
|
|
break;
|
|
case 2:
|
|
format = "%Y/%m/%d %a %H:%M:%S." + std::string(cMillis);
|
|
break;
|
|
case 3:
|
|
format = "%Y-%m-%d %H:%M:%S";
|
|
break;
|
|
}
|
|
strftime(tmpbuf, 32, format.data(), local);
|
|
return std::string(tmpbuf);
|
|
}
|
|
|
|
void writeLog(int type, std::string content)
|
|
{
|
|
//placeholder
|
|
if(print_debug_info)
|
|
std::cerr<<getTime(2)<<" [DEBUG] "<<content<<"\n";
|
|
}
|