Subversion Repositories Tewi

Rev

Rev 62 | Rev 191 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 62 Rev 182
Line 1... Line 1...
1
/* $Id: log.c 62 2024-09-18 20:02:26Z nishi $ */
1
/* $Id: log.c 182 2024-09-27 12:55:12Z nishi $ */
2
 
2
 
3
#include "cm_log.h"
3
#include "cm_log.h"
4
 
4
 
5
#include "cm_string.h"
5
#include "cm_string.h"
6
 
6
 
Line 9... Line 9...
9
#include <stdbool.h>
9
#include <stdbool.h>
10
#include <string.h>
10
#include <string.h>
11
#include <stdlib.h>
11
#include <stdlib.h>
12
#include <stdarg.h>
12
#include <stdarg.h>
13
 
13
 
-
 
14
#ifdef _PSP
-
 
15
#include <pspdebug.h>
-
 
16
#endif
-
 
17
 
14
FILE* logfile;
18
FILE* logfile;
15
 
19
 
16
bool cm_do_log = false;
20
bool cm_do_log = false;
17
 
21
 
18
#define LOGNAME_LENGTH 12
22
#define LOGNAME_LENGTH 12
Line 20... Line 24...
20
void cm_force_log(const char* log) {
24
void cm_force_log(const char* log) {
21
	time_t t = time(NULL);
25
	time_t t = time(NULL);
22
	struct tm* tm = localtime(&t);
26
	struct tm* tm = localtime(&t);
23
	char date[513];
27
	char date[513];
24
	strftime(date, 512, "%a %b %d %H:%M:%S %Z %Y", tm);
28
	strftime(date, 512, "%a %b %d %H:%M:%S %Z %Y", tm);
-
 
29
#ifdef _PSP
-
 
30
	pspDebugScreenPrintf("[%s] %s\n", date, log);
-
 
31
#else
25
	fprintf(logfile, "[%s] %s\n", date, log);
32
	fprintf(logfile, "[%s] %s\n", date, log);
-
 
33
#endif
26
	fflush(logfile);
34
	fflush(logfile);
27
}
35
}
28
 
36
 
29
void cm_log(const char* name, const char* log, ...) {
37
void cm_log(const char* name, const char* log, ...) {
30
	if(!cm_do_log) return;
38
	if(!cm_do_log) return;
Line 66... Line 74...
66
			result = cm_strcat(tmp, cbuf);
74
			result = cm_strcat(tmp, cbuf);
67
			free(tmp);
75
			free(tmp);
68
		}
76
		}
69
	}
77
	}
70
 
78
 
-
 
79
#ifdef _PSP
-
 
80
	pspDebugScreenPrintf("%s %s\n", namebuf, result);
-
 
81
#else
71
	fprintf(logfile, "%s %s\n", namebuf, result);
82
	fprintf(logfile, "%s %s\n", namebuf, result);
-
 
83
#endif
72
	va_end(args);
84
	va_end(args);
73
 
85
 
74
	free(result);
86
	free(result);
75
}
87
}