Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Namespaces | Macros | Functions | Variables
logs.hpp File Reference
#include "shambase/aliases_int.hpp"
#include "shambase/logs.hpp"
#include "shambase/print.hpp"
#include "shambase/string.hpp"
#include "shambase/term_colors.hpp"
#include <string>
+ Include dependency graph for logs.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  shamcomm
 namespace for communication related stuff
 
namespace  logger
 alias namespace to simplify the use of log functions
 

Macros

#define LIST_LEVEL
 X-macro for log level definition.
 
#define DECLARE_LOG_LEVEL(_name, StructREF)
 Macro defining the log levels that will be expanded by an X-macro.
 
#define X   DECLARE_LOG_LEVEL
 Temp definition for the X macro call to define the log levels.
 

Functions

template<typename... Types>
void shamcomm::logs::raw (Types... var2)
 Prints a log message with multiple arguments without newline.
 
template<typename... Types>
void shamcomm::logs::raw_ln (Types... var2)
 Prints a log message with multiple arguments followed by a newline.
 
void shamcomm::logs::print_faint_row ()
 Prints a faint separator line to the log.
 
template<typename... Types>
void shamcomm::logs::debug_alloc (std::string module_name, Types... var2)
 Prints a log message with multiple arguments.
 
template<typename... Types>
void shamcomm::logs::debug_alloc_ln (std::string module_name, Types... var2)
 Prints a log message with multiple arguments followed by a newline.
 
template<typename... Types>
void shamcomm::logs::debug_mpi (std::string module_name, Types... var2)
 Prints a log message with multiple arguments.
 
template<typename... Types>
void shamcomm::logs::debug_mpi_ln (std::string module_name, Types... var2)
 Prints a log message with multiple arguments followed by a newline.
 
template<typename... Types>
void shamcomm::logs::debug_sycl (std::string module_name, Types... var2)
 Prints a log message with multiple arguments.
 
template<typename... Types>
void shamcomm::logs::debug_sycl_ln (std::string module_name, Types... var2)
 Prints a log message with multiple arguments followed by a newline.
 
template<typename... Types>
void shamcomm::logs::debug (std::string module_name, Types... var2)
 Prints a log message with multiple arguments.
 
template<typename... Types>
void shamcomm::logs::debug_ln (std::string module_name, Types... var2)
 Prints a log message with multiple arguments followed by a newline.
 
template<typename... Types>
void shamcomm::logs::info (std::string module_name, Types... var2)
 Prints a log message with multiple arguments.
 
template<typename... Types>
void shamcomm::logs::info_ln (std::string module_name, Types... var2)
 Prints a log message with multiple arguments followed by a newline.
 
template<typename... Types>
void shamcomm::logs::normal (std::string module_name, Types... var2)
 Prints a log message with multiple arguments.
 
template<typename... Types>
void shamcomm::logs::normal_ln (std::string module_name, Types... var2)
 Prints a log message with multiple arguments followed by a newline.
 
template<typename... Types>
void shamcomm::logs::warn (std::string module_name, Types... var2)
 Prints a log message with multiple arguments.
 
template<typename... Types>
void shamcomm::logs::warn_ln (std::string module_name, Types... var2)
 Prints a log message with multiple arguments followed by a newline.
 
template<typename... Types>
void shamcomm::logs::err (std::string module_name, Types... var2)
 Prints a log message with multiple arguments.
 
template<typename... Types>
void shamcomm::logs::err_ln (std::string module_name, Types... var2)
 Prints a log message with multiple arguments followed by a newline.
 
void shamcomm::logs::print_active_level ()
 Prints the active log levels.
 
void shamcomm::logs::code_init_done_log ()
 Indicates that the code initialization is complete through various means ;)
 

Variables

constexpr i8 shamcomm::logs::log_debug_alloc = ( LogLevel_DebugAlloc ::logval)
 the log level value associated with debug_alloc
 
constexpr i8 shamcomm::logs::log_debug_mpi = ( LogLevel_DebugMPI ::logval)
 the log level value associated with debug_mpi
 
constexpr i8 shamcomm::logs::log_debug_sycl = ( LogLevel_DebugSYCL ::logval)
 the log level value associated with debug_sycl
 
constexpr i8 shamcomm::logs::log_debug = ( LogLevel_Debug ::logval)
 the log level value associated with debug
 
constexpr i8 shamcomm::logs::log_info = ( LogLevel_Info ::logval)
 the log level value associated with info
 
constexpr i8 shamcomm::logs::log_normal = ( LogLevel_Normal ::logval)
 the log level value associated with normal
 
constexpr i8 shamcomm::logs::log_warn = ( LogLevel_Warning ::logval)
 the log level value associated with warn
 
constexpr i8 shamcomm::logs::log_err = ( LogLevel_Error ::logval)
 the log level value associated with err
 

Detailed Description

Author
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)

Definition in file logs.hpp.

Macro Definition Documentation

◆ DECLARE_LOG_LEVEL

#define DECLARE_LOG_LEVEL (   _name,
  StructREF 
)
Value:
\
constexpr i8 log_##_name = (StructREF::logval); \
\
template<typename... Types> \
inline void _name(std::string module_name, Types... var2) { \
if (details::loglevel >= log_##_name) { \
shamcomm::logs::print( \
StructREF::reformat(shamcomm::logs::format_message(var2...), module_name)); \
} \
} \
\
template<typename... Types> \
inline void _name##_ln(std::string module_name, Types... var2) { \
if (details::loglevel >= log_##_name) { \
shamcomm::logs::print_ln( \
StructREF::reformat(shamcomm::logs::format_message(var2...), module_name)); \
} \
}
std::int8_t i8
8 bit integer
std::string format_message()
Formats an empty log message.
Definition msgformat.hpp:37

Macro defining the log levels that will be expanded by an X-macro.

Definition at line 111 of file logs.hpp.

◆ LIST_LEVEL

#define LIST_LEVEL
Value:
X(debug_alloc, LogLevel_DebugAlloc) \
X(debug_mpi, LogLevel_DebugMPI) \
X(debug_sycl, LogLevel_DebugSYCL) \
X(debug, LogLevel_Debug) \
X(info, LogLevel_Info) \
X(normal, LogLevel_Normal) \
X(warn, LogLevel_Warning) \
#define X
Temp definition for the X macro call to define the log levels.
Definition logs.hpp:132
Log level struct for debugging memory allocation.
Definition loglevels.hpp:27
Log level struct for debugging MPI operations.
Definition loglevels.hpp:65
Log level struct for debugging SYCL operations.
Log level struct for debugging general operations.
Log level struct for error messages.
Log level struct for informational messages.
Log level struct for normal messages.
Log level struct for warning messages.

X-macro for log level definition.

This X-macro is used to define the log levels available in the library. It is used to generate the log level structs and the corresponding log formatter functions.

The X-macro takes the following form:

X(name, LogLevel_Name)

Where:

  • name is the name of the log level
  • LogLevel_Name is the name of the struct containing the log level information

Definition at line 43 of file logs.hpp.

◆ X

#define X   DECLARE_LOG_LEVEL

Temp definition for the X macro call to define the log levels.

Definition at line 132 of file logs.hpp.

Function Documentation

◆ code_init_done_log()

void shamcomm::logs::code_init_done_log ( )

Indicates that the code initialization is complete through various means ;)

Definition at line 57 of file logs.cpp.

+ Here is the call graph for this function:

◆ debug()

template<typename... Types>
shamcomm::logs::debug ( std::string  module_name,
Types...  var2 
)
inline

Prints a log message with multiple arguments.

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

+ Here is the call graph for this function:

◆ debug_alloc()

template<typename... Types>
shamcomm::logs::debug_alloc ( std::string  module_name,
Types...  var2 
)
inline

Prints a log message with multiple arguments.

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ debug_alloc_ln()

template<typename... Types>
shamcomm::logs::debug_alloc_ln ( std::string  module_name,
Types...  var2 
)
inline

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

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ debug_ln()

template<typename... Types>
shamcomm::logs::debug_ln ( std::string  module_name,
Types...  var2 
)
inline

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

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ debug_mpi()

template<typename... Types>
shamcomm::logs::debug_mpi ( std::string  module_name,
Types...  var2 
)
inline

Prints a log message with multiple arguments.

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ debug_mpi_ln()

template<typename... Types>
shamcomm::logs::debug_mpi_ln ( std::string  module_name,
Types...  var2 
)
inline

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

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ debug_sycl()

template<typename... Types>
shamcomm::logs::debug_sycl ( std::string  module_name,
Types...  var2 
)
inline

Prints a log message with multiple arguments.

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ debug_sycl_ln()

template<typename... Types>
shamcomm::logs::debug_sycl_ln ( std::string  module_name,
Types...  var2 
)
inline

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

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ err()

template<typename... Types>
shamcomm::logs::err ( std::string  module_name,
Types...  var2 
)
inline

Prints a log message with multiple arguments.

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ err_ln()

template<typename... Types>
shamcomm::logs::err_ln ( std::string  module_name,
Types...  var2 
)
inline

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

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ info()

template<typename... Types>
shamcomm::logs::info ( std::string  module_name,
Types...  var2 
)
inline

Prints a log message with multiple arguments.

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ info_ln()

template<typename... Types>
shamcomm::logs::info_ln ( std::string  module_name,
Types...  var2 
)
inline

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

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ normal()

template<typename... Types>
shamcomm::logs::normal ( std::string  module_name,
Types...  var2 
)
inline

Prints a log message with multiple arguments.

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ normal_ln()

template<typename... Types>
shamcomm::logs::normal_ln ( std::string  module_name,
Types...  var2 
)
inline

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

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ print_active_level()

void shamcomm::logs::print_active_level ( )

Prints the active log levels.

Temp definition for the X macro call in print_active_level()

Temp definition for the X macro call in print_active_level()

Definition at line 33 of file logs.cpp.

+ Here is the call graph for this function:

◆ print_faint_row()

void shamcomm::logs::print_faint_row ( )
inline

Prints a faint separator line to the log.

This is a convenience function to print a separator line to the log. It prints a line of 50 dashes using the shambase::term_colors::faint color.

Definition at line 100 of file logs.hpp.

+ Here is the call graph for this function:

◆ raw()

template<typename... Types>
void shamcomm::logs::raw ( Types...  var2)
inline

Prints a log message with multiple arguments without newline.

This 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
TypesThe types of the arguments to be printed
Parameters
var2The arguments to be printed

Definition at line 73 of file logs.hpp.

+ Here is the call graph for this function:

◆ raw_ln()

template<typename... Types>
void shamcomm::logs::raw_ln ( Types...  var2)
inline

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

This 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, followed by a newline.

Template Parameters
TypesThe types of the arguments to be printed
Parameters
var2The arguments to be printed

Definition at line 90 of file logs.hpp.

+ Here is the call graph for this function:

◆ warn()

template<typename... Types>
shamcomm::logs::warn ( std::string  module_name,
Types...  var2 
)
inline

Prints a log message with multiple arguments.

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

◆ warn_ln()

template<typename... Types>
shamcomm::logs::warn_ln ( std::string  module_name,
Types...  var2 
)
inline

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

Parameters
module_nameThe name of the module
var2The arguments to be printed

Definition at line 133 of file logs.hpp.

Variable Documentation

◆ log_debug

shamcomm::logs::log_debug = ( LogLevel_Debug ::logval)
constexpr

the log level value associated with debug

Definition at line 133 of file logs.hpp.

◆ log_debug_alloc

shamcomm::logs::log_debug_alloc = ( LogLevel_DebugAlloc ::logval)
constexpr

the log level value associated with debug_alloc

Definition at line 133 of file logs.hpp.

◆ log_debug_mpi

shamcomm::logs::log_debug_mpi = ( LogLevel_DebugMPI ::logval)
constexpr

the log level value associated with debug_mpi

Definition at line 133 of file logs.hpp.

◆ log_debug_sycl

shamcomm::logs::log_debug_sycl = ( LogLevel_DebugSYCL ::logval)
constexpr

the log level value associated with debug_sycl

Definition at line 133 of file logs.hpp.

◆ log_err

shamcomm::logs::log_err = ( LogLevel_Error ::logval)
constexpr

the log level value associated with err

Definition at line 133 of file logs.hpp.

◆ log_info

shamcomm::logs::log_info = ( LogLevel_Info ::logval)
constexpr

the log level value associated with info

Definition at line 133 of file logs.hpp.

◆ log_normal

shamcomm::logs::log_normal = ( LogLevel_Normal ::logval)
constexpr

the log level value associated with normal

Definition at line 133 of file logs.hpp.

◆ log_warn

shamcomm::logs::log_warn = ( LogLevel_Warning ::logval)
constexpr

the log level value associated with warn

Definition at line 133 of file logs.hpp.