Commit 321b1c4c authored by Robert Schmidt's avatar Robert Schmidt Committed by Teodora

Increase maximum logging line length for in-memory log

- Increase the maximum logging line for print done through
  log_output_memory().
  The reason is that we hit this line length when printing some machine
  generated configuration (XML) through the M-plane.  Increase to make
  more of it visible.
- To limit the impact, only increase this locally in function
  log_output_memory(), and statically assert that it will never be
  larger than 64 kB.
  In other places, we use the old limit.
- Move the definition MAX_LOG_TOTAL to log.c, because it's only used
  there.
parent 7beb8842
......@@ -52,6 +52,13 @@
// main log variables
/** @defgroup _max_length Maximum Length of LOG
* @ingroup _macro
* @brief the macros that describe the maximum length of LOG
* @{*/
#define MAX_LOG_TOTAL 16384 /*!< \brief the maximum length of a log */
// Fixme: a better place to be shure it is called
void read_cpu_hardware (void) __attribute__ ((constructor));
#if !defined(__arm__) && !defined(__aarch64__)
......@@ -877,31 +884,32 @@ static void log_output_memory(log_component_t *c, const char *file, const char *
* correctly. It was not a big problem because in practice MAX_LOG_TOTAL is
* big enough so that the buffer is never full.
*/
char log_buffer[MAX_LOG_TOTAL];
static_assert(4 * MAX_LOG_TOTAL <= 65536, "log buffer limited to 64kB, please reduce MAX_LOG_TOTAL\n");
char log_buffer[4 * MAX_LOG_TOTAL];
// make sure that for log trace the extra info is only printed once, reset when the level changes
if (level < OAILOG_TRACE) {
int n = log_header(c, log_buffer+len, MAX_LOG_TOTAL, file, func, line, level);
int n = log_header(c, log_buffer+len, sizeof(log_buffer), file, func, line, level);
if (n > 0) {
len += n;
if (len > MAX_LOG_TOTAL) {
len = MAX_LOG_TOTAL;
if (len > sizeof(log_buffer)) {
len = sizeof(log_buffer);
}
}
}
int n = vsnprintf(log_buffer+len, MAX_LOG_TOTAL-len, format, args);
int n = vsnprintf(log_buffer+len, sizeof(log_buffer)-len, format, args);
if (n > 0) {
len += n;
if (len > MAX_LOG_TOTAL) {
len = MAX_LOG_TOTAL;
if (len > sizeof(log_buffer)) {
len = sizeof(log_buffer);
}
}
if (!((g_log->flag) & FLAG_NOCOLOR)) {
int n = snprintf(log_buffer+len, MAX_LOG_TOTAL-len, "%s", log_level_highlight_end[level]);
int n = snprintf(log_buffer+len, sizeof(log_buffer)-len, "%s", log_level_highlight_end[level]);
if (n > 0) {
len += n;
if (len > MAX_LOG_TOTAL) {
len = MAX_LOG_TOTAL;
if (len > sizeof(log_buffer)) {
len = sizeof(log_buffer);
}
}
}
......@@ -941,7 +949,7 @@ static void log_output_memory(log_component_t *c, const char *file, const char *
}
}
}else{
AssertFatal(len >= 0 && len <= MAX_LOG_TOTAL, "Bad len %d\n", len);
AssertFatal(len >= 0 && len <= sizeof(log_buffer), "Bad len %d\n", len);
if (write(fileno(c->stream), log_buffer, len)) {};
}
}
......
......@@ -65,12 +65,6 @@
extern "C" {
#endif
/** @defgroup _max_length Maximum Length of LOG
* @ingroup _macro
* @brief the macros that describe the maximum length of LOG
* @{*/
#define MAX_LOG_TOTAL 16384 /*!< \brief the maximum length of a log */
/** @}*/
/** @defgroup _log_level Message levels defined by LOG
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment