diff options
author | auzhegov <auzhegov@yandex-team.com> | 2023-02-17 14:30:19 +0300 |
---|---|---|
committer | auzhegov <auzhegov@yandex-team.com> | 2023-02-17 14:30:19 +0300 |
commit | e7f46af0fea08f462cd8492cab5aba5c0f48483d (patch) | |
tree | 3a6ef0bce2f6cc963e0e6aef8af978a8ad422c46 /library/cpp/actors | |
parent | 49a708acc9002a668fa866efccb3d752cd60ccbd (diff) | |
download | ydb-e7f46af0fea08f462cd8492cab5aba5c0f48483d.tar.gz |
Перенос yc public yq events api в oss
Initial version
Diffstat (limited to 'library/cpp/actors')
-rw-r--r-- | library/cpp/actors/CMakeLists.txt | 1 | ||||
-rw-r--r-- | library/cpp/actors/log_backend/CMakeLists.darwin.txt | 19 | ||||
-rw-r--r-- | library/cpp/actors/log_backend/CMakeLists.linux-aarch64.txt | 20 | ||||
-rw-r--r-- | library/cpp/actors/log_backend/CMakeLists.linux.txt | 20 | ||||
-rw-r--r-- | library/cpp/actors/log_backend/CMakeLists.txt | 15 | ||||
-rw-r--r-- | library/cpp/actors/log_backend/actor_log_backend.cpp | 42 | ||||
-rw-r--r-- | library/cpp/actors/log_backend/actor_log_backend.h | 20 |
7 files changed, 137 insertions, 0 deletions
diff --git a/library/cpp/actors/CMakeLists.txt b/library/cpp/actors/CMakeLists.txt index 85c57c9506..9d76935e02 100644 --- a/library/cpp/actors/CMakeLists.txt +++ b/library/cpp/actors/CMakeLists.txt @@ -12,6 +12,7 @@ add_subdirectory(dnsresolver) add_subdirectory(helpers) add_subdirectory(http) add_subdirectory(interconnect) +add_subdirectory(log_backend) add_subdirectory(memory_log) add_subdirectory(prof) add_subdirectory(protos) diff --git a/library/cpp/actors/log_backend/CMakeLists.darwin.txt b/library/cpp/actors/log_backend/CMakeLists.darwin.txt new file mode 100644 index 0000000000..2845e78e35 --- /dev/null +++ b/library/cpp/actors/log_backend/CMakeLists.darwin.txt @@ -0,0 +1,19 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(cpp-actors-log_backend) +target_link_libraries(cpp-actors-log_backend PUBLIC + contrib-libs-cxxsupp + yutil + cpp-actors-core + library-cpp-logger +) +target_sources(cpp-actors-log_backend PRIVATE + ${CMAKE_SOURCE_DIR}/library/cpp/actors/log_backend/actor_log_backend.cpp +) diff --git a/library/cpp/actors/log_backend/CMakeLists.linux-aarch64.txt b/library/cpp/actors/log_backend/CMakeLists.linux-aarch64.txt new file mode 100644 index 0000000000..15786d6c74 --- /dev/null +++ b/library/cpp/actors/log_backend/CMakeLists.linux-aarch64.txt @@ -0,0 +1,20 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(cpp-actors-log_backend) +target_link_libraries(cpp-actors-log_backend PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + cpp-actors-core + library-cpp-logger +) +target_sources(cpp-actors-log_backend PRIVATE + ${CMAKE_SOURCE_DIR}/library/cpp/actors/log_backend/actor_log_backend.cpp +) diff --git a/library/cpp/actors/log_backend/CMakeLists.linux.txt b/library/cpp/actors/log_backend/CMakeLists.linux.txt new file mode 100644 index 0000000000..15786d6c74 --- /dev/null +++ b/library/cpp/actors/log_backend/CMakeLists.linux.txt @@ -0,0 +1,20 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + + +add_library(cpp-actors-log_backend) +target_link_libraries(cpp-actors-log_backend PUBLIC + contrib-libs-linux-headers + contrib-libs-cxxsupp + yutil + cpp-actors-core + library-cpp-logger +) +target_sources(cpp-actors-log_backend PRIVATE + ${CMAKE_SOURCE_DIR}/library/cpp/actors/log_backend/actor_log_backend.cpp +) diff --git a/library/cpp/actors/log_backend/CMakeLists.txt b/library/cpp/actors/log_backend/CMakeLists.txt new file mode 100644 index 0000000000..5bb4faffb4 --- /dev/null +++ b/library/cpp/actors/log_backend/CMakeLists.txt @@ -0,0 +1,15 @@ + +# This file was generated by the build system used internally in the Yandex monorepo. +# Only simple modifications are allowed (adding source-files to targets, adding simple properties +# like target_include_directories). These modifications will be ported to original +# ya.make files by maintainers. Any complex modifications which can't be ported back to the +# original buildsystem will not be accepted. + + +if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" AND UNIX AND NOT APPLE AND NOT ANDROID) + include(CMakeLists.linux-aarch64.txt) +elseif (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + include(CMakeLists.darwin.txt) +elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND UNIX AND NOT APPLE AND NOT ANDROID) + include(CMakeLists.linux.txt) +endif() diff --git a/library/cpp/actors/log_backend/actor_log_backend.cpp b/library/cpp/actors/log_backend/actor_log_backend.cpp new file mode 100644 index 0000000000..a6fdd20c7b --- /dev/null +++ b/library/cpp/actors/log_backend/actor_log_backend.cpp @@ -0,0 +1,42 @@ +#include "actor_log_backend.h" + +#include <library/cpp/actors/core/actorsystem.h> +#include <library/cpp/actors/core/log.h> +#include <library/cpp/logger/record.h> + +namespace { + +NActors::NLog::EPriority GetActorLogPriority(ELogPriority priority) { + switch (priority) { + case TLOG_EMERG: + return NActors::NLog::PRI_EMERG; + case TLOG_ALERT: + return NActors::NLog::PRI_ALERT; + case TLOG_CRIT: + return NActors::NLog::PRI_CRIT; + case TLOG_ERR: + return NActors::NLog::PRI_ERROR; + case TLOG_WARNING: + return NActors::NLog::PRI_WARN; + case TLOG_NOTICE: + return NActors::NLog::PRI_NOTICE; + case TLOG_INFO: + return NActors::NLog::PRI_INFO; + case TLOG_DEBUG: + return NActors::NLog::PRI_DEBUG; + default: + return NActors::NLog::PRI_TRACE; + } +} + +} + +TActorLogBackend::TActorLogBackend(NActors::TActorSystem* actorSystem, int logComponent) + : ActorSystem(actorSystem) + , LogComponent(logComponent) +{ +} + +void TActorLogBackend::WriteData(const TLogRecord& rec) { + LOG_LOG(*ActorSystem, GetActorLogPriority(rec.Priority), LogComponent, TString(rec.Data, rec.Len)); +} diff --git a/library/cpp/actors/log_backend/actor_log_backend.h b/library/cpp/actors/log_backend/actor_log_backend.h new file mode 100644 index 0000000000..a51427d498 --- /dev/null +++ b/library/cpp/actors/log_backend/actor_log_backend.h @@ -0,0 +1,20 @@ +#pragma once +#include <library/cpp/logger/backend.h> + +namespace NActors { +class TActorSystem; +} // namespace NActors + +class TActorLogBackend : public TLogBackend { +public: + TActorLogBackend(NActors::TActorSystem* actorSystem, int logComponent); + + void WriteData(const TLogRecord& rec) override; + + void ReopenLog() override { + } + +private: + NActors::TActorSystem* const ActorSystem; + const int LogComponent; +}; |