-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxlog.c
41 lines (35 loc) · 965 Bytes
/
xlog.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* This file belongs to the 'xlab' game engine.
* Copyright 2009 xfacter
* Copyright 2016 wickles
* This work is licensed under the LGPLv3
* subject to all terms as reproduced in the included LICENSE file.
*/
#include <stdarg.h>
#include <stdio.h>
#include <psptypes.h>
#include <psprtc.h>
#include "xlog.h"
#define X_BUFFER_SIZE (1024)
FILE* xlog_file = 0;
char buffer[X_BUFFER_SIZE];
void xLogPrint(char* text)
{
xlog_file = fopen("./xlog.txt", "a");
if (!xlog_file) return;
pspTime time_struct;
sceRtcGetCurrentClockLocalTime(&time_struct);
fprintf(xlog_file, "[%02u:%02u:%02u:%06u] %s\r\n", time_struct.hour, time_struct.minutes, time_struct.seconds, (unsigned int)time_struct.microseconds, text);
fclose(xlog_file);
xlog_file = 0;
}
void xLogPrintf(char* text, ... )
{
#ifdef X_DEBUG
va_list ap;
va_start(ap, text);
vsnprintf(buffer, X_BUFFER_SIZE, text, ap);
va_end(ap);
xLogPrint(buffer);
#endif
}