Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
reformat_message.cpp
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
16
19
20namespace shambase::logs {
21
29
37
39 _reformat_simple = simple;
40 _reformat_all = full;
41 }
42
51 std::string reformat_all(
52 const std::string &color,
53 const char *name,
54 const std::string &module_name,
55 const std::string &content) {
56 if (shambase::logs::_reformat_all == nullptr) {
57 // old form
58 return "[" + (color) + module_name + shambase::term_colors::reset() + "] " + (color)
59 + (name) + shambase::term_colors::reset() + ": " + content;
60 }
61
63 {.color = color, .level_name = name, .module_name = module_name, .content = content});
64 }
65
74 std::string reformat_simple(
75 const std::string &color,
76 const char *name,
77 const std::string &module_name,
78 const std::string &content) {
79
80 if (shambase::logs::_reformat_simple == nullptr) {
81 // old form
82 return "[" + (color) + module_name + shambase::term_colors::reset() + "] " + (color)
83 + (name) + shambase::term_colors::reset() + ": " + content;
84 }
85
87 {.color = color, .level_name = name, .module_name = module_name, .content = content});
88 }
89} // 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.
reformat_func_ptr _reformat_all
Pointer to the full formatter function.
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.
reformat_func_ptr _reformat_simple
Pointer to the simple 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.
const std::string reset()
Get the reset terminal escape char.