diff options
author | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-10-20 17:16:20 +0300 |
---|---|---|
committer | ivanmorozov <ivanmorozov@yandex-team.com> | 2023-10-20 18:36:48 +0300 |
commit | 25d84e86f40b4fd3fdf1e17f5a6b72b6f83735d7 (patch) | |
tree | f10995265f28b73401597434f20e74665864fed7 | |
parent | b5c517190a565e87657b56a363d58217480ef3f8 (diff) | |
download | ydb-25d84e86f40b4fd3fdf1e17f5a6b72b6f83735d7.tar.gz |
add log macros
-rw-r--r-- | library/cpp/actors/core/log.cpp | 5 | ||||
-rw-r--r-- | library/cpp/actors/core/log.h | 24 |
2 files changed, 24 insertions, 5 deletions
diff --git a/library/cpp/actors/core/log.cpp b/library/cpp/actors/core/log.cpp index 18f43a2fed..a4427610a8 100644 --- a/library/cpp/actors/core/log.cpp +++ b/library/cpp/actors/core/log.cpp @@ -732,4 +732,9 @@ namespace NActors { } + TVerifyFormattedRecordWriter::~TVerifyFormattedRecordWriter() { + const TString data = TBase::GetResult(); + Y_ABORT("%s", data.data()); + } + } diff --git a/library/cpp/actors/core/log.h b/library/cpp/actors/core/log.h index 44cd3730a4..05e7a50107 100644 --- a/library/cpp/actors/core/log.h +++ b/library/cpp/actors/core/log.h @@ -403,6 +403,16 @@ namespace NActors { return *this; } + template <class TKey, class TValue> + TFormatedStreamWriter& Write(const TKey& pName, const std::optional<TValue>& pValue) { + if (pValue) { + Builder << pName << "=" << *pValue << ";"; + } else { + Builder << pName << "=NO_VALUE_OPTIONAL;"; + } + return *this; + } + TFormatedStreamWriter& WriteDirectly(const TString& data) { Builder << data; return *this; @@ -463,7 +473,7 @@ namespace NActors { template <class TKey, class TValue> TLogContextGuard& Write(const TKey& pName, const TValue& pValue) { - Write(pName, pValue); + TBase::Write(pName, pValue); return *this; } @@ -522,15 +532,19 @@ namespace NActors { return *this; } - ~TVerifyFormattedRecordWriter() { - const TString data = TBase::GetResult(); - Y_ABORT("%s", data.data()); - } + ~TVerifyFormattedRecordWriter(); }; } #define AFL_VERIFY(condition) if (condition); else NActors::TVerifyFormattedRecordWriter(#condition)("fline", TStringBuilder() << TStringBuf(__FILE__).RAfter(LOCSLASH_C) << ":" << __LINE__) +#ifndef NDEBUG +/// Assert that depend on NDEBUG macro and outputs message like printf +#define AFL_VERIFY_DEBUG AFL_VERIFY +#else +#define AFL_VERIFY_DEBUG(condition) if (true); else NActors::TVerifyFormattedRecordWriter(#condition)("fline", TStringBuilder() << TStringBuf(__FILE__).RAfter(LOCSLASH_C) << ":" << __LINE__) +#endif + #define ACTORS_FORMATTED_LOG(mPriority, mComponent) \ if (NActors::TlsActivationContext && !IS_LOG_PRIORITY_ENABLED(mPriority, mComponent));\ else NActors::TFormattedRecordWriter(\ |