mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use std::string to return the debug level information
parent
10e12154f5
commit
53f83c31b0
|
@ -220,22 +220,14 @@ void SetDebugString(const char *s, void (*error_func)(const std::string &))
|
||||||
* Just return a string with the values of all the debug categories.
|
* Just return a string with the values of all the debug categories.
|
||||||
* @return string with debug-levels
|
* @return string with debug-levels
|
||||||
*/
|
*/
|
||||||
const char *GetDebugString()
|
std::string GetDebugString()
|
||||||
{
|
{
|
||||||
const DebugLevel *i;
|
std::string result;
|
||||||
static char dbgstr[150];
|
for (const DebugLevel *i = debug_level; i != endof(debug_level); ++i) {
|
||||||
char dbgval[20];
|
if (!result.empty()) result += ", ";
|
||||||
|
fmt::format_to(std::back_inserter(result), "{}={}", i->name, *i->level);
|
||||||
memset(dbgstr, 0, sizeof(dbgstr));
|
|
||||||
i = debug_level;
|
|
||||||
seprintf(dbgstr, lastof(dbgstr), "%s=%d", i->name, *i->level);
|
|
||||||
|
|
||||||
for (i++; i != endof(debug_level); i++) {
|
|
||||||
seprintf(dbgval, lastof(dbgval), ", %s=%d", i->name, *i->level);
|
|
||||||
strecat(dbgstr, dbgval, lastof(dbgstr));
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
return dbgstr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,7 +58,7 @@ extern int _debug_random_level;
|
||||||
|
|
||||||
void DumpDebugFacilityNames(std::back_insert_iterator<std::string> &output_iterator);
|
void DumpDebugFacilityNames(std::back_insert_iterator<std::string> &output_iterator);
|
||||||
void SetDebugString(const char *s, void (*error_func)(const std::string &));
|
void SetDebugString(const char *s, void (*error_func)(const std::string &));
|
||||||
const char *GetDebugString();
|
std::string GetDebugString();
|
||||||
|
|
||||||
/* Shorter form for passing filename and linenumber */
|
/* Shorter form for passing filename and linenumber */
|
||||||
#define FILE_LINE __FILE__, __LINE__
|
#define FILE_LINE __FILE__, __LINE__
|
||||||
|
|
Loading…
Reference in New Issue