mirror of
https://github.com/cathery/sys-con.git
synced 2025-01-01 03:14:48 +00:00
replace time posix functions with time service functions
This commit is contained in:
parent
72497b76f1
commit
d5cd9b7b0d
@ -1,9 +1,7 @@
|
|||||||
#include "switch.h"
|
#include "switch.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "configFile.h"
|
#include "configFile.h"
|
||||||
#include <stdarg.h>
|
#include <stratosphere.hpp>
|
||||||
#include <stdio.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
static Mutex g_PrintMutex = 0;
|
static Mutex g_PrintMutex = 0;
|
||||||
|
|
||||||
@ -11,23 +9,15 @@ void WriteToLog(const char *fmt, ...)
|
|||||||
{
|
{
|
||||||
mutexLock(&g_PrintMutex);
|
mutexLock(&g_PrintMutex);
|
||||||
|
|
||||||
#ifdef __APPLET__
|
u64 ts;
|
||||||
va_list va;
|
TimeCalendarTime caltime;
|
||||||
va_start(va, fmt);
|
timeGetCurrentTime(TimeType_LocalSystemClock, &ts);
|
||||||
vprintf(fmt, va);
|
timeToCalendarTimeWithMyRule(ts, &caltime, nullptr);
|
||||||
printf("\n");
|
|
||||||
va_end(va);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
time_t unixTime = time(NULL);
|
|
||||||
struct tm tStruct;
|
|
||||||
localtime_r(&unixTime, &tStruct);
|
|
||||||
|
|
||||||
FILE *fp = fopen(CONFIG_PATH "log.txt", "a");
|
FILE *fp = fopen(CONFIG_PATH "log.txt", "a");
|
||||||
|
|
||||||
//Print time
|
//Print time
|
||||||
fprintf(fp, "%04i-%02i-%02i %02i:%02i:%02i: ", (tStruct.tm_year + 1900), tStruct.tm_mon, tStruct.tm_mday, tStruct.tm_hour, tStruct.tm_min, tStruct.tm_sec);
|
fprintf(fp, "%04i-%02i-%02i %02i:%02i:%02i: ", caltime.year, caltime.month, caltime.day, caltime.hour, caltime.minute, caltime.second);
|
||||||
|
|
||||||
//Print the actual text
|
//Print the actual text
|
||||||
va_list va;
|
va_list va;
|
||||||
@ -37,7 +27,6 @@ void WriteToLog(const char *fmt, ...)
|
|||||||
|
|
||||||
fprintf(fp, "\n");
|
fprintf(fp, "\n");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
#endif
|
|
||||||
|
|
||||||
mutexUnlock(&g_PrintMutex);
|
mutexUnlock(&g_PrintMutex);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user