2019-06-20 06:02:54 +08:00
|
|
|
/*
|
2023-09-25 21:05:07 +08:00
|
|
|
* This content is released under the MIT License as specified in
|
2023-10-01 17:20:48 +08:00
|
|
|
* https://raw.githubusercontent.com/gabime/spdlog/v2.x/LICENSE
|
2019-06-20 06:02:54 +08:00
|
|
|
*/
|
|
|
|
#include "includes.h"
|
|
|
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
2023-09-29 05:20:26 +08:00
|
|
|
#include "spdlog/sinks/stdout_sinks.h"
|
2023-10-01 17:20:48 +08:00
|
|
|
|
2023-09-25 21:05:07 +08:00
|
|
|
TEST_CASE("stdout_st", "[stdout]") {
|
2023-10-01 17:20:48 +08:00
|
|
|
spdlog::set_pattern("%+");
|
2019-06-20 06:02:54 +08:00
|
|
|
auto l = spdlog::stdout_logger_st("test");
|
2023-09-23 22:59:51 +08:00
|
|
|
l->set_level(spdlog::level::trace);
|
2019-06-20 06:02:54 +08:00
|
|
|
l->trace("Test stdout_st");
|
2023-10-01 17:20:48 +08:00
|
|
|
l->debug("Test stdout_st");
|
|
|
|
l->info("Test stdout_st");
|
|
|
|
l->warn("Test stdout_st");
|
|
|
|
l->error("Test stdout_st");
|
|
|
|
l->critical("Test stdout_st");
|
2019-06-20 06:02:54 +08:00
|
|
|
spdlog::drop_all();
|
|
|
|
}
|
|
|
|
|
2023-09-25 21:05:07 +08:00
|
|
|
TEST_CASE("stderr_st", "[stderr]") {
|
2019-06-20 06:02:54 +08:00
|
|
|
auto l = spdlog::stderr_logger_st("test");
|
2023-10-01 17:20:48 +08:00
|
|
|
l->set_level(spdlog::level::trace);
|
|
|
|
l->trace("Test stderr_st");
|
|
|
|
l->debug("Test stderr_st");
|
2019-06-20 06:02:54 +08:00
|
|
|
l->info("Test stderr_st");
|
2023-10-01 17:20:48 +08:00
|
|
|
l->warn("Test stderr_st");
|
|
|
|
l->error("Test stderr_st");
|
|
|
|
l->critical("Test stderr_st");
|
2019-06-20 06:02:54 +08:00
|
|
|
spdlog::drop_all();
|
|
|
|
}
|
|
|
|
|
2023-10-01 17:20:48 +08:00
|
|
|
TEST_CASE("stdout_mt", "[stdout]") {
|
|
|
|
auto sink = std::make_shared<spdlog::sinks::stdout_sink_mt>();
|
|
|
|
spdlog::logger logger("logger", sink);
|
|
|
|
logger.debug("Test stdout_mt should not be displayed !!!!");
|
|
|
|
}
|
|
|
|
|
2023-09-25 21:05:07 +08:00
|
|
|
TEST_CASE("stderr_mt", "[stderr]") {
|
2023-10-01 17:20:48 +08:00
|
|
|
auto sink = std::make_shared<spdlog::sinks::stderr_sink_mt>();
|
|
|
|
spdlog::logger logger("logger", sink);
|
|
|
|
logger.debug("Test stderr_mt should not be displayed !!!!");
|
2019-06-20 06:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// color loggers
|
2023-09-25 21:05:07 +08:00
|
|
|
TEST_CASE("stdout_color_st", "[stdout]") {
|
2019-06-20 06:02:54 +08:00
|
|
|
auto l = spdlog::stdout_color_st("test");
|
|
|
|
l->set_pattern("%+");
|
2023-10-01 17:20:48 +08:00
|
|
|
l->set_level(spdlog::level::trace);
|
|
|
|
l->trace("Test stdout_color_st");
|
|
|
|
l->debug("Test stdout_color_st");
|
2019-06-20 06:02:54 +08:00
|
|
|
l->info("Test stdout_color_st");
|
2023-10-01 17:20:48 +08:00
|
|
|
l->warn("Test stdout_color_st");
|
|
|
|
l->error("Test stdout_color_st");
|
|
|
|
l->critical("Test stdout_color_st");
|
2019-06-20 06:02:54 +08:00
|
|
|
spdlog::drop_all();
|
|
|
|
}
|
|
|
|
|
2023-09-25 21:05:07 +08:00
|
|
|
TEST_CASE("stdout_color_mt", "[stdout]") {
|
2019-06-20 06:02:54 +08:00
|
|
|
auto l = spdlog::stdout_color_mt("test");
|
|
|
|
l->set_pattern("%+");
|
2023-09-23 22:59:51 +08:00
|
|
|
l->set_level(spdlog::level::trace);
|
2019-06-20 06:02:54 +08:00
|
|
|
l->trace("Test stdout_color_mt");
|
2023-10-01 17:20:48 +08:00
|
|
|
l->debug("Test stdout_color_mt");
|
|
|
|
l->info("Test stdout_color_mt");
|
|
|
|
l->warn("Test stdout_color_mt");
|
|
|
|
l->error("Test stdout_color_mt");
|
|
|
|
l->critical("Test stdout_color_mt");
|
2019-06-20 06:02:54 +08:00
|
|
|
spdlog::drop_all();
|
|
|
|
}
|
|
|
|
|
2023-09-25 21:05:07 +08:00
|
|
|
TEST_CASE("stderr_color_st", "[stderr]") {
|
2019-06-20 06:02:54 +08:00
|
|
|
auto l = spdlog::stderr_color_st("test");
|
|
|
|
l->set_pattern("%+");
|
2023-09-23 22:59:51 +08:00
|
|
|
l->set_level(spdlog::level::debug);
|
2019-06-20 06:02:54 +08:00
|
|
|
l->debug("Test stderr_color_st");
|
|
|
|
spdlog::drop_all();
|
|
|
|
}
|
|
|
|
|
2023-09-25 21:05:07 +08:00
|
|
|
TEST_CASE("stderr_color_mt", "[stderr]") {
|
2019-06-20 06:02:54 +08:00
|
|
|
auto l = spdlog::stderr_color_mt("test");
|
|
|
|
l->set_pattern("%+");
|
|
|
|
l->info("Test stderr_color_mt");
|
|
|
|
l->warn("Test stderr_color_mt");
|
|
|
|
l->error("Test stderr_color_mt");
|
|
|
|
l->critical("Test stderr_color_mt");
|
|
|
|
spdlog::drop_all();
|
2019-09-23 17:06:21 +08:00
|
|
|
}
|