summaryrefslogtreecommitdiff
path: root/asl/logging/logging_tests.cpp
blob: 39a800ad62d35407dc1f88596b1c6a9ef77bfae4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "asl/logging/logging.hpp"
#include "asl/testing/testing.hpp"
#include "asl/strings/string_builder.hpp"

ASL_TEST(log)
{
    asl::log::log(asl::log::kInfo, asl::source_location{}, "Hello, {}!", "world"_sv);

    ASL_LOG_ERROR("Oh no! {}", 42);
}

static asl::StringWriter g_string_writer{};

ASL_TEST(custom_writer)
{
    asl::log::register_logger<asl::log::DefaultLogger<asl::StringWriter<>&>>(g_string_writer);

    ASL_LOG_INFO("Hello");
    auto sv = g_string_writer.as_string_view();

    ASL_TEST_EXPECT(sv == "[  INFO   ] asl/logging/logging_tests.cpp:18: Hello\n");
}