2023-03-03 23:59:49 +00:00
|
|
|
/*
|
|
|
|
* 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"
|
2023-07-04 17:55:58 +00:00
|
|
|
#include "core/format.hpp"
|
2023-03-03 23:59:49 +00:00
|
|
|
|
2024-01-15 17:26:09 +00:00
|
|
|
#define ShowInfo(format_string, ...) ShowInfoI(fmt::format(FMT_STRING(format_string), ## __VA_ARGS__))
|
|
|
|
|
2023-03-03 23:59:49 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2024-02-17 11:53:23 +00:00
|
|
|
#define Debug(name, level, format_string, ...) do { if ((level) == 0 || _debug_ ## name ## _level >= (level)) debug_print(#name, level, fmt::format(FMT_STRING(format_string), ## __VA_ARGS__).c_str()); } while (false)
|
2023-03-03 23:59:49 +00:00
|
|
|
|
2024-02-18 20:58:18 +00:00
|
|
|
[[noreturn]] void usererror_str(const char *msg);
|
|
|
|
[[noreturn]] void fatalerror_str(const char *msg);
|
2024-01-05 14:47:30 +00:00
|
|
|
|
|
|
|
#define UserError(format_string, ...) usererror_str(fmt::format(FMT_STRING(format_string), ## __VA_ARGS__).c_str())
|
|
|
|
#define FatalError(format_string, ...) fatalerror_str(fmt::format(FMT_STRING(format_string), ## __VA_ARGS__).c_str())
|
|
|
|
|
2023-03-03 23:59:49 +00:00
|
|
|
#endif /* DEBUG_FMT_H */
|