Skip to content

Commit

Permalink
Add datetime to log file
Browse files Browse the repository at this point in the history
  • Loading branch information
d3m3vilurr committed Nov 3, 2016
1 parent ac94541 commit bcfdd65
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/global.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
* along with Moonlight; if not, see <http://www.gnu.org/licenses/>.
*/

#include <string.h>
#include <stdarg.h>
#include <signal.h>
#include <pthread.h>
#include <psp2/rtc.h>

#include "config.h"
#include "debug.h"
Expand All @@ -35,13 +37,24 @@ void DEBUG_PRINT(const char *s, ...) {
return;
}

va_list va;
char buffer[1024];
char buffer[1024] = {0};

SceDateTime time;
sceRtcGetCurrentClock(&time, 0);

snprintf(buffer, 26, "%04d%02d%02d %02d:%02d:%02d.%06d ",
time.year, time.month, time.day,
time.hour, time.minute, time.second,
time.microsecond);

va_list va;
va_start(va, s);
vsprintf(buffer, s, va);
int len = vsnprintf(&buffer[25], 998, s, va);
va_end(va);

fprintf(config.log_file, buffer);
if (buffer[len + 24] != '\n') {
fprintf(config.log_file, "\n");
}
fflush(config.log_file);
}

0 comments on commit bcfdd65

Please sign in to comment.