Keep log format as "function() in file:line: msg", but pass the arguments in consistent order between the host and guest app.

This commit is contained in:
Martin Fouilleul 2023-09-18 12:17:36 +02:00 committed by MartinFouilleul
parent 44477782d8
commit 116e614ab6
5 changed files with 20 additions and 20 deletions

View File

@ -45,8 +45,8 @@ oc_log_output* OC_LOG_DEFAULT_OUTPUT = &oc_logDefaultOutput;
void platform_log_push(oc_log_output* output, void platform_log_push(oc_log_output* output,
oc_log_level level, oc_log_level level,
const char* file,
const char* function, const char* function,
const char* file,
int line, int line,
const char* fmt, const char* fmt,
va_list ap) va_list ap)
@ -60,7 +60,7 @@ void platform_log_push(oc_log_output* output,
if(isatty(fd)) if(isatty(fd))
{ {
fprintf(output->f, fprintf(output->f,
"%s%s:%s %s in %s():%i: ", "%s%s:%s %s() in %s:%i: ",
OC_LOG_FORMATS[level], OC_LOG_FORMATS[level],
OC_LOG_HEADINGS[level], OC_LOG_HEADINGS[level],
OC_LOG_FORMAT_STOP, OC_LOG_FORMAT_STOP,
@ -71,7 +71,7 @@ void platform_log_push(oc_log_output* output,
else else
{ {
fprintf(output->f, fprintf(output->f,
"%s: %s in %s():%i: ", "%s: %s() in %s:%i: ",
OC_LOG_HEADINGS[level], OC_LOG_HEADINGS[level],
function, function,
file, file,

View File

@ -50,18 +50,18 @@ static oc_log_output oc_logDefaultOutput = { .kind = ORCA_LOG_OUTPUT_CONSOLE };
oc_log_output* OC_LOG_DEFAULT_OUTPUT = &oc_logDefaultOutput; oc_log_output* OC_LOG_DEFAULT_OUTPUT = &oc_logDefaultOutput;
void ORCA_IMPORT(oc_bridge_log)(oc_log_level level, void ORCA_IMPORT(oc_bridge_log)(oc_log_level level,
int fileLen,
const char* file,
int functionLen, int functionLen,
const char* function, const char* function,
int fileLen,
const char* file,
int line, int line,
int msgLen, int msgLen,
const char* msg); const char* msg);
void platform_log_push(oc_log_output* output, void platform_log_push(oc_log_output* output,
oc_log_level level, oc_log_level level,
const char* file,
const char* function, const char* function,
const char* file,
int line, int line,
const char* fmt, const char* fmt,
va_list ap) va_list ap)
@ -76,7 +76,7 @@ void platform_log_push(oc_log_output* output,
oc_str8 string = oc_str8_list_join(scratch.arena, ctx.list); oc_str8 string = oc_str8_list_join(scratch.arena, ctx.list);
oc_bridge_log(level, strlen(file), file, strlen(function), function, line, oc_str8_ip(string)); oc_bridge_log(level, strlen(function), function, strlen(file), file, line, oc_str8_ip(string));
oc_scratch_end(scratch); oc_scratch_end(scratch);
} }

View File

@ -28,8 +28,8 @@ void oc_log_set_level(oc_log_level level)
void platform_log_push(oc_log_output* output, void platform_log_push(oc_log_output* output,
oc_log_level level, oc_log_level level,
const char* file,
const char* function, const char* function,
const char* file,
int line, int line,
const char* fmt, const char* fmt,
va_list ap); va_list ap);

View File

@ -134,10 +134,10 @@ void oc_bridge_clipboard_set_string(oc_wasm_str8 value)
} }
void oc_bridge_log(oc_log_level level, void oc_bridge_log(oc_log_level level,
int fileLen,
char* file,
int functionLen, int functionLen,
char* function, char* function,
int fileLen,
char* file,
int line, int line,
int msgLen, int msgLen,
char* msg) char* msg)
@ -179,14 +179,14 @@ void oc_bridge_log(oc_log_level level,
} }
char* payload = (char*)entry + sizeof(log_entry); char* payload = (char*)entry + sizeof(log_entry);
entry->file.len = fileLen;
entry->file.ptr = payload;
payload += entry->file.len;
entry->function.len = functionLen; entry->function.len = functionLen;
entry->function.ptr = payload; entry->function.ptr = payload;
payload += entry->function.len; payload += entry->function.len;
entry->file.len = fileLen;
entry->file.ptr = payload;
payload += entry->file.len;
entry->msg.len = msgLen; entry->msg.len = msgLen;
entry->msg.ptr = payload; entry->msg.ptr = payload;
payload += entry->msg.len; payload += entry->msg.len;
@ -203,8 +203,8 @@ void oc_bridge_log(oc_log_level level,
oc_list_push_back(&debug->logEntries, &entry->listElt); oc_list_push_back(&debug->logEntries, &entry->listElt);
oc_log_ext(level, oc_log_ext(level,
file,
function, function,
file,
line, line,
"%.*s\n", "%.*s\n",
msgLen, msgLen,

View File

@ -5,16 +5,16 @@
"ret": {"name": "void", "tag": "v"}, "ret": {"name": "void", "tag": "v"},
"args": [ {"name": "level", "args": [ {"name": "level",
"type": {"name": "oc_log_level", "tag": "i"}}, "type": {"name": "oc_log_level", "tag": "i"}},
{"name": "fileLen",
"type": {"name": "int", "tag": "i"}},
{"name": "file",
"type": {"name": "char*", "tag": "p"},
"len": {"count": "fileLen"}},
{"name": "functionLen", {"name": "functionLen",
"type": {"name": "int", "tag": "i"}}, "type": {"name": "int", "tag": "i"}},
{"name": "function", {"name": "function",
"type": {"name": "char*", "tag": "p"}, "type": {"name": "char*", "tag": "p"},
"len": {"count": "functionLen"}}, "len": {"count": "functionLen"}},
{"name": "fileLen",
"type": {"name": "int", "tag": "i"}},
{"name": "file",
"type": {"name": "char*", "tag": "p"},
"len": {"count": "fileLen"}},
{"name": "line", {"name": "line",
"type": {"name": "int", "tag": "i"}}, "type": {"name": "int", "tag": "i"}},
{"name": "msgLen", {"name": "msgLen",