Fix truncation of dump_command_log console command output
This commit is contained in:
@@ -686,7 +686,7 @@ static void DumpSubCommandLogEntry(char *&buffer, const char *last, const Comman
|
||||
}
|
||||
}
|
||||
|
||||
static void DumpSubCommandLog(char *&buffer, const char *last, const CommandLog &cmd_log, const unsigned int count)
|
||||
static void DumpSubCommandLog(char *&buffer, const char *last, const CommandLog &cmd_log, const unsigned int count, std::function<char *(char *)> &flush)
|
||||
{
|
||||
unsigned int log_index = cmd_log.next;
|
||||
for (unsigned int i = 0 ; i < count; i++) {
|
||||
@@ -702,20 +702,22 @@ static void DumpSubCommandLog(char *&buffer, const char *last, const CommandLog
|
||||
DumpSubCommandLogEntry(buffer, last, entry);
|
||||
|
||||
buffer += seprintf(buffer, last, "\n");
|
||||
if (flush) buffer = flush(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
char *DumpCommandLog(char *buffer, const char *last)
|
||||
char *DumpCommandLog(char *buffer, const char *last, std::function<char *(char *)> flush)
|
||||
{
|
||||
const unsigned int count = std::min<unsigned int>(_command_log.count, 256);
|
||||
buffer += seprintf(buffer, last, "Command Log:\n Showing most recent %u of %u commands\n", count, _command_log.count);
|
||||
DumpSubCommandLog(buffer, last, _command_log, count);
|
||||
DumpSubCommandLog(buffer, last, _command_log, count, flush);
|
||||
|
||||
if (_command_log_aux.count > 0) {
|
||||
const unsigned int aux_count = std::min<unsigned int>(_command_log_aux.count, 32);
|
||||
buffer += seprintf(buffer, last, "\n Showing most recent %u of %u commands (aux log)\n", aux_count, _command_log_aux.count);
|
||||
DumpSubCommandLog(buffer, last, _command_log_aux, aux_count);
|
||||
DumpSubCommandLog(buffer, last, _command_log_aux, aux_count, flush);
|
||||
}
|
||||
if (flush) buffer = flush(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
@@ -83,7 +83,7 @@ static inline DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
|
||||
}
|
||||
|
||||
void ClearCommandLog();
|
||||
char *DumpCommandLog(char *buffer, const char *last);
|
||||
char *DumpCommandLog(char *buffer, const char *last, std::function<char *(char *)> flush);
|
||||
|
||||
void ExecuteCommandQueue();
|
||||
void ClearCommandQueue();
|
||||
|
@@ -2576,9 +2576,11 @@ DEF_CONSOLE_CMD(ConDumpCommandLog)
|
||||
return true;
|
||||
}
|
||||
|
||||
char buffer[32768];
|
||||
DumpCommandLog(buffer, lastof(buffer));
|
||||
char buffer[2048];
|
||||
DumpCommandLog(buffer, lastof(buffer), [&](char *current) -> char * {
|
||||
PrintLineByLine(buffer);
|
||||
return buffer;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -508,7 +508,7 @@ char *CrashLog::LogRecentNews(char *buffer, const char *last) const
|
||||
*/
|
||||
char *CrashLog::LogCommandLog(char *buffer, const char *last) const
|
||||
{
|
||||
buffer = DumpCommandLog(buffer, last);
|
||||
buffer = DumpCommandLog(buffer, last, nullptr);
|
||||
buffer += seprintf(buffer, last, "\n");
|
||||
buffer = DumpSpecialEventsLog(buffer, last);
|
||||
buffer += seprintf(buffer, last, "\n");
|
||||
|
Reference in New Issue
Block a user