| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #pragma once |
| 4 | |
| 5 | #include <iostream> |
| 6 | |
| 7 | class DebugLogger |
| 8 | { |
| 9 | static constexpr auto INIT_DEBUG = false; |
| 10 | |
| 11 | public: |
| 12 | template<typename TArg> |
| 13 | const DebugLogger &operator<<(TArg arg) const |
| 14 | { |
| 15 | if (INIT_DEBUG) |
| 16 | std::cout << arg; |
| 17 | return *this; |
| 18 | } |
| 19 | |
| 20 | using ostream_manipulator = std::ostream &(*) (std::ostream &); |
| 21 | |
| 22 | const DebugLogger &operator<<(ostream_manipulator manip) const |
| 23 | { |
| 24 | if (INIT_DEBUG) |
| 25 | manip(std::cout); |
| 26 | return *this; |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | inline const DebugLogger Debug; |
| 31 | |