Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables
shambase::logs Namespace Reference

Namespace containing logs utils. More...

Classes

struct  ReformatArgs
 A structure containing the arguments to a log formatter. More...
 

Typedefs

using reformat_func_ptr = std::string(*)(const ReformatArgs &args)
 A pointer to a log formatter function.
 

Functions

void set_loglevel (i8 val)
 Set the global log level.
 
i8 get_loglevel ()
 Get the current global log level.
 
std::string format_message ()
 Formats an empty log message.
 
template<typename T , typename... Types>
std::string format_message (T var1, Types... var2)
 Formats a log message with multiple arguments.
 
template<typename... Types>
std::string format_message (std::string s, Types... var2)
 
void print ()
 Prints a log message with no arguments.
 
template<typename T , typename... Types>
void print (T var1, Types... var2)
 Prints a log message with multiple arguments.
 
void print_ln ()
 Prints a log message with multiple arguments followed by a newline.
 
template<typename T , typename... Types>
void print_ln (T var1, Types... var2)
 Prints a log message with multiple arguments followed by a newline.
 
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 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.
 

Variables

reformat_func_ptr _reformat_all = nullptr
 Pointer to the full formatter function.
 
reformat_func_ptr _reformat_simple = nullptr
 Pointer to the simple formatter function.
 

Detailed Description

Namespace containing logs utils.

Typedef Documentation

◆ reformat_func_ptr

A pointer to a log formatter function.

This is a pointer to a function that takes a ReformatArgs structure and returns a string containing the formatted log message. It is used to pass a log formatter function to the change_formaters function.

Definition at line 71 of file reformat_message.hpp.

Function Documentation

◆ change_formaters()

void shambase::logs::change_formaters ( reformat_func_ptr  full,
reformat_func_ptr  simple 
)

Changes the log formatter functions.

This function is used to change the log formatter functions used by the shamcomm::logs module. It takes two reformat_func_ptr arguments: the first is the full formatter function, and the second is the simple formatter function.

Parameters
fullThe full formatter function
simpleThe simple formatter function

Definition at line 38 of file reformat_message.cpp.

+ Here is the call graph for this function:

◆ format_message() [1/3]

std::string shambase::logs::format_message ( )
inline

Formats an empty log message.

This function is used to format log messages when there are no additional arguments to be passed.

Returns
An empty string

Definition at line 37 of file msgformat.hpp.

◆ format_message() [2/3]

template<typename... Types>
std::string shambase::logs::format_message ( std::string  s,
Types...  var2 
)
inline

Formats a log message by concatenating a string with additional arguments.

Parameters
sThe initial string to be formatted
var2Additional arguments to be formatted and appended to the string
Returns
The formatted log message

Definition at line 60 of file msgformat.hpp.

+ Here is the call graph for this function:

◆ format_message() [3/3]

template<typename T , typename... Types>
std::string shambase::logs::format_message ( var1,
Types...  var2 
)
inline

Formats a log message with multiple arguments.

Formats a log message with multiple arguments.

Parameters
var1The first argument to be formatted in the log message.
var2The remaining arguments to be formatted in the log message.
Returns
The formatted log message.

This function is a variadic template that recursively formats a log message by concatenating the string representation of each argument passed to it.

Template Parameters
TThe type of the first argument
TypesThe types of the remaining arguments
Returns
The formatted log message.

Definition at line 77 of file msgformat.hpp.

+ Here is the call graph for this function:

◆ get_loglevel()

i8 shambase::logs::get_loglevel ( )
inline

Get the current global log level.

Returns
The current log level

Definition at line 52 of file loglevel.hpp.

◆ print() [1/2]

void shambase::logs::print ( )
inline

Prints a log message with no arguments.

This function is a specialization of the variadic template print that does nothing. It is used to terminate the recursion when there are no more arguments to format.

Definition at line 37 of file printer_base.hpp.

◆ print() [2/2]

template<typename T , typename... Types>
void shambase::logs::print ( var1,
Types...  var2 
)

Prints a log message with multiple arguments.

This function is a variadic template that recursively prints a log message by formatting each argument and concatenating them. It uses the shambase::print function to output the formatted message.

Template Parameters
TThe type of the first argument
TypesThe types of the remaining arguments
Parameters
var1The first argument to be printed in the log message.
var2The remaining arguments to be printed in the log message.

Definition at line 53 of file printer_base.hpp.

+ Here is the call graph for this function:

◆ print_ln() [1/2]

void shambase::logs::print_ln ( )
inline

Prints a log message with multiple arguments followed by a newline.

This function is a specialization of the variadic template print_ln that does nothing. It is used to terminate the recursion when there are no more arguments to format.

Definition at line 64 of file printer_base.hpp.

◆ print_ln() [2/2]

template<typename T , typename... Types>
void shambase::logs::print_ln ( var1,
Types...  var2 
)

Prints a log message with multiple arguments followed by a newline.

This function is a variadic template that recursively prints a log message by formatting each argument and concatenating them. It uses the shambase::println function to output the formatted message, followed by a newline.

Template Parameters
TThe type of the first argument
TypesThe types of the remaining arguments
Parameters
var1The first argument to be printed in the log message.
var2The remaining arguments to be printed in the log message.

Definition at line 81 of file printer_base.hpp.

+ Here is the call graph for this function:

◆ reformat_all()

std::string shambase::logs::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.

Parameters
colorThe color of the log message
nameThe name of the logger
module_nameThe name of the module
contentThe content of the log message
Returns
A formatted log message

Definition at line 51 of file reformat_message.cpp.

◆ reformat_simple()

std::string shambase::logs::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.

Parameters
colorThe color of the log message
nameThe name of the logger
module_nameThe name of the module
contentThe content of the log message
Returns
A formatted log message

Definition at line 73 of file reformat_message.cpp.

◆ set_loglevel()

void shambase::logs::set_loglevel ( i8  val)
inline

Set the global log level.

Parameters
valThe new log level

Definition at line 45 of file loglevel.hpp.

Variable Documentation

◆ _reformat_all

reformat_func_ptr shambase::logs::_reformat_all = nullptr

Pointer to the full formatter function.

If this pointer is equal to nullptr, the default full formatter function will be used.

Definition at line 28 of file reformat_message.cpp.

◆ _reformat_simple

reformat_func_ptr shambase::logs::_reformat_simple = nullptr

Pointer to the simple formatter function.

If this pointer is equal to nullptr, the default simple formatter function will be used.

Definition at line 36 of file reformat_message.cpp.