Subversion Repositories Tewi

Rev

Rev 212 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 212 Rev 253
Line 1... Line 1...
1
/* $Id: log.c 212 2024-10-02 17:44:55Z nishi $ */
1
/* $Id: log.c 253 2024-10-04 03:13:36Z nishi $ */
2
 
2
 
3
#include "cm_log.h"
3
#include "cm_log.h"
4
 
4
 
-
 
5
#include "../config.h"
5
#include "cm_string.h"
6
#include "cm_string.h"
6
 
7
 
7
#include <time.h>
8
#include <time.h>
8
#include <stdio.h>
9
#include <stdio.h>
9
#include <stdbool.h>
10
#include <stdbool.h>
Line 23... Line 24...
23
 
24
 
24
bool cm_do_log = false;
25
bool cm_do_log = false;
25
 
26
 
26
#define LOGNAME_LENGTH 12
27
#define LOGNAME_LENGTH 12
27
 
28
 
-
 
29
#ifdef BUILD_GUI_VALID
-
 
30
void AddLog(const char* str);
-
 
31
#endif
-
 
32
 
28
void cm_force_log(const char* log) {
33
void cm_force_log(const char* log) {
29
	time_t t = time(NULL);
34
	time_t t = time(NULL);
30
	struct tm* tm = localtime(&t);
35
	struct tm* tm = localtime(&t);
31
	char date[513];
36
	char date[513];
-
 
37
	char* str;
32
	strftime(date, 512, "%a %b %d %H:%M:%S %Z %Y", tm);
38
	strftime(date, 512, "%a %b %d %H:%M:%S %Z %Y", tm);
33
#ifdef _PSP
39
#ifdef _PSP
34
	pspDebugScreenPrintf("[%s] %s\n", date, log);
40
	pspDebugScreenPrintf("[%s] %s\n", date, log);
35
#elif defined(__PPU__)
41
#elif defined(__PPU__)
36
	tt_printf("[%s] %s\n", date, log);
42
	tt_printf("[%s] %s\n", date, log);
-
 
43
#elif defined(BUILD_GUI_VALID)
-
 
44
	str = malloc(strlen(date) + strlen(log) + 3 + 1);
-
 
45
	str[strlen(date) + strlen(log) + 3] = 0;
-
 
46
	sprintf(str, "[%s] %s", date, log);
-
 
47
	AddLog(str);
-
 
48
	free(str);
37
#else
49
#else
38
	fprintf(logfile, "[%s] %s\n", date, log);
50
	fprintf(logfile, "[%s] %s\n", date, log);
39
#endif
-
 
40
	fflush(logfile);
51
	fflush(logfile);
-
 
52
#endif
41
}
53
}
42
 
54
 
43
void cm_log(const char* name, const char* log, ...) {
55
void cm_log(const char* name, const char* log, ...) {
44
	va_list args;
56
	va_list args;
45
	char namebuf[LOGNAME_LENGTH + 1];
57
	char namebuf[LOGNAME_LENGTH + 1];