Add fmt-based Debug macro for upstream

pull/491/head
Jonathan G Rennison 1 year ago
parent a2d2dcd3d5
commit 3549d5be20

@ -139,7 +139,7 @@ char *DumpDebugFacilityNames(char *buf, char *last)
* @param dbg Debug category.
* @param buf Text line to output.
*/
static void debug_print(const char *dbg, const char *buf)
void debug_print(const char *dbg, const char *buf)
{
if (_debug_socket != INVALID_SOCKET) {
char buf2[1024 + 32];

@ -64,6 +64,7 @@ extern bool _save_DBGC_data;
extern std::string _loadgame_DBGC_data;
void CDECL debug(const char *dbg, const char *format, ...) WARN_FORMAT(2, 3);
void debug_print(const char *dbg, const char *buf);
char *DumpDebugFacilityNames(char *buf, char *last);
void SetDebugString(const char *s, void (*error_func)(const char *));

@ -0,0 +1,24 @@
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file debug_fmt.h Functions related to debugging. */
#ifndef DEBUG_FMT_H
#define DEBUG_FMT_H
#include "debug.h"
#include "3rdparty/fmt/format.h"
/**
* Ouptut a line of debugging information.
* @param name The category of debug information.
* @param level The maximum debug level this message should be shown at. When the debug level for this category is set lower, then the message will not be shown.
* @param format_string The formatting string of the message.
*/
#define Debug(name, level, format_string, ...) if ((level) == 0 || _debug_ ## name ## _level >= (level)) debug_print(#name, fmt::format(FMT_STRING(format_string), ## __VA_ARGS__).c_str())
#endif /* DEBUG_FMT_H */
Loading…
Cancel
Save