TRIQS/triqs_ctseg 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
logs.hpp
1// Copyright (c) 2022--present, The Simons Foundation
2// Copyright (c) 2022--present, Max Planck Institute for Polymer Research, Mainz, Germany
3// This file is part of TRIQS/ctseg and is licensed under the terms of GPLv3 or later.
4// SPDX-License-Identifier: GPL-3.0-or-later
5// See LICENSE in the root of this distribution for details.
6
7#pragma once
8
9// Set log levels
10#ifdef CTSEG_DEBUG
11#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
12static constexpr bool ctseg_debug = true;
13#else
14#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
15static constexpr bool ctseg_debug = false;
16#endif
17#ifdef PRINT_LOGS
18static constexpr bool print_logs = true;
19#else
20static constexpr bool print_logs = false;
21#endif
22
23#include <fmt/format.h>
24#include <fmt/ostream.h>
25#include <spdlog/spdlog.h>
26
27// Log messages for dubugging
28#define LOG(...) SPDLOG_DEBUG(__VA_ARGS__)
29
30// Checked always, even in production
31#define ALWAYS_EXPECTS(Condition, ...) \
32 if (not(Condition)) { \
33 SPDLOG_CRITICAL("Error in function {} in file {} at line {}", __FUNCTION__, __FILE__, __LINE__); \
34 SPDLOG_CRITICAL(__VA_ARGS__); \
35 throw std::runtime_error("Assertion Error, cf log"); \
36 }