1

Following spdlog documentation I was able to modify the print pattern

#include "spdlog/spdlog.h"
#include "spdlog/sinks/daily_file_sink.h"

int main()
{
    spdlog::set_pattern("%H:%M:%S.%e %t %s %! %v");

    auto logger = spdlog::daily_logger_mt("daily_logger", "../../../logs/daily.txt", 2, 30);

    logger->info("casdc");

    return 0;
}

With the above I see daily_logger.txt contents below:

01:41:35.895 70101   casdc
01:44:22.719 71978   casdc
01:44:35.225 72232   casdc

But I was expecting to see also:

%s Basename of the source file  
%! Source function

Why I'm not seeing those?

Actually it seems to work if I call

 SPDLOG_LOGGER_INFO(logger, "{:>10}", "vsvfsdfv");

But then my question is when should I call

logger->info("casdc");
user16217248
  • 3,119
  • 19
  • 19
  • 37
KcFnMi
  • 5,516
  • 10
  • 62
  • 136
  • You can't for now. There is a tracking issue [#1823](https://github.com/gabime/spdlog/issues/1823) for this feature, using C++20 `std::source_location`. – Sprite Jun 05 '22 at 18:48

1 Answers1

0

SPDLOG_LOGGER_INFO(logger, "{:>10}", "vsvfsdfv") it works, but it doesn't work when SPDLOG_LOGGER_TRACE(logger, "message"),the log level is invalid