aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorauzhegov <auzhegov@yandex-team.com>2023-02-17 14:30:19 +0300
committerauzhegov <auzhegov@yandex-team.com>2023-02-17 14:30:19 +0300
commite7f46af0fea08f462cd8492cab5aba5c0f48483d (patch)
tree3a6ef0bce2f6cc963e0e6aef8af978a8ad422c46 /library
parent49a708acc9002a668fa866efccb3d752cd60ccbd (diff)
downloadydb-e7f46af0fea08f462cd8492cab5aba5c0f48483d.tar.gz
Перенос yc public yq events api в oss
Initial version
Diffstat (limited to 'library')
-rw-r--r--library/cpp/actors/CMakeLists.txt1
-rw-r--r--library/cpp/actors/log_backend/CMakeLists.darwin.txt19
-rw-r--r--library/cpp/actors/log_backend/CMakeLists.linux-aarch64.txt20
-rw-r--r--library/cpp/actors/log_backend/CMakeLists.linux.txt20
-rw-r--r--library/cpp/actors/log_backend/CMakeLists.txt15
-rw-r--r--library/cpp/actors/log_backend/actor_log_backend.cpp42
-rw-r--r--library/cpp/actors/log_backend/actor_log_backend.h20
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;
+};