CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
179 lines
5.7 KiB
C++
179 lines
5.7 KiB
C++
|
|
#include "includes.h"
|
|
#include "test_sink.h"
|
|
|
|
#include <spdlog/cfg/env.h>
|
|
#include <spdlog/cfg/argv.h>
|
|
|
|
using spdlog::cfg::load_argv_levels;
|
|
using spdlog::cfg::load_env_levels;
|
|
using spdlog::sinks::test_sink_st;
|
|
|
|
TEST_CASE("env", "[cfg]") {
|
|
spdlog::drop("l1");
|
|
auto l1 = spdlog::create<test_sink_st>("l1");
|
|
#ifdef CATCH_PLATFORM_WINDOWS
|
|
_putenv_s("SPDLOG_LEVEL", "l1=warn");
|
|
#else
|
|
setenv("SPDLOG_LEVEL", "l1=warn", 1);
|
|
#endif
|
|
load_env_levels();
|
|
REQUIRE(l1->level() == spdlog::level::warn);
|
|
|
|
#ifdef CATCH_PLATFORM_WINDOWS
|
|
_putenv_s("MYAPP_LEVEL", "l1=trace");
|
|
#else
|
|
setenv("MYAPP_LEVEL", "l1=trace", 1);
|
|
#endif
|
|
load_env_levels("MYAPP_LEVEL");
|
|
REQUIRE(l1->level() == spdlog::level::trace);
|
|
|
|
spdlog::set_default_logger(spdlog::create<test_sink_st>("cfg-default"));
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
|
|
}
|
|
|
|
TEST_CASE("argv1", "[cfg]") {
|
|
spdlog::drop("l1");
|
|
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn"};
|
|
load_argv_levels(2, argv);
|
|
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
|
|
REQUIRE(l1->level() == spdlog::level::warn);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
|
|
}
|
|
|
|
TEST_CASE("argv2", "[cfg]") {
|
|
spdlog::drop("l1");
|
|
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn,trace"};
|
|
load_argv_levels(2, argv);
|
|
auto l1 = spdlog::create<test_sink_st>("l1");
|
|
REQUIRE(l1->level() == spdlog::level::warn);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace);
|
|
}
|
|
|
|
TEST_CASE("argv3", "[cfg]") {
|
|
spdlog::set_level(spdlog::level::trace);
|
|
|
|
spdlog::drop("l1");
|
|
const char *argv[] = {"ignore", "SPDLOG_LEVEL=junk_name=warn"};
|
|
load_argv_levels(2, argv);
|
|
auto l1 = spdlog::create<test_sink_st>("l1");
|
|
REQUIRE(l1->level() == spdlog::level::trace);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace);
|
|
}
|
|
|
|
TEST_CASE("argv4", "[cfg]") {
|
|
spdlog::set_level(spdlog::level::info);
|
|
spdlog::drop("l1");
|
|
const char *argv[] = {"ignore", "SPDLOG_LEVEL=junk"};
|
|
load_argv_levels(2, argv);
|
|
auto l1 = spdlog::create<test_sink_st>("l1");
|
|
REQUIRE(l1->level() == spdlog::level::info);
|
|
}
|
|
|
|
TEST_CASE("argv5", "[cfg]") {
|
|
spdlog::set_level(spdlog::level::info);
|
|
spdlog::drop("l1");
|
|
const char *argv[] = {"ignore", "ignore", "SPDLOG_LEVEL=l1=warn,trace"};
|
|
load_argv_levels(3, argv);
|
|
auto l1 = spdlog::create<test_sink_st>("l1");
|
|
REQUIRE(l1->level() == spdlog::level::warn);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace);
|
|
spdlog::set_level(spdlog::level::info);
|
|
}
|
|
|
|
TEST_CASE("argv6", "[cfg]") {
|
|
spdlog::set_level(spdlog::level::err);
|
|
const char *argv[] = {""};
|
|
load_argv_levels(1, argv);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::err);
|
|
spdlog::set_level(spdlog::level::info);
|
|
}
|
|
|
|
TEST_CASE("argv7", "[cfg]") {
|
|
spdlog::set_level(spdlog::level::err);
|
|
const char *argv[] = {""};
|
|
load_argv_levels(0, argv);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::err);
|
|
spdlog::set_level(spdlog::level::info);
|
|
}
|
|
|
|
TEST_CASE("level-not-set-test1", "[cfg]") {
|
|
spdlog::drop("l1");
|
|
const char *argv[] = {"ignore", ""};
|
|
load_argv_levels(2, argv);
|
|
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
|
|
l1->set_level(spdlog::level::trace);
|
|
REQUIRE(l1->level() == spdlog::level::trace);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
|
|
}
|
|
|
|
TEST_CASE("level-not-set-test2", "[cfg]") {
|
|
spdlog::drop("l1");
|
|
spdlog::drop("l2");
|
|
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=trace"};
|
|
|
|
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
|
|
l1->set_level(spdlog::level::warn);
|
|
auto l2 = spdlog::create<spdlog::sinks::test_sink_st>("l2");
|
|
l2->set_level(spdlog::level::warn);
|
|
|
|
load_argv_levels(2, argv);
|
|
|
|
REQUIRE(l1->level() == spdlog::level::trace);
|
|
REQUIRE(l2->level() == spdlog::level::warn);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
|
|
}
|
|
|
|
TEST_CASE("level-not-set-test3", "[cfg]") {
|
|
spdlog::drop("l1");
|
|
spdlog::drop("l2");
|
|
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=trace"};
|
|
|
|
load_argv_levels(2, argv);
|
|
|
|
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
|
|
auto l2 = spdlog::create<spdlog::sinks::test_sink_st>("l2");
|
|
|
|
REQUIRE(l1->level() == spdlog::level::trace);
|
|
REQUIRE(l2->level() == spdlog::level::info);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
|
|
}
|
|
|
|
TEST_CASE("level-not-set-test4", "[cfg]") {
|
|
spdlog::drop("l1");
|
|
spdlog::drop("l2");
|
|
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=trace,warn"};
|
|
|
|
load_argv_levels(2, argv);
|
|
|
|
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
|
|
auto l2 = spdlog::create<spdlog::sinks::test_sink_st>("l2");
|
|
|
|
REQUIRE(l1->level() == spdlog::level::trace);
|
|
REQUIRE(l2->level() == spdlog::level::warn);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::warn);
|
|
}
|
|
|
|
TEST_CASE("level-not-set-test5", "[cfg]") {
|
|
spdlog::drop("l1");
|
|
spdlog::drop("l2");
|
|
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=junk,warn"};
|
|
|
|
load_argv_levels(2, argv);
|
|
|
|
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
|
|
auto l2 = spdlog::create<spdlog::sinks::test_sink_st>("l2");
|
|
|
|
REQUIRE(l1->level() == spdlog::level::warn);
|
|
REQUIRE(l2->level() == spdlog::level::warn);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::warn);
|
|
}
|
|
|
|
TEST_CASE("restore-to-default", "[cfg]") {
|
|
spdlog::drop("l1");
|
|
spdlog::drop("l2");
|
|
const char *argv[] = {"ignore", "SPDLOG_LEVEL=info"};
|
|
load_argv_levels(2, argv);
|
|
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
|
|
}
|