ContextSV v1.0.0
Loading...
Searching...
No Matches
debug.h
Go to the documentation of this file.
1// debug.h
2#pragma once
3
4#include <iostream>
5#include <mutex>
6#include <chrono>
7#include <iomanip>
8#include <sstream>
9
10extern std::mutex debug_mutex;
11
12#ifdef DEBUG
13 #define DEBUG_PRINT(x) do { \
14 std::lock_guard<std::mutex> lock(debug_mutex); \
15 auto now = std::chrono::system_clock::now(); \
16 std::time_t now_time = std::chrono::system_clock::to_time_t(now); \
17 std::ostringstream oss; \
18 oss << std::put_time(std::localtime(&now_time), "%Y-%m-%d %H:%M:%S"); \
19 std::cerr << oss.str() << " - " << x << std::endl; \
20 } while (0)
21#else
22 #define DEBUG_PRINT(x)
23#endif
std::mutex debug_mutex
Definition debug.cpp:4