-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
033da10
commit fa0ebf9
Showing
8 changed files
with
211 additions
and
552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,40 @@ | ||
//------------------------------------------------------------------------------ | ||
//! @file Debug.h | ||
//! @brief Provide a debug printing macro. | ||
//! @brief Provide debug printing macros. | ||
// | ||
// SPDX-FileCopyrightText: Michael Popoloski | ||
// SPDX-License-Identifier: MIT | ||
//------------------------------------------------------------------------------ | ||
#pragma once | ||
|
||
#include <fmt/core.h> | ||
|
||
#include "Config.h" | ||
#include <iostream> | ||
|
||
namespace netlist { | ||
|
||
template <typename... T> | ||
void DebugMessage(const char *filename, const int line, fmt::format_string<T...> fmt, T &&...args) { | ||
fmt::print("{}:{}: ", filename, line); | ||
fmt::print(fmt, std::forward<T>(args)...); | ||
} | ||
|
||
template <typename... T> void InfoMessage(fmt::format_string<T...> fmt, T &&...args) { | ||
fmt::print(fmt, std::forward<T>(args)...); | ||
} | ||
|
||
} // namespace netlist | ||
|
||
#ifdef DEBUG | ||
# define DEBUG_PRINT(x) \ | ||
if (netlist::Config::getInstance().debugEnabled) { \ | ||
std::cerr << x; \ | ||
# define DEBUG_PRINT(str, ...) \ | ||
if (netlist::Config::getInstance().debugEnabled) { \ | ||
DebugMessage(__FILE__, __LINE__, str __VA_OPT__(, ) __VA_ARGS__); \ | ||
} | ||
#else | ||
# define DEBUG_PRINT(x) | ||
# define DEBUG_PRINT(str, ...) | ||
#endif | ||
|
||
#define INFO_PRINT(str, ...) \ | ||
if (!Config::getInstance().quietEnabled) { \ | ||
InfoMessage(str __VA_OPT__(, ) __VA_ARGS__); \ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.