diff options
author | m-milkin <m-milkin@yandex-team.com> | 2023-04-14 15:40:27 +0300 |
---|---|---|
committer | m-milkin <m-milkin@yandex-team.com> | 2023-04-14 15:40:27 +0300 |
commit | fb642d882910bcf70b25fa17c3de522e61b4ac84 (patch) | |
tree | 5eb54fe4209510f211280aaaba63ede17ad1e2ea /library/cpp/logger/element_ut.cpp | |
parent | 8c60d32628e9e0c4659bd837a357b08973070031 (diff) | |
download | ydb-fb642d882910bcf70b25fa17c3de522e61b4ac84.tar.gz |
[library/cpp/logger] Support meta flags with TLogElement
Support opportunity to use TMetaFlags with TLogElement.
**Use example:**
`Log().With("Property", "Value").With("Code", "Code") << LogMessage`
Such interface allows to not parse required by TLogBackend properties from raw string.
Diffstat (limited to 'library/cpp/logger/element_ut.cpp')
-rw-r--r-- | library/cpp/logger/element_ut.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/library/cpp/logger/element_ut.cpp b/library/cpp/logger/element_ut.cpp index 32edc52dfb0..86303973d8f 100644 --- a/library/cpp/logger/element_ut.cpp +++ b/library/cpp/logger/element_ut.cpp @@ -9,13 +9,16 @@ #include <library/cpp/testing/unittest/registar.h> + class TLogElementTest: public TTestBase { UNIT_TEST_SUITE(TLogElementTest); UNIT_TEST(TestMoveCtor); + UNIT_TEST(TestWith); UNIT_TEST_SUITE_END(); public: void TestMoveCtor(); + void TestWith(); }; UNIT_TEST_SUITE_REGISTRATION(TLogElementTest); @@ -37,3 +40,16 @@ void TLogElementTest::TestMoveCtor() { dst.Destroy(); UNIT_ASSERT(output.Str() == message); } + +void TLogElementTest::TestWith() { + TStringStream output; + TLog log(MakeHolder<TStreamWithContextLogBackend>(&output)); + + THolder<TLogElement> src = MakeHolder<TLogElement>(&log); + + TString message = "Hello, World!"; + (*src).With("Foo", "Bar").With("Foo", "Baz") << message; + + src.Destroy(); + UNIT_ASSERT(output.Str() == "Hello, World!; Foo=Bar; Foo=Baz; "); +} |