62 "{5:}rank={6:<4}{2:} {5:}({3:^20}){2:} {0:}{1:}{2:}: {4:}",
80 "{5:}({3:}){2:} : {4:}",
98 "{0:}{1:}{2:}: {4:}{5:} | ({3:}) rank={6:<4}{2:}",
116 "{5:}({3:}){2:} : {4:}",
138 std::string lineend = sham::format(
139 "{5:} [{3:}][rank={6:}]{2:}",
148 std::string log = sham::format(
149 "{0:}{1:}{2:}: {4:}",
158 std::string log_line1, log_line2;
159 size_t first_nl = log.find_first_of(
'\n');
160 if (first_nl != std::string::npos) {
161 log_line1 = log.substr(0, first_nl);
162 log_line2 = log.substr(first_nl);
168 u32 ansi_count = ansi_reset.size() * 2 + ansi_faint.size() + args.color.size();
170 return sham::format(
"{:<{}}", log_line1, tty_width - lineend.size() + ansi_count - 1)
171 + lineend + log_line2;
182 "{5:}{3:}{2:}: {4:}",
204 std::string lineend = sham::format(
205 "{5:} [{3:}][rank={6:}][{7:.2f}s]{2:}",
215 std::string log = sham::format(
216 "{0:}{1:}{2:}: {4:}",
225 std::string log_line1, log_line2;
226 size_t first_nl = log.find_first_of(
'\n');
227 if (first_nl != std::string::npos) {
228 log_line1 = log.substr(0, first_nl);
229 log_line2 = log.substr(first_nl);
235 u32 ansi_count = ansi_reset.size() * 2 + ansi_faint.size() + args.color.size();
237 return sham::format(
"{:<{}}", log_line1, tty_width - lineend.size() + ansi_count - 1)
238 + lineend + log_line2;
249 "{5:}{3:}{2:}: {4:}",
273 "SHAMLOGFORMATTER",
"3",
"Change the log formatter (values :0-4) [default: 3]");
276 "SHAMLOG_ERR_ON_EXCEPT",
"1",
"Enable logging of exceptions (default to 1)");
282 shamlog_debug_ln(
"Sys",
"changing formatter to MPI form");
284 if (SHAMLOGFORMATTER ==
"0") {
287 }
else if (SHAMLOGFORMATTER ==
"1") {
290 }
else if (SHAMLOGFORMATTER ==
"2") {
293 }
else if (SHAMLOGFORMATTER ==
"3") {
296 }
else if (SHAMLOGFORMATTER ==
"4") {
304 if (SHAMLOG_ERR_ON_EXCEPT ==
"1") {
305 shamlog_debug_ln(
"Log",
"Enabling exception handler callback");
std::uint32_t u32
32 bit unsigned integer
This header file contains utility functions related to exception handling in the code.
void change_formaters(reformat_func_ptr full, reformat_func_ptr simple)
Changes the log formatter functions.
void set_exception_gen_callback(exception_gen_callback_t callback)
Set the exception generator callback.
void throw_unimplemented(SourceLocation loc=SourceLocation{})
Throw a std::runtime_error saying that the function is unimplemented.
std::string getenv_str_default_register(const char *env_var, std::string default_val, std::string desc)
Get the content of the environment variable if it exist and register it documentation,...
i32 world_rank()
Gives the rank of the current process in the MPI communicator.
namespace for the system handling
void change_log_format()
Change the log formatter according to the SHAMLOGFORMATTER and SHAMLOG_ERR_ON_EXCEPT environment vari...
void err_ln(std::string module_name, Types... var2)
Prints a log message with multiple arguments followed by a newline.
This file contains the definition for the stacktrace related functionality.
f64 get_wtime()
Returns the current wall clock time in seconds.
const std::string reset()
Get the reset terminal escape char.
const std::string faint()
Get the faint terminal escape char.
const std::string bold()
Get the bold terminal escape char.
This file contains tty info getters.
int get_tty_columns()
Get the number of columns of the current terminal.
Functions related to the MPI communicator.