diff options
author | nsofya <nsofya@yandex-team.com> | 2023-05-26 17:26:26 +0300 |
---|---|---|
committer | nsofya <nsofya@yandex-team.com> | 2023-05-26 17:26:26 +0300 |
commit | d8341f8abab29d0fcfb7096a3d1b3c6fd399781b (patch) | |
tree | caa9826553c33baa2f29b2d297ae98fbd365d08d | |
parent | a740299e17210754147467428d1e64d7887ae4a6 (diff) | |
download | ydb-d8341f8abab29d0fcfb7096a3d1b3c6fd399781b.tar.gz |
Check TlsActivationContext in log macroses
Чтобы в тестах без акторов можно было использовать, и не было падений.
-rw-r--r-- | library/cpp/actors/core/log.h | 33 | ||||
-rw-r--r-- | ydb/core/blob_depot/agent/storage_get.cpp | 4 | ||||
-rw-r--r-- | ydb/core/blob_depot/agent/storage_range.cpp | 2 | ||||
-rw-r--r-- | ydb/core/blob_depot/data_trash.cpp | 2 | ||||
-rw-r--r-- | ydb/core/blob_depot/types.h | 2 | ||||
-rw-r--r-- | ydb/core/tx/columnshard/columnshard__scan.cpp | 2 | ||||
-rw-r--r-- | ydb/core/tx/ctor_logger.h | 2 | ||||
-rw-r--r-- | ydb/core/tx/datashard/datashard_split_dst.cpp | 2 | ||||
-rw-r--r-- | ydb/core/util/stlog.h | 4 |
9 files changed, 26 insertions, 27 deletions
diff --git a/library/cpp/actors/core/log.h b/library/cpp/actors/core/log.h index f58621a58d..c801666ca3 100644 --- a/library/cpp/actors/core/log.h +++ b/library/cpp/actors/core/log.h @@ -24,23 +24,23 @@ // TODO: limit number of messages per second // TODO: make TLogComponentLevelRequest/Response network messages -#define IS_LOG_PRIORITY_ENABLED(actorCtxOrSystem, priority, component) \ - (static_cast<::NActors::NLog::TSettings*>((actorCtxOrSystem).LoggerSettings()) && \ - static_cast<::NActors::NLog::TSettings*>((actorCtxOrSystem).LoggerSettings())->Satisfies( \ +#define IS_LOG_PRIORITY_ENABLED(priority, component) \ + (NActors::TlsActivationContext ? (static_cast<::NActors::NLog::TSettings*>((*NActors::TlsActivationContext).LoggerSettings()) && \ + static_cast<::NActors::NLog::TSettings*>((*NActors::TlsActivationContext).LoggerSettings())->Satisfies( \ static_cast<::NActors::NLog::EPriority>(priority), \ static_cast<::NActors::NLog::EComponent>(component), \ 0ull) \ - ) - -#define IS_EMERG_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NActors::NLog::PRI_EMERG, component) -#define IS_ALERT_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NActors::NLog::PRI_ALERT, component) -#define IS_CRIT_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NActors::NLog::PRI_CRIT, component) -#define IS_ERROR_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NActors::NLog::PRI_ERROR, component) -#define IS_WARN_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NActors::NLog::PRI_WARN, component) -#define IS_NOTICE_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NActors::NLog::PRI_NOTICE, component) -#define IS_INFO_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NActors::NLog::PRI_INFO, component) -#define IS_DEBUG_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NActors::NLog::PRI_DEBUG, component) -#define IS_TRACE_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NActors::NLog::PRI_TRACE, component) + ) : true) + +#define IS_EMERG_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(NActors::NLog::PRI_EMERG, component) +#define IS_ALERT_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(NActors::NLog::PRI_ALERT, component) +#define IS_CRIT_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(NActors::NLog::PRI_CRIT, component) +#define IS_ERROR_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(NActors::NLog::PRI_ERROR, component) +#define IS_WARN_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(NActors::NLog::PRI_WARN, component) +#define IS_NOTICE_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(NActors::NLog::PRI_NOTICE, component) +#define IS_INFO_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(NActors::NLog::PRI_INFO, component) +#define IS_DEBUG_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(NActors::NLog::PRI_DEBUG, component) +#define IS_TRACE_LOG_ENABLED(component) IS_LOG_PRIORITY_ENABLED(NActors::NLog::PRI_TRACE, component) #define LOG_LOG_SAMPLED_BY(actorCtxOrSystem, priority, component, sampleBy, ...) \ do { \ @@ -425,13 +425,13 @@ namespace NActors { } #define ACTORS_FORMATTED_LOG(mPriority, mComponent) \ - if (NActors::TlsActivationContext && !IS_LOG_PRIORITY_ENABLED(NActors::TActivationContext::AsActorContext(), mPriority, mComponent));\ + if (NActors::TlsActivationContext && !IS_LOG_PRIORITY_ENABLED(mPriority, mComponent));\ else NActors::TFormattedRecordWriter(\ static_cast<::NActors::NLog::EPriority>(mPriority), static_cast<::NActors::NLog::EComponent>(mComponent)\ )("fline", TStringBuilder() << TStringBuf(__FILE__).RAfter(LOCSLASH_C) << ":" << __LINE__) #define ACTORS_LOG_STREAM(mPriority, mComponent) \ - if (NActors::TlsActivationContext && !IS_LOG_PRIORITY_ENABLED(NActors::TActivationContext::AsActorContext(), mPriority, mComponent));\ + if (NActors::TlsActivationContext && !IS_LOG_PRIORITY_ENABLED(mPriority, mComponent));\ else NActors::TRecordWriter(\ static_cast<::NActors::NLog::EPriority>(mPriority), static_cast<::NActors::NLog::EComponent>(mComponent)\ ) << TStringBuf(__FILE__).RAfter(LOCSLASH_C) << ":" << __LINE__ << " :" @@ -475,4 +475,3 @@ namespace NActors { #define AFL_CRIT(component) ACTORS_FORMATTED_LOG_CRIT(component) #define AFL_ALERT(component) ACTORS_FORMATTED_LOG_ALERT(component) #define AFL_EMERG(component) ACTORS_FORMATTED_LOG_EMERG(component) - diff --git a/ydb/core/blob_depot/agent/storage_get.cpp b/ydb/core/blob_depot/agent/storage_get.cpp index 697dfb2d49..e09c1be28e 100644 --- a/ydb/core/blob_depot/agent/storage_get.cpp +++ b/ydb/core/blob_depot/agent/storage_get.cpp @@ -22,7 +22,7 @@ namespace NKikimr::NBlobDepot { using TBlobStorageQuery::TBlobStorageQuery; void Initiate() override { - if (IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NLog::PRI_TRACE, NKikimrServices::BLOB_DEPOT_EVENTS)) { + if (IS_LOG_PRIORITY_ENABLED(NLog::PRI_TRACE, NKikimrServices::BLOB_DEPOT_EVENTS)) { for (ui32 i = 0; i < Request.QuerySize; ++i) { const auto& q = Request.Queries[i]; BDEV_QUERY(BDEV19, "TEvGet_new", (U.BlobId, q.Id), (U.Shift, q.Shift), (U.Size, q.Size), @@ -145,7 +145,7 @@ namespace NKikimr::NBlobDepot { } void TraceResponse(std::optional<NKikimrProto::EReplyStatus> status) { - if (IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NLog::PRI_TRACE, NKikimrServices::BLOB_DEPOT_EVENTS)) { + if (IS_LOG_PRIORITY_ENABLED(NLog::PRI_TRACE, NKikimrServices::BLOB_DEPOT_EVENTS)) { for (ui32 i = 0; i < Response->ResponseSz; ++i) { const auto& r = Response->Responses[i]; BDEV_QUERY(BDEV20, "TEvGet_end", (BlobId, r.Id), (Shift, r.Shift), diff --git a/ydb/core/blob_depot/agent/storage_range.cpp b/ydb/core/blob_depot/agent/storage_range.cpp index d9a2b049f6..c4a736ca96 100644 --- a/ydb/core/blob_depot/agent/storage_range.cpp +++ b/ydb/core/blob_depot/agent/storage_range.cpp @@ -157,7 +157,7 @@ namespace NKikimr::NBlobDepot { } void EndWithSuccess() { - if (IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NLog::PRI_TRACE, NKikimrServices::BLOB_DEPOT_EVENTS)) { + if (IS_LOG_PRIORITY_ENABLED(NLog::PRI_TRACE, NKikimrServices::BLOB_DEPOT_EVENTS)) { for (const auto& r : Response->Responses) { BDEV_QUERY(BDEV22, "TEvRange_item", (BlobId, r.Id), (Buffer.size, r.Buffer.size())); } diff --git a/ydb/core/blob_depot/data_trash.cpp b/ydb/core/blob_depot/data_trash.cpp index d5019f24f3..62e3d625e9 100644 --- a/ydb/core/blob_depot/data_trash.cpp +++ b/ydb/core/blob_depot/data_trash.cpp @@ -137,7 +137,7 @@ namespace NKikimr::NBlobDepot { const ui64 queryId = RandomNumber<ui64>(); CollectCmds.emplace(id, TCollectCmd{.QueryId = queryId, .GroupId = record.GroupId}); - if (IS_LOG_PRIORITY_ENABLED(*TlsActivationContext, NLog::PRI_TRACE, NKikimrServices::BLOB_DEPOT_EVENTS)) { + if (IS_LOG_PRIORITY_ENABLED(NLog::PRI_TRACE, NKikimrServices::BLOB_DEPOT_EVENTS)) { if (ev->Keep) { for (const TLogoBlobID& blobId : *ev->Keep) { Y_VERIFY(blobId.Channel() == record.Channel); diff --git a/ydb/core/blob_depot/types.h b/ydb/core/blob_depot/types.h index ba9a3f0148..4faf6f2529 100644 --- a/ydb/core/blob_depot/types.h +++ b/ydb/core/blob_depot/types.h @@ -248,7 +248,7 @@ namespace NKikimr::NBlobDepot { auto& ctx = *TlsActivationContext; \ const auto priority = NLog::PRI_TRACE; \ const auto component = NKikimrServices::BLOB_DEPOT_EVENTS; \ - if (IS_LOG_PRIORITY_ENABLED(ctx, priority, component)) { \ + if (IS_LOG_PRIORITY_ENABLED(priority, component)) { \ struct MARKER {}; \ TStringStream __stream; \ { \ diff --git a/ydb/core/tx/columnshard/columnshard__scan.cpp b/ydb/core/tx/columnshard/columnshard__scan.cpp index a925f1876e..9de12ac722 100644 --- a/ydb/core/tx/columnshard/columnshard__scan.cpp +++ b/ydb/core/tx/columnshard/columnshard__scan.cpp @@ -948,7 +948,7 @@ void TTxScan::Complete(const TActorContext& ctx) { } TStringStream detailedInfo; - if (IS_LOG_PRIORITY_ENABLED(ctx, NActors::NLog::PRI_TRACE, NKikimrServices::TX_COLUMNSHARD)) { + if (IS_LOG_PRIORITY_ENABLED(NActors::NLog::PRI_TRACE, NKikimrServices::TX_COLUMNSHARD)) { detailedInfo << " read metadata: (" << TContainerPrinter(ReadMetadataRanges) << ")" << " req: " << request; } std::vector<NOlap::TReadMetadata::TConstPtr> rMetadataRanges; diff --git a/ydb/core/tx/ctor_logger.h b/ydb/core/tx/ctor_logger.h index 1def1dd2a1..1126b4d321 100644 --- a/ydb/core/tx/ctor_logger.h +++ b/ydb/core/tx/ctor_logger.h @@ -23,7 +23,7 @@ public: template <typename TFunc> TCtorLogger(const NActors::TActivationContext& ctx, NActors::NLog::EPriority priority, TFunc logFunc) { - if (IS_LOG_PRIORITY_ENABLED(ctx, priority, Component)) { + if (IS_LOG_PRIORITY_ENABLED(priority, Component)) { TStringBuilder strStream; logFunc(strStream); ::NActors::MemLogAdapter(ctx, priority, Component, "%s", strStream.data()); diff --git a/ydb/core/tx/datashard/datashard_split_dst.cpp b/ydb/core/tx/datashard/datashard_split_dst.cpp index 24e741dd7b..41dd9f45c4 100644 --- a/ydb/core/tx/datashard/datashard_split_dst.cpp +++ b/ydb/core/tx/datashard/datashard_split_dst.cpp @@ -500,7 +500,7 @@ public: source.EnsureSplitKey(rdb, leftKey, itBegin->MaxOffset); // Dump final split keys and offsets for debugging - if (IS_LOG_PRIORITY_ENABLED(ctx, NLog::PRI_TRACE, NKikimrServices::TX_DATASHARD)) { + if (IS_LOG_PRIORITY_ENABLED(NLog::PRI_TRACE, NKikimrServices::TX_DATASHARD)) { for (const auto* state : source.Offsets) { LOG_TRACE_S(ctx, NKikimrServices::TX_DATASHARD, Self->TabletID() << " Source " << EscapeC(sourceName) diff --git a/ydb/core/util/stlog.h b/ydb/core/util/stlog.h index 268db31990..284c52a89b 100644 --- a/ydb/core/util/stlog.h +++ b/ydb/core/util/stlog.h @@ -65,7 +65,7 @@ namespace NKikimr::NStLog { auto& ctx = (CTX); \ const auto priority = [&]{ using namespace NActors::NLog; return (PRIO); }(); \ const auto component = [&]{ using namespace NKikimrServices; using namespace NActorsServices; return (COMP); }(); \ - if (IS_LOG_PRIORITY_ENABLED(ctx, priority, component)) { \ + if (IS_LOG_PRIORITY_ENABLED(priority, component)) { \ STLOG_STREAM(__stream, 0, __VA_ARGS__); \ ::NActors::MemLogAdapter(ctx, priority, component, __stream.Str()); \ }; \ @@ -78,7 +78,7 @@ namespace NKikimr::NStLog { auto& ctx = (CTX); \ const auto priority = [&]{ using namespace NActors::NLog; return (PRIO); }(); \ const auto component = [&]{ using namespace NKikimrServices; using namespace NActorsServices; return (COMP); }(); \ - if (IS_LOG_PRIORITY_ENABLED(ctx, priority, component)) { \ + if (IS_LOG_PRIORITY_ENABLED(priority, component)) { \ STLOG_STREAM(__stream, 1, __VA_ARGS__); \ ::NActors::MemLogAdapter(ctx, priority, component, __stream.Str()); \ }; \ |