diff options
| author | ivanmorozov <[email protected]> | 2023-05-07 15:23:49 +0300 | 
|---|---|---|
| committer | ivanmorozov <[email protected]> | 2023-05-07 15:23:49 +0300 | 
| commit | 48838be4e225474e15657f8f6f68c404432f0ec0 (patch) | |
| tree | b75f42a88805f0804542d255bd9a88636a45b2c4 | |
| parent | 20960c20bb04247a8c375589d9d0cbcb302e887f (diff) | |
unify actor-system-logs for non-actor-system cases
| -rw-r--r-- | library/cpp/actors/core/CMakeLists.darwin-x86_64.txt | 11 | ||||
| -rw-r--r-- | library/cpp/actors/core/CMakeLists.linux-aarch64.txt | 11 | ||||
| -rw-r--r-- | library/cpp/actors/core/CMakeLists.linux-x86_64.txt | 11 | ||||
| -rw-r--r-- | library/cpp/actors/core/CMakeLists.windows-x86_64.txt | 11 | ||||
| -rw-r--r-- | library/cpp/actors/core/log.h | 114 | ||||
| -rw-r--r-- | library/cpp/actors/core/log_iface.h | 20 | 
6 files changed, 115 insertions, 63 deletions
diff --git a/library/cpp/actors/core/CMakeLists.darwin-x86_64.txt b/library/cpp/actors/core/CMakeLists.darwin-x86_64.txt index fa5d64256ec..747c10d87d2 100644 --- a/library/cpp/actors/core/CMakeLists.darwin-x86_64.txt +++ b/library/cpp/actors/core/CMakeLists.darwin-x86_64.txt @@ -19,6 +19,12 @@ get_built_tool_path(    tools/enum_parser/enum_parser    enum_parser  ) +get_built_tool_path( +  TOOL_enum_parser_bin +  TOOL_enum_parser_dependency +  tools/enum_parser/enum_parser +  enum_parser +)  add_library(cpp-actors-core)  target_link_libraries(cpp-actors-core PUBLIC @@ -85,3 +91,8 @@ generate_enum_serilization(cpp-actors-core    INCLUDE_HEADERS    library/cpp/actors/core/actor.h  ) +generate_enum_serilization(cpp-actors-core +  ${CMAKE_SOURCE_DIR}/library/cpp/actors/core/log_iface.h +  INCLUDE_HEADERS +  library/cpp/actors/core/log_iface.h +) diff --git a/library/cpp/actors/core/CMakeLists.linux-aarch64.txt b/library/cpp/actors/core/CMakeLists.linux-aarch64.txt index 5d93da10cdc..4aa2f487056 100644 --- a/library/cpp/actors/core/CMakeLists.linux-aarch64.txt +++ b/library/cpp/actors/core/CMakeLists.linux-aarch64.txt @@ -19,6 +19,12 @@ get_built_tool_path(    tools/enum_parser/enum_parser    enum_parser  ) +get_built_tool_path( +  TOOL_enum_parser_bin +  TOOL_enum_parser_dependency +  tools/enum_parser/enum_parser +  enum_parser +)  add_library(cpp-actors-core)  target_link_libraries(cpp-actors-core PUBLIC @@ -86,3 +92,8 @@ generate_enum_serilization(cpp-actors-core    INCLUDE_HEADERS    library/cpp/actors/core/actor.h  ) +generate_enum_serilization(cpp-actors-core +  ${CMAKE_SOURCE_DIR}/library/cpp/actors/core/log_iface.h +  INCLUDE_HEADERS +  library/cpp/actors/core/log_iface.h +) diff --git a/library/cpp/actors/core/CMakeLists.linux-x86_64.txt b/library/cpp/actors/core/CMakeLists.linux-x86_64.txt index 5d93da10cdc..4aa2f487056 100644 --- a/library/cpp/actors/core/CMakeLists.linux-x86_64.txt +++ b/library/cpp/actors/core/CMakeLists.linux-x86_64.txt @@ -19,6 +19,12 @@ get_built_tool_path(    tools/enum_parser/enum_parser    enum_parser  ) +get_built_tool_path( +  TOOL_enum_parser_bin +  TOOL_enum_parser_dependency +  tools/enum_parser/enum_parser +  enum_parser +)  add_library(cpp-actors-core)  target_link_libraries(cpp-actors-core PUBLIC @@ -86,3 +92,8 @@ generate_enum_serilization(cpp-actors-core    INCLUDE_HEADERS    library/cpp/actors/core/actor.h  ) +generate_enum_serilization(cpp-actors-core +  ${CMAKE_SOURCE_DIR}/library/cpp/actors/core/log_iface.h +  INCLUDE_HEADERS +  library/cpp/actors/core/log_iface.h +) diff --git a/library/cpp/actors/core/CMakeLists.windows-x86_64.txt b/library/cpp/actors/core/CMakeLists.windows-x86_64.txt index fa5d64256ec..747c10d87d2 100644 --- a/library/cpp/actors/core/CMakeLists.windows-x86_64.txt +++ b/library/cpp/actors/core/CMakeLists.windows-x86_64.txt @@ -19,6 +19,12 @@ get_built_tool_path(    tools/enum_parser/enum_parser    enum_parser  ) +get_built_tool_path( +  TOOL_enum_parser_bin +  TOOL_enum_parser_dependency +  tools/enum_parser/enum_parser +  enum_parser +)  add_library(cpp-actors-core)  target_link_libraries(cpp-actors-core PUBLIC @@ -85,3 +91,8 @@ generate_enum_serilization(cpp-actors-core    INCLUDE_HEADERS    library/cpp/actors/core/actor.h  ) +generate_enum_serilization(cpp-actors-core +  ${CMAKE_SOURCE_DIR}/library/cpp/actors/core/log_iface.h +  INCLUDE_HEADERS +  library/cpp/actors/core/log_iface.h +) diff --git a/library/cpp/actors/core/log.h b/library/cpp/actors/core/log.h index f9bbdbe914e..f58621a58d0 100644 --- a/library/cpp/actors/core/log.h +++ b/library/cpp/actors/core/log.h @@ -372,32 +372,36 @@ namespace NActors {      class TRecordWriter: public TStringBuilder {      private: -        const TActorContext& ActorContext; +        const TActorContext* ActorContext = nullptr;          ::NActors::NLog::EPriority Priority = ::NActors::NLog::EPriority::PRI_INFO;          ::NActors::NLog::EComponent Component = 0;      public: -        TRecordWriter(const TActorContext& actorContext, ::NActors::NLog::EPriority priority, ::NActors::NLog::EComponent component) -            : ActorContext(actorContext) +        TRecordWriter(::NActors::NLog::EPriority priority, ::NActors::NLog::EComponent component) +            : ActorContext(NActors::TlsActivationContext ? &NActors::TlsActivationContext->AsActorContext() : nullptr)              , Priority(priority)              , Component(component) {          }          ~TRecordWriter() { -            ::NActors::MemLogAdapter(ActorContext, Priority, Component, *this); +            if (ActorContext) { +                ::NActors::MemLogAdapter(*ActorContext, Priority, Component, *this); +            } else { +                Cerr << "FALLBACK_ACTOR_LOGGING;priority=" << Priority << ";component=" << Component << ";" << static_cast<const TStringBuilder&>(*this) << Endl; +            }          }      };      class TFormattedRecordWriter {      private: -        const TActorContext& ActorContext; +        const TActorContext* ActorContext = nullptr;          ::NActors::NLog::EPriority Priority = ::NActors::NLog::EPriority::PRI_INFO;          ::NActors::NLog::EComponent Component = 0;          TStringBuilder Builder;      public: -        TFormattedRecordWriter(const TActorContext& actorContext, ::NActors::NLog::EPriority priority, ::NActors::NLog::EComponent component) -            : ActorContext(actorContext) +        TFormattedRecordWriter(::NActors::NLog::EPriority priority, ::NActors::NLog::EComponent component) +            : ActorContext(NActors::TlsActivationContext ? &NActors::TlsActivationContext->AsActorContext() : nullptr)              , Priority(priority)              , Component(component) { @@ -410,61 +414,65 @@ namespace NActors {          }          ~TFormattedRecordWriter() { -            ::NActors::MemLogAdapter(ActorContext, Priority, Component, Builder); +            if (ActorContext) { +                ::NActors::MemLogAdapter(*ActorContext, Priority, Component, Builder); +            } else { +                Cerr << "FALLBACK_ACTOR_LOGGING;priority=" << Priority << ";component=" << Component << ";" << Builder << Endl; +            }          }      };  } -#define ACTORS_FORMATTED_LOG(actorCtxOrSystem, mPriority, mComponent) \ -    if (!IS_LOG_PRIORITY_ENABLED(actorCtxOrSystem, mPriority, mComponent));\ +#define ACTORS_FORMATTED_LOG(mPriority, mComponent) \ +    if (NActors::TlsActivationContext && !IS_LOG_PRIORITY_ENABLED(NActors::TActivationContext::AsActorContext(), mPriority, mComponent));\          else NActors::TFormattedRecordWriter(\ -            actorCtxOrSystem, static_cast<::NActors::NLog::EPriority>(mPriority), static_cast<::NActors::NLog::EComponent>(mComponent)\ +            static_cast<::NActors::NLog::EPriority>(mPriority), static_cast<::NActors::NLog::EComponent>(mComponent)\              )("fline", TStringBuilder() << TStringBuf(__FILE__).RAfter(LOCSLASH_C) << ":" << __LINE__) -#define ACTORS_LOG_STREAM(actorCtxOrSystem, mPriority, mComponent) \ -    if (!IS_LOG_PRIORITY_ENABLED(actorCtxOrSystem, mPriority, mComponent));\ +#define ACTORS_LOG_STREAM(mPriority, mComponent) \ +    if (NActors::TlsActivationContext && !IS_LOG_PRIORITY_ENABLED(NActors::TActivationContext::AsActorContext(), mPriority, mComponent));\          else NActors::TRecordWriter(\ -            actorCtxOrSystem, static_cast<::NActors::NLog::EPriority>(mPriority), static_cast<::NActors::NLog::EComponent>(mComponent)\ +            static_cast<::NActors::NLog::EPriority>(mPriority), static_cast<::NActors::NLog::EComponent>(mComponent)\              ) << TStringBuf(__FILE__).RAfter(LOCSLASH_C) << ":" << __LINE__ << " :" -#define ACTORS_LOG_STREAM_TRACE(actorCtxOrSystem, component) ACTORS_LOG_STREAM(actorCtxOrSystem, NActors::NLog::PRI_TRACE, component) -#define ACTORS_LOG_STREAM_DEBUG(actorCtxOrSystem, component) ACTORS_LOG_STREAM(actorCtxOrSystem, NActors::NLog::PRI_DEBUG, component) -#define ACTORS_LOG_STREAM_INFO(actorCtxOrSystem, component) ACTORS_LOG_STREAM(actorCtxOrSystem, NActors::NLog::PRI_INFO, component) -#define ACTORS_LOG_STREAM_NOTICE(actorCtxOrSystem, component) ACTORS_LOG_STREAM(actorCtxOrSystem, NActors::NLog::PRI_NOTICE, component) -#define ACTORS_LOG_STREAM_WARN(actorCtxOrSystem, component) ACTORS_LOG_STREAM(actorCtxOrSystem, NActors::NLog::PRI_WARN, component) -#define ACTORS_LOG_STREAM_ERROR(actorCtxOrSystem, component) ACTORS_LOG_STREAM(actorCtxOrSystem, NActors::NLog::PRI_ERROR, component) -#define ACTORS_LOG_STREAM_CRIT(actorCtxOrSystem, component) ACTORS_LOG_STREAM(actorCtxOrSystem, NActors::NLog::PRI_CRIT, component) -#define ACTORS_LOG_STREAM_ALERT(actorCtxOrSystem, component) ACTORS_LOG_STREAM(actorCtxOrSystem, NActors::NLog::PRI_ALERT, component) -#define ACTORS_LOG_STREAM_EMERG(actorCtxOrSystem, component) ACTORS_LOG_STREAM(actorCtxOrSystem, NActors::NLog::PRI_EMERG, component) - -#define ALS_TRACE(component) ACTORS_LOG_STREAM_TRACE(NActors::TActivationContext::AsActorContext(), component) -#define ALS_DEBUG(component) ACTORS_LOG_STREAM_DEBUG(NActors::TActivationContext::AsActorContext(), component) -#define ALS_INFO(component) ACTORS_LOG_STREAM_INFO(NActors::TActivationContext::AsActorContext(), component) -#define ALS_NOTICE(component) ACTORS_LOG_STREAM_NOTICE(NActors::TActivationContext::AsActorContext(), component) -#define ALS_WARN(component) ACTORS_LOG_STREAM_WARN(NActors::TActivationContext::AsActorContext(), component) -#define ALS_ERROR(component) ACTORS_LOG_STREAM_ERROR(NActors::TActivationContext::AsActorContext(), component) -#define ALS_CRIT(component) ACTORS_LOG_STREAM_CRIT(NActors::TActivationContext::AsActorContext(), component) -#define ALS_ALERT(component) ACTORS_LOG_STREAM_ALERT(NActors::TActivationContext::AsActorContext(), component) -#define ALS_EMERG(component) ACTORS_LOG_STREAM_EMERG(NActors::TActivationContext::AsActorContext(), component) - -#define ACTORS_FORMATTED_LOG_TRACE(actorCtxOrSystem, component) ACTORS_FORMATTED_LOG(actorCtxOrSystem, NActors::NLog::PRI_TRACE, component) -#define ACTORS_FORMATTED_LOG_DEBUG(actorCtxOrSystem, component) ACTORS_FORMATTED_LOG(actorCtxOrSystem, NActors::NLog::PRI_DEBUG, component) -#define ACTORS_FORMATTED_LOG_INFO(actorCtxOrSystem, component) ACTORS_FORMATTED_LOG(actorCtxOrSystem, NActors::NLog::PRI_INFO, component) -#define ACTORS_FORMATTED_LOG_NOTICE(actorCtxOrSystem, component) ACTORS_FORMATTED_LOG(actorCtxOrSystem, NActors::NLog::PRI_NOTICE, component) -#define ACTORS_FORMATTED_LOG_WARN(actorCtxOrSystem, component) ACTORS_FORMATTED_LOG(actorCtxOrSystem, NActors::NLog::PRI_WARN, component) -#define ACTORS_FORMATTED_LOG_ERROR(actorCtxOrSystem, component) ACTORS_FORMATTED_LOG(actorCtxOrSystem, NActors::NLog::PRI_ERROR, component) -#define ACTORS_FORMATTED_LOG_CRIT(actorCtxOrSystem, component) ACTORS_FORMATTED_LOG(actorCtxOrSystem, NActors::NLog::PRI_CRIT, component) -#define ACTORS_FORMATTED_LOG_ALERT(actorCtxOrSystem, component) ACTORS_FORMATTED_LOG(actorCtxOrSystem, NActors::NLog::PRI_ALERT, component) -#define ACTORS_FORMATTED_LOG_EMERG(actorCtxOrSystem, component) ACTORS_FORMATTED_LOG(actorCtxOrSystem, NActors::NLog::PRI_EMERG, component) - -#define AFL_TRACE(component) ACTORS_FORMATTED_LOG_TRACE(NActors::TActivationContext::AsActorContext(), component) -#define AFL_DEBUG(component) ACTORS_FORMATTED_LOG_DEBUG(NActors::TActivationContext::AsActorContext(), component) -#define AFL_INFO(component) ACTORS_FORMATTED_LOG_INFO(NActors::TActivationContext::AsActorContext(), component) -#define AFL_NOTICE(component) ACTORS_FORMATTED_LOG_NOTICE(NActors::TActivationContext::AsActorContext(), component) -#define AFL_WARN(component) ACTORS_FORMATTED_LOG_WARN(NActors::TActivationContext::AsActorContext(), component) -#define AFL_ERROR(component) ACTORS_FORMATTED_LOG_ERROR(NActors::TActivationContext::AsActorContext(), component) -#define AFL_CRIT(component) ACTORS_FORMATTED_LOG_CRIT(NActors::TActivationContext::AsActorContext(), component) -#define AFL_ALERT(component) ACTORS_FORMATTED_LOG_ALERT(NActors::TActivationContext::AsActorContext(), component) -#define AFL_EMERG(component) ACTORS_FORMATTED_LOG_EMERG(NActors::TActivationContext::AsActorContext(), component) +#define ACTORS_LOG_STREAM_TRACE(component) ACTORS_LOG_STREAM(NActors::NLog::PRI_TRACE, component) +#define ACTORS_LOG_STREAM_DEBUG(component) ACTORS_LOG_STREAM(NActors::NLog::PRI_DEBUG, component) +#define ACTORS_LOG_STREAM_INFO(component) ACTORS_LOG_STREAM(NActors::NLog::PRI_INFO, component) +#define ACTORS_LOG_STREAM_NOTICE(component) ACTORS_LOG_STREAM(NActors::NLog::PRI_NOTICE, component) +#define ACTORS_LOG_STREAM_WARN(component) ACTORS_LOG_STREAM(NActors::NLog::PRI_WARN, component) +#define ACTORS_LOG_STREAM_ERROR(component) ACTORS_LOG_STREAM(NActors::NLog::PRI_ERROR, component) +#define ACTORS_LOG_STREAM_CRIT(component) ACTORS_LOG_STREAM(NActors::NLog::PRI_CRIT, component) +#define ACTORS_LOG_STREAM_ALERT(component) ACTORS_LOG_STREAM(NActors::NLog::PRI_ALERT, component) +#define ACTORS_LOG_STREAM_EMERG(component) ACTORS_LOG_STREAM(NActors::NLog::PRI_EMERG, component) + +#define ALS_TRACE(component) ACTORS_LOG_STREAM_TRACE(component) +#define ALS_DEBUG(component) ACTORS_LOG_STREAM_DEBUG(component) +#define ALS_INFO(component) ACTORS_LOG_STREAM_INFO(component) +#define ALS_NOTICE(component) ACTORS_LOG_STREAM_NOTICE(component) +#define ALS_WARN(component) ACTORS_LOG_STREAM_WARN(component) +#define ALS_ERROR(component) ACTORS_LOG_STREAM_ERROR(component) +#define ALS_CRIT(component) ACTORS_LOG_STREAM_CRIT(component) +#define ALS_ALERT(component) ACTORS_LOG_STREAM_ALERT(component) +#define ALS_EMERG(component) ACTORS_LOG_STREAM_EMERG(component) + +#define ACTORS_FORMATTED_LOG_TRACE(component) ACTORS_FORMATTED_LOG(NActors::NLog::PRI_TRACE, component) +#define ACTORS_FORMATTED_LOG_DEBUG(component) ACTORS_FORMATTED_LOG(NActors::NLog::PRI_DEBUG, component) +#define ACTORS_FORMATTED_LOG_INFO(component) ACTORS_FORMATTED_LOG(NActors::NLog::PRI_INFO, component) +#define ACTORS_FORMATTED_LOG_NOTICE(component) ACTORS_FORMATTED_LOG(NActors::NLog::PRI_NOTICE, component) +#define ACTORS_FORMATTED_LOG_WARN(component) ACTORS_FORMATTED_LOG(NActors::NLog::PRI_WARN, component) +#define ACTORS_FORMATTED_LOG_ERROR(component) ACTORS_FORMATTED_LOG(NActors::NLog::PRI_ERROR, component) +#define ACTORS_FORMATTED_LOG_CRIT(component) ACTORS_FORMATTED_LOG(NActors::NLog::PRI_CRIT, component) +#define ACTORS_FORMATTED_LOG_ALERT(component) ACTORS_FORMATTED_LOG(NActors::NLog::PRI_ALERT, component) +#define ACTORS_FORMATTED_LOG_EMERG(component) ACTORS_FORMATTED_LOG(NActors::NLog::PRI_EMERG, component) + +#define AFL_TRACE(component) ACTORS_FORMATTED_LOG_TRACE(component) +#define AFL_DEBUG(component) ACTORS_FORMATTED_LOG_DEBUG(component) +#define AFL_INFO(component) ACTORS_FORMATTED_LOG_INFO(component) +#define AFL_NOTICE(component) ACTORS_FORMATTED_LOG_NOTICE(component) +#define AFL_WARN(component) ACTORS_FORMATTED_LOG_WARN(component) +#define AFL_ERROR(component) ACTORS_FORMATTED_LOG_ERROR(component) +#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/library/cpp/actors/core/log_iface.h b/library/cpp/actors/core/log_iface.h index d929794f4a4..b0195f55812 100644 --- a/library/cpp/actors/core/log_iface.h +++ b/library/cpp/actors/core/log_iface.h @@ -8,15 +8,15 @@ namespace NActors {          using EComponent = int;          enum EPriority : ui16 { // migrate it to EPrio whenever possible -            PRI_EMERG, -            PRI_ALERT, -            PRI_CRIT, -            PRI_ERROR, -            PRI_WARN, -            PRI_NOTICE, -            PRI_INFO, -            PRI_DEBUG, -            PRI_TRACE +            PRI_EMERG /* "EMERG" */, +            PRI_ALERT /* "ALERT" */, +            PRI_CRIT /* "CRIT" */, +            PRI_ERROR /* "ERROR" */, +            PRI_WARN /* "WARN" */, +            PRI_NOTICE /* "NOTICE" */, +            PRI_INFO /* "INFO" */, +            PRI_DEBUG /* "DEBUG" */, +            PRI_TRACE /* "TRACE" */          };          enum class EPrio : ui16 { @@ -78,7 +78,7 @@ namespace NActors {          struct TEvLogBufferLevelListTag {};          class TEvLog -            : public TEventLocal<TEvLog, int(EEv::Log)>  +            : public TEventLocal<TEvLog, int(EEv::Log)>              , public TIntrusiveListItem<TEvLog, TEvLogBufferMainListTag>              , public TIntrusiveListItem<TEvLog, TEvLogBufferLevelListTag>          {  | 
