#include "log.h" #include #include #include const char *REG_NAMES[32] = { "R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", "R11", "R12", "R13", "R14", "R15", "R16", "R17", "R18", "R19", "R20", "R21", "R22", "R23", "R24", "R25", "R26", "R27", "GP", "SP", "FP", "RA"}; void _log(const char *filename, const char *funcname, int line_num, const char *level, const char *fmt, ...) { time_t now; char fmt_time[sizeof "2011-10-08T07:07:09Z"]; time(&now); strftime(&fmt_time[0], sizeof fmt_time, "%Y-%m-%dT%H:%M:%S", gmtime(&now)); printf("%s,%s,%s,%d,%s,\"", fmt_time, level, filename, line_num, funcname); va_list args; va_start(args, fmt); // TODO: Double quotes should be escaped before printing vprintf(fmt, args); va_end(args); printf("\"\n"); }