This is an automated email from the ASF dual-hosted git repository. astitcher pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-proton.git
commit a0443f64b2394947100c4f364f72af9a9f41ee31 Author: Andrew Stitcher <[email protected]> AuthorDate: Wed Dec 15 22:28:50 2021 -0500 PROTON-2562: Use a fixed size buffer for more log messages The log messages that still use a pn_string_t either use that type because of internal APIs. --- c/src/core/logger.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/c/src/core/logger.c b/c/src/core/logger.c index 0ea4fba59..2ee9e1dd1 100644 --- a/c/src/core/logger.c +++ b/c/src/core/logger.c @@ -247,8 +247,16 @@ void pni_logger_log(pn_logger_t *logger, pn_log_subsystem_t subsystem, pn_log_le void pni_logger_vlogf(pn_logger_t *logger, pn_log_subsystem_t subsystem, pn_log_level_t severity, const char *fmt, va_list ap) { assert(logger); - pn_string_vformat(logger->scratch, fmt, ap); - pni_logger_log(logger, subsystem, severity, pn_string_get(logger->scratch)); + char buf[1024]; + pn_fixed_string_t output = pn_fixed_string(buf, sizeof(buf)); + pn_fixed_string_vaddf(&output, fmt, ap); + if (output.position==output.size) { + // Message overflow + const char truncated[] = " ... (truncated)"; + output.position -= sizeof(truncated); + pn_fixed_string_append(&output, pn_string_const(truncated, sizeof(truncated))); + } + pni_logger_log(logger, subsystem, severity, buf); } void pn_logger_logf(pn_logger_t *logger, pn_log_subsystem_t subsystem, pn_log_level_t severity, const char *fmt, ...) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
