Changeset 62 in Main for trunk/Common
- Timestamp:
- Sep 19, 2024, 5:02:26 AM (2 months ago)
- Location:
- trunk/Common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/cm_log.h
r3 r62 5 5 6 6 void cm_log(const char* name, const char* log, ...); 7 void cm_force_log(const char* log); 7 8 8 9 #endif -
trunk/Common/log.c
r12 r62 5 5 #include "cm_string.h" 6 6 7 #include <time.h> 7 8 #include <stdio.h> 8 9 #include <stdbool.h> … … 11 12 #include <stdarg.h> 12 13 14 FILE* logfile; 15 13 16 bool cm_do_log = false; 14 17 15 18 #define LOGNAME_LENGTH 12 19 20 void cm_force_log(const char* log) { 21 time_t t = time(NULL); 22 struct tm* tm = localtime(&t); 23 char date[513]; 24 strftime(date, 512, "%a %b %d %H:%M:%S %Z %Y", tm); 25 fprintf(logfile, "[%s] %s\n", date, log); 26 fflush(logfile); 27 } 16 28 17 29 void cm_log(const char* name, const char* log, ...) { … … 57 69 } 58 70 59 fprintf( stderr, "%s %s\n", namebuf, result);71 fprintf(logfile, "%s %s\n", namebuf, result); 60 72 va_end(args); 61 73
Note:
See TracChangeset
for help on using the changeset viewer.