Conversation
| int msg_len = vsnprintf(message, sizeof(message), fmt, args); | ||
| if (msg_len >= (int)sizeof(message)) { | ||
| msg_len = sizeof(message) - 1; | ||
| char *message = malloc(output_len); |
There was a problem hiding this comment.
need to use od_malloc\od_free here
| @@ -0,0 +1,19 @@ | |||
| log_format "%p %t %l [%i %s] (%c) %M\n" | |||
There was a problem hiding this comment.
maybe this feature need to be tested not in separated flow, but in test/functional/tests ?
|
what about performance? this pr adds new allocation/deallocation per each log line |
Replaced per-log-line malloc/free with thread-local reusable buffers Eliminated heap allocation on every log call by using OD_THREAD_LOCAL buffers that are allocated once per thread and reused across all subsequent log lines. Two separate buffers are used: od_log_buf for the final formatted output (od_logger_write, od_logger_write_plain) and od_log_tmp for intermediate formatting (od_logger_escape, od_logger_format_json). |
| if (*buf != NULL && *cur_size >= size) { | ||
| return *buf; | ||
| } | ||
| char *new_buf = realloc(*buf, size); |
Summary
log_max_msg_sizeconfiguration option to control the maximum size of the entire log line (default: 1024, max: 32768 bytes)Motivation
When
log_queryis enabled, large SQL queries are silently truncated at 1024 bytes, making it impossible to debug issues involving long queries. This change makes the limit configurable while keeping the default behavior unchanged for backward compatibility.Configuration
log_max_msg_sizeInvalid values (0, negative) fall back to 1024. Values exceeding 32768 are capped.
Backward compatibility