Sha256: 971613c8bfda783c382a8e69e1d84763f6bf49ac4ffbb94e8f818a94d160e976

Contents?: true

Size: 1.89 KB

Versions: 16

Compression:

Stored size: 1.89 KB

Contents

#include <catch.hpp>
#include <leatherman/logging/logging.hpp>
#include <boost/nowide/convert.hpp>
#include "logging.hpp"

using namespace std;
using namespace leatherman::logging;

TEST_CASE("logging with on_message") {
    leatherman::test::logging_context ctx(log_level::trace);

    string message;
    log_level level;
    on_message([&](log_level lvl, string const& msg) {
        level = lvl;
        message = msg;
        return false;
    });

    SECTION("a TRACE message is logged to on_message") {
        LOG_TRACE("trace message");
        REQUIRE(level == log_level::trace);
        REQUIRE(message == "trace message");
    }
    SECTION("a DEBUG message is logged to on_message") {
        LOG_DEBUG("debug message");
        REQUIRE(level == log_level::debug);
        REQUIRE(message == "debug message");
    }
    SECTION("an INFO message is logged to on_message") {
        LOG_INFO("info message");
        REQUIRE(level == log_level::info);
        REQUIRE(message == "info message");
    }
    SECTION("a WARNING message is logged to on_message") {
        LOG_WARNING("warning message");
        REQUIRE(level == log_level::warning);
        REQUIRE(message == "warning message");
    }
    SECTION("an ERROR message is logged to on_message") {
        LOG_ERROR("error message");
        REQUIRE(level == log_level::error);
        REQUIRE(message == "error message");
    }
    SECTION("a FATAL message is logged to on_message") {
        LOG_FATAL("fatal message");
        REQUIRE(level == log_level::fatal);
        REQUIRE(message == "fatal message");
    }
#if 0
    SECTION("a unicode characters to log") {
        const wstring symbols[] = {L"\u2122", L"\u2744", L"\u039b"};
        for (auto const& s : symbols) {
            auto utf8 = boost::nowide::narrow(s);
            LOG_INFO(utf8);
            REQUIRE(level == log_level::info);
            REQUIRE(message == utf8);
        }
    }
#endif
}

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.12.1.cfacter.20181031 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.11.6.cfacter.20181031 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.12.1.cfacter.20181023 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.11.5.cfacter.20181022 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.12.0.cfacter.20181004 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.12.0.cfacter.20181001 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.12.0.cfacter.20180918 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.11.4.cfacter.20180821 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.11.3.cfacter.20180716 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.11.2.cfacter.20180612 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.9.6.cfacter.20180612 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.11.2.cfacter.20180606 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.9.6.cfacter.20180606 ext/facter/leatherman/logging/tests/logging_on_message.cc
facter-3.11.0.cfacter.20180319 ext/facter/leatherman/logging/tests/logging_on_message.cc
cfacter-3.11.0.rc.20180314 ext/facter/leatherman/logging/tests/logging_on_message.cc