30#include <fmt/format.h>
63template <
typename... Args>
64 requires(
sizeof...(Args) > 0)
69 source, level, format, std::forward<Args>(args)...);
83 std::constructible_from<std::string_view, util::source_info_view> Exception>
86 l.
error(source)(message);
87 throw Exception(message, source);
101 std::constructible_from<std::string_view, util::source_info_view> Exception,
102 typename... MessageArgs>
103 requires(
sizeof...(MessageArgs) > 0)
105 fmt::format_string<MessageArgs...> message_format,
106 MessageArgs&&... message_args) {
107 fmt::memory_buffer buffer;
108 fmt::format_to(std::back_inserter(buffer), message_format,
109 std::forward<MessageArgs>(message_args)...);
111 source, l, std::string_view(buffer.data(), buffer.size()));
122 std::constructible_from<std::string_view, util::source_info_view> Exception>
139 std::constructible_from<std::string_view, util::source_info_view> Exception,
140 typename... MessageArgs>
141 requires(
sizeof...(MessageArgs) > 0)
143 fmt::format_string<MessageArgs...> message_format,
144 MessageArgs&&... message_args) {
147 source, l, message_format, std::forward<MessageArgs>(message_args)...);
163#define INTERNAL_NUM_COLLECT_LOG_IMPL(LOGGER, LEVEL, ...) \
165 if (LOGGER.should_log(LEVEL)) { \
166 ::num_collect::logging::impl::log_without_condition_check( \
167 ::num_collect::util::source_info_view(), LOGGER, LEVEL, \
184#define NUM_COLLECT_LOG_TRACE(LOGGER, ...) \
185 INTERNAL_NUM_COLLECT_LOG_IMPL( \
186 LOGGER, ::num_collect::logging::log_level::trace, __VA_ARGS__)
200#define NUM_COLLECT_LOG_DEBUG(LOGGER, ...) \
201 INTERNAL_NUM_COLLECT_LOG_IMPL( \
202 LOGGER, ::num_collect::logging::log_level::debug, __VA_ARGS__)
216#define NUM_COLLECT_LOG_ITERATION(LOGGER, ...) \
217 INTERNAL_NUM_COLLECT_LOG_IMPL( \
218 LOGGER, ::num_collect::logging::log_level::iteration, __VA_ARGS__)
232#define NUM_COLLECT_LOG_ITERATION_LABEL(LOGGER, ...) \
233 INTERNAL_NUM_COLLECT_LOG_IMPL(LOGGER, \
234 ::num_collect::logging::log_level::iteration_label, __VA_ARGS__)
248#define NUM_COLLECT_LOG_SUMMARY(LOGGER, ...) \
249 INTERNAL_NUM_COLLECT_LOG_IMPL( \
250 LOGGER, ::num_collect::logging::log_level::summary, __VA_ARGS__)
264#define NUM_COLLECT_LOG_INFO(LOGGER, ...) \
265 INTERNAL_NUM_COLLECT_LOG_IMPL( \
266 LOGGER, ::num_collect::logging::log_level::info, __VA_ARGS__)
280#define NUM_COLLECT_LOG_WARNING(LOGGER, ...) \
281 INTERNAL_NUM_COLLECT_LOG_IMPL( \
282 LOGGER, ::num_collect::logging::log_level::warning, __VA_ARGS__)
296#define NUM_COLLECT_LOG_ERROR(LOGGER, ...) \
297 INTERNAL_NUM_COLLECT_LOG_IMPL( \
298 LOGGER, ::num_collect::logging::log_level::error, __VA_ARGS__)
312#define NUM_COLLECT_LOG_CRITICAL(LOGGER, ...) \
313 INTERNAL_NUM_COLLECT_LOG_IMPL( \
314 LOGGER, ::num_collect::logging::log_level::critical, __VA_ARGS__)
333#define NUM_COLLECT_LOG_AND_THROW(EXCEPTION_TYPE, ...) \
334 ::num_collect::logging::log_and_throw<EXCEPTION_TYPE>( \
335 ::num_collect::util::source_info_view(), __VA_ARGS__)
void log_without_condition_check(util::source_info_view source, log_level level, std::string_view body) const
Write a log without check of the condition to write logs.
auto error(util::source_info_view source=util::source_info_view()) const noexcept -> logging_proxy
Write a error log.
Class to hold information of source codes.
Definition of log_level enumeration.
Definition of logger class.
void 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.
void 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.
log_level
Enumeration of log levels.
Definition of source_info_view class.