36 return "[" + (args.color) + args.module_name + shambase::term_colors::reset() +
"] "
37 + (args.color) + (args.level_name) + shambase::term_colors::reset() +
": "
48 return "[" + (args.color) + args.module_name + shambase::term_colors::reset() +
"] "
49 + (args.color) + (args.level_name) + shambase::term_colors::reset() +
": "
60 return shambase::format(
61 "{5:}rank={6:<4}{2:} {5:}({3:^20}){2:} {0:}{1:}{2:}: {4:}",
64 shambase::term_colors::reset(),
67 shambase::term_colors::faint(),
78 return shambase::format(
79 "{5:}({3:}){2:} : {4:}",
82 shambase::term_colors::reset(),
85 shambase::term_colors::faint());
96 return shambase::format(
97 "{0:}{1:}{2:}: {4:}{5:} | ({3:}) rank={6:<4}{2:}",
100 shambase::term_colors::reset(),
103 shambase::term_colors::faint(),
114 return shambase::format(
115 "{5:}({3:}){2:} : {4:}",
118 shambase::term_colors::reset(),
121 shambase::term_colors::faint());
134 std::string ansi_reset = shambase::term_colors::reset();
135 std::string ansi_faint = shambase::term_colors::faint();
137 std::string lineend = shambase::format(
138 "{5:} [{3:}][rank={6:}]{2:}",
147 std::string log = shambase::format(
148 "{0:}{1:}{2:}: {4:}",
157 std::string log_line1, log_line2;
158 size_t first_nl = log.find_first_of(
'\n');
159 if (first_nl != std::string::npos) {
160 log_line1 = log.substr(0, first_nl);
161 log_line2 = log.substr(first_nl);
167 u32 ansi_count = ansi_reset.size() * 2 + ansi_faint.size() + args.color.size();
169 return shambase::format(
"{:<{}}", log_line1, tty_width - lineend.size() + ansi_count - 1)
170 + lineend + log_line2;
180 return shambase::format(
181 "{5:}{3:}{2:}: {4:}",
184 shambase::term_colors::reset(),
187 shambase::term_colors::bold());
200 std::string ansi_reset = shambase::term_colors::reset();
201 std::string ansi_faint = shambase::term_colors::faint();
203 std::string lineend = shambase::format(
204 "{5:} [{3:}][rank={6:}][{7:.2f}s]{2:}",
212 shambase::details::get_wtime());
214 std::string log = shambase::format(
215 "{0:}{1:}{2:}: {4:}",
224 std::string log_line1, log_line2;
225 size_t first_nl = log.find_first_of(
'\n');
226 if (first_nl != std::string::npos) {
227 log_line1 = log.substr(0, first_nl);
228 log_line2 = log.substr(first_nl);
234 u32 ansi_count = ansi_reset.size() * 2 + ansi_faint.size() + args.color.size();
236 return shambase::format(
"{:<{}}", log_line1, tty_width - lineend.size() + ansi_count - 1)
237 + lineend + log_line2;
247 return shambase::format(
248 "{5:}{3:}{2:}: {4:}",
251 shambase::term_colors::reset(),
254 shambase::term_colors::bold());
266 shamcomm::logs::err_ln(
"Exception",
"Exception created :\n" + msg);
272 "SHAMLOGFORMATTER",
"3",
"Change the log formatter (values :0-4) [default: 3]");
275 "SHAMLOG_ERR_ON_EXCEPT",
"1",
"Enable logging of exceptions (default to 1)");
281 shamlog_debug_ln(
"Sys",
"changing formatter to MPI form");
283 if (SHAMLOGFORMATTER ==
"0") {
286 }
else if (SHAMLOGFORMATTER ==
"1") {
289 }
else if (SHAMLOGFORMATTER ==
"2") {
292 }
else if (SHAMLOGFORMATTER ==
"3") {
295 }
else if (SHAMLOGFORMATTER ==
"4") {
299 logger::err_ln(
"Log",
"Unknown formatter");
303 if (SHAMLOG_ERR_ON_EXCEPT ==
"1") {
304 shamlog_debug_ln(
"Log",
"Enabling exception handler callback");
std::uint32_t u32
32 bit unsigned integer
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,...
u32 get_tty_columns()
Get the number of columns of the current terminal.
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...
This file contains the definition for the stacktrace related functionality.
This file contains tty info getters.
Functions related to the MPI communicator.