Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
loglevels.hpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
10#pragma once
11
20#include <string>
21
28 constexpr static i8 logval = 127;
29 constexpr static const char *level_name = "Debug Alloc";
30
40 static std::string reformat(const std::string &in, std::string module_name);
41};
42
43#define shamlog_debug_alloc(module_name, ...) \
44 if (shambase::logs::details::loglevel >= LogLevel_DebugAlloc::logval) { \
45 shambase::logs::print( \
46 LogLevel_DebugAlloc::reformat( \
47 shambase::logs::format_message(__VA_ARGS__), module_name)); \
48 }
49
50#define shamlog_debug_alloc_ln(module_name, ...) \
51 if (shambase::logs::details::loglevel >= LogLevel_DebugAlloc::logval) { \
52 shambase::logs::print_ln( \
53 LogLevel_DebugAlloc::reformat( \
54 shambase::logs::format_message(__VA_ARGS__), module_name)); \
55 }
56
57#define when_shamlog_debug_alloc \
58 if (shambase::logs::details::loglevel >= LogLevel_DebugAlloc::logval)
59
66 constexpr static i8 logval = 100;
67 constexpr static const char *level_name = "Debug MPI";
68
78 static std::string reformat(const std::string &in, std::string module_name);
79};
80
81#define shamlog_debug_mpi(module_name, ...) \
82 if (shambase::logs::details::loglevel >= LogLevel_DebugMPI::logval) { \
83 shambase::logs::print( \
84 LogLevel_DebugMPI::reformat( \
85 shambase::logs::format_message(__VA_ARGS__), module_name)); \
86 }
87
88#define shamlog_debug_mpi_ln(module_name, ...) \
89 if (shambase::logs::details::loglevel >= LogLevel_DebugMPI::logval) { \
90 shambase::logs::print_ln( \
91 LogLevel_DebugMPI::reformat( \
92 shambase::logs::format_message(__VA_ARGS__), module_name)); \
93 }
94
95#define when_shamlog_debug_mpi if (shambase::logs::details::loglevel >= LogLevel_DebugMPI::logval)
96
103 constexpr static i8 logval = 11;
104 constexpr static const char *level_name = "Debug SYCL";
105
115 static std::string reformat(const std::string &in, std::string module_name);
116};
117
118#define shamlog_debug_sycl(module_name, ...) \
119 if (shambase::logs::details::loglevel >= LogLevel_DebugSYCL::logval) { \
120 shambase::logs::print( \
121 LogLevel_DebugSYCL::reformat( \
122 shambase::logs::format_message(__VA_ARGS__), module_name)); \
123 }
124
125#define shamlog_debug_sycl_ln(module_name, ...) \
126 if (shambase::logs::details::loglevel >= LogLevel_DebugSYCL::logval) { \
127 shambase::logs::print_ln( \
128 LogLevel_DebugSYCL::reformat( \
129 shambase::logs::format_message(__VA_ARGS__), module_name)); \
130 }
131
132#define when_shamlog_debug_sycl if (shambase::logs::details::loglevel >= LogLevel_DebugSYCL::logval)
133
140 constexpr static i8 logval = 10;
141 constexpr static const char *level_name = "Debug";
142
152 static std::string reformat(const std::string &in, std::string module_name);
153};
154
155#define shamlog_debug(module_name, ...) \
156 if (shambase::logs::details::loglevel >= LogLevel_Debug::logval) { \
157 shambase::logs::print( \
158 LogLevel_Debug::reformat(shambase::logs::format_message(__VA_ARGS__), module_name)); \
159 }
160
161#define shamlog_debug_ln(module_name, ...) \
162 if (shambase::logs::details::loglevel >= LogLevel_Debug::logval) { \
163 shambase::logs::print_ln( \
164 LogLevel_Debug::reformat(shambase::logs::format_message(__VA_ARGS__), module_name)); \
165 }
166
167#define when_shamlog_debug if (shambase::logs::details::loglevel >= LogLevel_Debug::logval)
168
175 constexpr static i8 logval = 1;
176 constexpr static const char *level_name = "";
177
187 static std::string reformat(const std::string &in, std::string module_name);
188};
189
190#define shamlog_info(module_name, ...) \
191 if (shambase::logs::details::loglevel >= LogLevel_Info::logval) { \
192 shambase::logs::print( \
193 LogLevel_Info::reformat(shambase::logs::format_message(__VA_ARGS__), module_name)); \
194 }
195
196#define shamlog_info_ln(module_name, ...) \
197 if (shambase::logs::details::loglevel >= LogLevel_Info::logval) { \
198 shambase::logs::print_ln( \
199 LogLevel_Info::reformat(shambase::logs::format_message(__VA_ARGS__), module_name)); \
200 }
201
202#define when_shamlog_info if (shambase::logs::details::loglevel >= LogLevel_Info::logval)
203
210 constexpr static i8 logval = 0;
211 constexpr static const char *level_name = "";
212
222 static std::string reformat(const std::string &in, std::string module_name);
223};
224
225#define shamlog_normal(module_name, ...) \
226 if (shambase::logs::details::loglevel >= LogLevel_Normal::logval) { \
227 shambase::logs::print( \
228 LogLevel_Normal::reformat(shambase::logs::format_message(__VA_ARGS__), module_name)); \
229 }
230
231#define shamlog_normal_ln(module_name, ...) \
232 if (shambase::logs::details::loglevel >= LogLevel_Normal::logval) { \
233 shambase::logs::print_ln( \
234 LogLevel_Normal::reformat(shambase::logs::format_message(__VA_ARGS__), module_name)); \
235 }
236
237#define when_shamlog_normal if (shambase::logs::details::loglevel >= LogLevel_Normal::logval)
238
245 constexpr static i8 logval = -1;
246 constexpr static const char *level_name = "Warning";
247
257 static std::string reformat(const std::string &in, std::string module_name);
258};
259
260#define shamlog_warn(module_name, ...) \
261 if (shambase::logs::details::loglevel >= LogLevel_Warning::logval) { \
262 shambase::logs::print( \
263 LogLevel_Warning::reformat(shambase::logs::format_message(__VA_ARGS__), module_name)); \
264 }
265
266#define shamlog_warn_ln(module_name, ...) \
267 if (shambase::logs::details::loglevel >= LogLevel_Warning::logval) { \
268 shambase::logs::print_ln( \
269 LogLevel_Warning::reformat(shambase::logs::format_message(__VA_ARGS__), module_name)); \
270 }
271
272#define when_shamlog_warn if (shambase::logs::details::loglevel >= LogLevel_Warning::logval)
273
280 constexpr static i8 logval = -10;
281 constexpr static const char *level_name = "Error";
282
292 static std::string reformat(const std::string &in, std::string module_name);
293};
294
295#define shamlog_error(module_name, ...) \
296 if (shambase::logs::details::loglevel >= LogLevel_Error::logval) { \
297 shambase::logs::print( \
298 LogLevel_Error::reformat(shambase::logs::format_message(__VA_ARGS__), module_name)); \
299 }
300
301#define shamlog_error_ln(module_name, ...) \
302 if (shambase::logs::details::loglevel >= LogLevel_Error::logval) { \
303 shambase::logs::print_ln( \
304 LogLevel_Error::reformat(shambase::logs::format_message(__VA_ARGS__), module_name)); \
305 }
306
307#define when_shamlog_error if (shambase::logs::details::loglevel >= LogLevel_Error::logval)
std::int8_t i8
8 bit integer
Log level struct for debugging memory allocation.
Definition loglevels.hpp:27
static constexpr const char * level_name
Log level name.
Definition loglevels.hpp:29
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for debugging memory allocation.
Definition logs.cpp:109
static constexpr i8 logval
Log level value.
Definition loglevels.hpp:28
Log level struct for debugging MPI operations.
Definition loglevels.hpp:65
static constexpr i8 logval
Log level value.
Definition loglevels.hpp:66
static constexpr const char * level_name
Log level name.
Definition loglevels.hpp:67
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for debugging MPI operations.
Definition logs.cpp:113
Log level struct for debugging SYCL operations.
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for debugging SYCL operations.
Definition logs.cpp:117
static constexpr i8 logval
Log level value.
static constexpr const char * level_name
Log level name.
Log level struct for debugging general operations.
static constexpr i8 logval
Log level value.
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for debugging general operations.
Definition logs.cpp:122
static constexpr const char * level_name
Log level name.
Log level struct for error messages.
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for error messages.
Definition logs.cpp:138
static constexpr i8 logval
Log level value.
static constexpr const char * level_name
Log level name.
Log level struct for informational messages.
static constexpr i8 logval
Log level value.
static constexpr const char * level_name
Log level name.
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for informational messages.
Definition logs.cpp:126
Log level struct for normal messages.
static constexpr i8 logval
Log level value.
static constexpr const char * level_name
Log level name.
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for normal messages.
Definition logs.cpp:130
Log level struct for warning messages.
static constexpr i8 logval
Log level value.
static constexpr const char * level_name
Log level name.
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for warning messages.
Definition logs.cpp:134