Skip to content

Commit

Permalink
check should_log in log_with_format_
Browse files Browse the repository at this point in the history
  • Loading branch information
gabime committed Sep 9, 2023
1 parent d230fbf commit 3a68858
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions include/spdlog/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ class SPDLOG_API logger
template<typename... Args>
void log(source_loc loc, level::level_enum lvl, format_string_t<Args...> fmt, Args &&...args)
{
log_with_format_(loc, lvl, details::to_string_view(fmt), std::forward<Args>(args)...);
if (should_log(lvl))
{
log_with_format_(loc, lvl, details::to_string_view(fmt), std::forward<Args>(args)...);
}

}

template<typename... Args>
Expand Down Expand Up @@ -247,10 +251,7 @@ class SPDLOG_API logger
template<typename... Args>
void log_with_format_(source_loc loc, level::level_enum lvl, string_view_t fmt, Args &&...args)
{
if (!should_log(lvl))
{
return;
}
assert(should_log(lvl));
SPDLOG_TRY
{
memory_buf_t buf;
Expand Down

0 comments on commit 3a68858

Please sign in to comment.