log/stats: allow longer counter names

With the addition of exception policy stats counters, the human readable
version of the sats log was mis-aligned, when counters for per-app-proto
were enabled.

Width change made large enough to accomodate a counter as long as
"app_layer.error.bittorrent-dht.exception_policy.pass_packet" which
could be valid.

Task #5816
pull/10805/head
Juliana Fajardini 1 year ago committed by Victor Julien
parent 0f6dbf650e
commit 172b55c547

@ -1,4 +1,4 @@
/* Copyright (C) 2014 Open Information Security Foundation
/* Copyright (C) 2014-2024 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
@ -89,17 +89,16 @@ static int LogStatsLogger(ThreadVars *tv, void *thread_data, const StatsTable *s
int days = in_hours / 24;
MemBufferWriteString(aft->buffer, "----------------------------------------------"
"--------------------------------------\n");
"-----------------------------------------------------\n");
MemBufferWriteString(aft->buffer, "Date: %" PRId32 "/%" PRId32 "/%04d -- "
"%02d:%02d:%02d (uptime: %"PRId32"d, %02dh %02dm %02ds)\n",
tms->tm_mon + 1, tms->tm_mday, tms->tm_year + 1900, tms->tm_hour,
tms->tm_min, tms->tm_sec, days, hours, min, sec);
MemBufferWriteString(aft->buffer, "----------------------------------------------"
"--------------------------------------\n");
MemBufferWriteString(aft->buffer, "%-45s | %-25s | %-s\n", "Counter", "TM Name",
"Value");
"-----------------------------------------------------\n");
MemBufferWriteString(aft->buffer, "%-60s | %-25s | %-s\n", "Counter", "TM Name", "Value");
MemBufferWriteString(aft->buffer, "----------------------------------------------"
"--------------------------------------\n");
"-----------------------------------------------------\n");
/* global stats */
uint32_t u = 0;
@ -112,7 +111,7 @@ static int LogStatsLogger(ThreadVars *tv, void *thread_data, const StatsTable *s
continue;
char line[256];
size_t len = snprintf(line, sizeof(line), "%-45s | %-25s | %-" PRIu64 "\n",
size_t len = snprintf(line, sizeof(line), "%-60s | %-25s | %-" PRIu64 "\n",
st->stats[u].name, st->stats[u].tm_name, st->stats[u].value);
/* since we can have many threads, the buffer might not be big enough.
@ -206,7 +205,7 @@ TmEcode LogStatsLogThreadDeinit(ThreadVars *t, void *data)
/** \brief Create a new http log LogFileCtx.
* \param conf Pointer to ConfNode containing this loggers configuration.
* \return NULL if failure, LogFileCtx* to the file_ctx if succesful
* \return NULL if failure, LogFileCtx* to the file_ctx if successful
* */
static OutputInitResult LogStatsLogInitCtx(ConfNode *conf)
{

Loading…
Cancel
Save