Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
reformat_message.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
19#include <string>
20namespace shambase::logs {
21
29 struct ReformatArgs {
36 std::string color;
37
44 const char *level_name;
45
52 std::string module_name;
53
60 std::string content;
61 };
62
71 using reformat_func_ptr = std::string (*)(const ReformatArgs &args);
72
85
94 std::string reformat_all(
95 const std::string &color,
96 const char *name,
97 const std::string &module_name,
98 const std::string &content);
99
108 std::string reformat_simple(
109 const std::string &color,
110 const char *name,
111 const std::string &module_name,
112 const std::string &content);
113
114} // namespace shambase::logs
Namespace containing logs utils.
Definition loglevel.hpp:24
void change_formaters(reformat_func_ptr full, reformat_func_ptr simple)
Changes the log formatter functions.
std::string reformat_all(const std::string &color, const char *name, const std::string &module_name, const std::string &content)
Format a log message with all the information.
std::string(*)(const ReformatArgs &args) reformat_func_ptr
A pointer to a log formatter function.
std::string reformat_simple(const std::string &color, const char *name, const std::string &module_name, const std::string &content)
Format a log message with the minimum information.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
A structure containing the arguments to a log formatter.
const char * level_name
The name of the log level.
std::string module_name
The name of the module from which the log is emitter.
std::string color
The color of the log message.
std::string content
The log message.