numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
logging_macros.h File Reference

Definition of macros for logging. More...

#include <concepts>
#include <iterator>
#include <string_view>
#include <utility>
#include <fmt/base.h>
#include <fmt/format.h>
#include "num_collect/logging/log_level.h"
#include "num_collect/logging/logger.h"
#include "num_collect/util/source_info_view.h"
+ Include dependency graph for logging_macros.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  num_collect
 Namespace of num_collect source codes.
 
namespace  num_collect::logging
 Namespace of logging.
 
namespace  num_collect::logging::impl
 Namespace of internal implementations.
 

Macros

#define INTERNAL_NUM_COLLECT_LOG_IMPL(LOGGER, LEVEL, ...)
 Write a log.
 
#define NUM_COLLECT_LOG_AND_THROW(EXCEPTION_TYPE, ...)
 Write an error log and throw an exception for an error.
 
#define NUM_COLLECT_LOG_CRITICAL(LOGGER, ...)
 Write a critical log.
 
#define NUM_COLLECT_LOG_DEBUG(LOGGER, ...)
 Write a debug log.
 
#define NUM_COLLECT_LOG_ERROR(LOGGER, ...)
 Write an error log.
 
#define NUM_COLLECT_LOG_INFO(LOGGER, ...)
 Write an information log.
 
#define NUM_COLLECT_LOG_ITERATION(LOGGER, ...)
 Write a log of an iteration.
 
#define NUM_COLLECT_LOG_ITERATION_LABEL(LOGGER, ...)
 Write a log of a label of iterations.
 
#define NUM_COLLECT_LOG_SUMMARY(LOGGER, ...)
 Write a summary log.
 
#define NUM_COLLECT_LOG_TRACE(LOGGER, ...)
 Write a trace log.
 
#define NUM_COLLECT_LOG_WARNING(LOGGER, ...)
 Write a warning log.
 

Functions

template<std::constructible_from< std::string_view, util::source_info_view > Exception, typename... MessageArgs>
requires (sizeof...(MessageArgs) > 0)
void num_collect::logging::log_and_throw (util::source_info_view source, const logger &l, fmt::format_string< MessageArgs... > message_format, MessageArgs &&... message_args)
 Write an error log and throw an exception for an error.
 
template<std::constructible_from< std::string_view, util::source_info_view > Exception>
void num_collect::logging::log_and_throw (util::source_info_view source, const logger &l, std::string_view message)
 Write an error log and throw an exception for an error.
 
template<std::constructible_from< std::string_view, util::source_info_view > Exception, typename... MessageArgs>
requires (sizeof...(MessageArgs) > 0)
void num_collect::logging::log_and_throw (util::source_info_view source, fmt::format_string< MessageArgs... > message_format, MessageArgs &&... message_args)
 Write an error log and throw an exception for an error.
 
template<std::constructible_from< std::string_view, util::source_info_view > Exception>
void num_collect::logging::log_and_throw (util::source_info_view source, std::string_view message)
 Write an error log and throw an exception for an error.
 
template<typename... Args>
requires (sizeof...(Args) > 0)
void num_collect::logging::impl::log_without_condition_check (util::source_info_view source, const logger &l, log_level level, fmt::format_string< Args... > format, Args &&... args)
 Write a log without check of the condition to write logs.
 
void num_collect::logging::impl::log_without_condition_check (util::source_info_view source, const logger &l, log_level level, std::string_view body)
 Write a log without check of the condition to write logs.
 

Detailed Description

Definition of macros for logging.

Definition in file logging_macros.h.

Macro Definition Documentation

◆ INTERNAL_NUM_COLLECT_LOG_IMPL

#define INTERNAL_NUM_COLLECT_LOG_IMPL ( LOGGER,
LEVEL,
... )
Value:
/*NOLINT*/ \
do { \
if (LOGGER.should_log(LEVEL)) { \
::num_collect::logging::impl::log_without_condition_check( \
__VA_ARGS__); \
} \
} while (false)
Class to hold information of source codes.

Write a log.

Arguments:

  • LOGGER: Logger.
  • LEVEL: Log level.
  • Remaining arguments are either
    • the log body, or
    • the format string and its arguments of the log body.

Definition at line 163 of file logging_macros.h.

◆ NUM_COLLECT_LOG_AND_THROW

#define NUM_COLLECT_LOG_AND_THROW ( EXCEPTION_TYPE,
... )
Value:
/*NOLINT*/ \
::num_collect::logging::log_and_throw<EXCEPTION_TYPE>( \

Write an error log and throw an exception for an error.

This macro can be usable as following signature:

Here arguments are as follows:

  • EXCEPTION_TYPE: Type of the exception.
  • LOGGER: num_collect::logging::logger object to write the log.
  • MESSAGE_FORMAT: Format of the error message.
  • MESSAGE_ARGS...: Arguments for formatting of the error message.

Definition at line 333 of file logging_macros.h.

◆ NUM_COLLECT_LOG_CRITICAL

#define NUM_COLLECT_LOG_CRITICAL ( LOGGER,
... )
Value:
/*NOLINT*/ \
INTERNAL_NUM_COLLECT_LOG_IMPL( \

Write a critical log.

Arguments:

  • LOGGER: Logger.
  • Remaining arguments are either
    • the log body, or
    • the format string and its arguments of the log body.

For log levels, see num_collect::logging::log_level.

Definition at line 312 of file logging_macros.h.

◆ NUM_COLLECT_LOG_DEBUG

#define NUM_COLLECT_LOG_DEBUG ( LOGGER,
... )
Value:
/*NOLINT*/ \
INTERNAL_NUM_COLLECT_LOG_IMPL( \

Write a debug log.

Arguments:

  • LOGGER: Logger.
  • Remaining arguments are either
    • the log body, or
    • the format string and its arguments of the log body.

For log levels, see num_collect::logging::log_level.

Definition at line 200 of file logging_macros.h.

◆ NUM_COLLECT_LOG_ERROR

#define NUM_COLLECT_LOG_ERROR ( LOGGER,
... )
Value:
/*NOLINT*/ \
INTERNAL_NUM_COLLECT_LOG_IMPL( \

Write an error log.

Arguments:

  • LOGGER: Logger.
  • Remaining arguments are either
    • the log body, or
    • the format string and its arguments of the log body.

For log levels, see num_collect::logging::log_level.

Definition at line 296 of file logging_macros.h.

◆ NUM_COLLECT_LOG_INFO

#define NUM_COLLECT_LOG_INFO ( LOGGER,
... )
Value:
/*NOLINT*/ \
INTERNAL_NUM_COLLECT_LOG_IMPL( \

Write an information log.

Arguments:

  • LOGGER: Logger.
  • Remaining arguments are either
    • the log body, or
    • the format string and its arguments of the log body.

For log levels, see num_collect::logging::log_level.

Definition at line 264 of file logging_macros.h.

◆ NUM_COLLECT_LOG_ITERATION

#define NUM_COLLECT_LOG_ITERATION ( LOGGER,
... )
Value:
/*NOLINT*/ \
INTERNAL_NUM_COLLECT_LOG_IMPL( \

Write a log of an iteration.

Arguments:

  • LOGGER: Logger.
  • Remaining arguments are either
    • the log body, or
    • the format string and its arguments of the log body.

For log levels, see num_collect::logging::log_level.

Definition at line 216 of file logging_macros.h.

◆ NUM_COLLECT_LOG_ITERATION_LABEL

#define NUM_COLLECT_LOG_ITERATION_LABEL ( LOGGER,
... )
Value:
/*NOLINT*/ \
INTERNAL_NUM_COLLECT_LOG_IMPL(LOGGER, \
@ iteration_label
Label of iterations.

Write a log of a label of iterations.

Arguments:

  • LOGGER: Logger.
  • Remaining arguments are either
    • the log body, or
    • the format string and its arguments of the log body.

For log levels, see num_collect::logging::log_level.

Definition at line 232 of file logging_macros.h.

◆ NUM_COLLECT_LOG_SUMMARY

#define NUM_COLLECT_LOG_SUMMARY ( LOGGER,
... )
Value:
/*NOLINT*/ \
INTERNAL_NUM_COLLECT_LOG_IMPL( \

Write a summary log.

Arguments:

  • LOGGER: Logger.
  • Remaining arguments are either
    • the log body, or
    • the format string and its arguments of the log body.

For log levels, see num_collect::logging::log_level.

Definition at line 248 of file logging_macros.h.

◆ NUM_COLLECT_LOG_TRACE

#define NUM_COLLECT_LOG_TRACE ( LOGGER,
... )
Value:
/*NOLINT*/ \
INTERNAL_NUM_COLLECT_LOG_IMPL( \

Write a trace log.

Arguments:

  • LOGGER: Logger.
  • Remaining arguments are either
    • the log body, or
    • the format string and its arguments of the log body.

For log levels, see num_collect::logging::log_level.

Definition at line 184 of file logging_macros.h.

◆ NUM_COLLECT_LOG_WARNING

#define NUM_COLLECT_LOG_WARNING ( LOGGER,
... )
Value:
/*NOLINT*/ \
INTERNAL_NUM_COLLECT_LOG_IMPL( \

Write a warning log.

Arguments:

  • LOGGER: Logger.
  • Remaining arguments are either
    • the log body, or
    • the format string and its arguments of the log body.

For log levels, see num_collect::logging::log_level.

Definition at line 280 of file logging_macros.h.