Replies: 4 comments 6 replies
-
That document is wrong. See FAQ: https://github.com/gabime/spdlog/wiki/0.-FAQ#source-information-do-not-appear-when-using-custom-format Example: #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO
#include "spdlog/spdlog.h"
#include "spdlog/sinks/stdout_sinks.h"
void source_info_example()
{
auto console = spdlog::stdout_logger_mt("console");
spdlog::set_default_logger(console);
spdlog::set_pattern("[source %s] [function %!] [line %#] %v");
SPDLOG_LOGGER_INFO(console, "log with source info"); // Console: "[source example.cpp] [function source_info_example] [line 10] log with source info"
SPDLOG_INFO("global log with source info"); // Console: "[source example.cpp] [function source_info_example] [line 11] global logger with source info"
console->info("source info is not printed"); // Console: "[source ] [function ] [line ] source info is not printed"
} |
Beta Was this translation helpful? Give feedback.
-
If I add these lines: #define SPDLOG_LEVEL_NAMES I got some compilation error (result.txt). If I change to #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_INFO Then I can compile ok. |
Beta Was this translation helpful? Give feedback.
-
when I use SPDLOG_INFO, I'd like to use one pattern and while I use spdlog::info, I'd like to use another pattern. I have not found a nice way to do achieve it. More meaningful to me is that I want #define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_TRACE to work. When in TRACE, ERROR/Critical level, I want source information. |
Beta Was this translation helpful? Give feedback.
-
btw, my problem code I think you can easily remove them: #include "DepthSource.h" |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I know there is a link https://spdlog.docsforge.com/v1.x/0.faq/#source-information-do-not-appear-when-using-custom-format talking about this restriction.
#define SPDLOG_INFO_VERBOSE(...) SPDLOG_LOGGER_CALL(spdlog::default_logger_raw(), spdlog::level::info, VA_ARGS)
#define SPDLOG_TRACE_VERBOSE(...) SPDLOG_LOGGER_CALL(spdlog::default_logger_raw(), spdlog::level::trace, VA_ARGS)
spdlog::set_level(spdlog::level::trace);
SPDLOG_TRACE_VERBOSE("Welcome to spdlog!");
spdlog::info("Welcome to spdlog!");
auto console = spd::stdout_color_mt("console");
spdlog::set_pattern("[%H:%M:%S %f] [%t] [%^%l%$] %v");
SPDLOG_INFO_VERBOSE("Welcome to spdlog!");
console->error("Some error message with arg{}..", 1);
output:
[2022-01-07 18:15:28.120] [trace] [spdlogTest.cpp:42] Welcome to spdlog!
[2022-01-07 18:15:28.120] [info] Welcome to spdlog!
[18:15:28 120806] [18013] [info] Welcome to spdlog!
[18:15:28 120906] [18013] [error] Some error message with arg1..
[18:15:28 120949] [18013] [warning] Easy padding in numbers like 00000012
Keen to know why I can't call set_pattern().
I want source information and dynamic level setting by spdlog::set_level()
Beta Was this translation helpful? Give feedback.
All reactions