LCOV - code coverage report
Current view: top level - source/extensions/access_loggers/wasm - wasm_access_log_impl.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 19 0.0 %
Date: 2024-01-05 06:35:25 Functions: 0 3 0.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "envoy/access_log/access_log.h"
       4             : 
       5             : #include "source/common/common/logger.h"
       6             : #include "source/extensions/common/wasm/wasm.h"
       7             : 
       8             : namespace Envoy {
       9             : namespace Extensions {
      10             : namespace AccessLoggers {
      11             : namespace Wasm {
      12             : 
      13             : using Common::Wasm::PluginHandleSharedPtrThreadLocal;
      14             : using Envoy::Extensions::Common::Wasm::PluginSharedPtr;
      15             : 
      16             : class WasmAccessLog : public AccessLog::Instance {
      17             : public:
      18             :   WasmAccessLog(const PluginSharedPtr& plugin,
      19             :                 ThreadLocal::TypedSlotPtr<PluginHandleSharedPtrThreadLocal>&& tls_slot,
      20             :                 AccessLog::FilterPtr filter)
      21           0 :       : plugin_(plugin), tls_slot_(std::move(tls_slot)), filter_(std::move(filter)) {}
      22             : 
      23             :   void log(const Formatter::HttpFormatterContext& log_context,
      24           0 :            const StreamInfo::StreamInfo& stream_info) override {
      25           0 :     if (filter_) {
      26           0 :       if (!filter_->evaluate(log_context, stream_info)) {
      27           0 :         return;
      28           0 :       }
      29           0 :     }
      30             : 
      31           0 :     if (tls_slot_ != nullptr) {
      32           0 :       if (auto handle = tls_slot_->get()->handle(); handle != nullptr) {
      33           0 :         if (handle->wasmHandle()) {
      34           0 :           handle->wasmHandle()->wasm()->log(plugin_, log_context, stream_info);
      35           0 :         }
      36           0 :       }
      37           0 :     }
      38           0 :   }
      39             : 
      40           0 :   void setTlsSlot(ThreadLocal::TypedSlotPtr<PluginHandleSharedPtrThreadLocal>&& tls_slot) {
      41           0 :     ASSERT(tls_slot_ == nullptr);
      42           0 :     tls_slot_ = std::move(tls_slot);
      43           0 :   }
      44             : 
      45             : private:
      46             :   PluginSharedPtr plugin_;
      47             :   ThreadLocal::TypedSlotPtr<PluginHandleSharedPtrThreadLocal> tls_slot_;
      48             :   AccessLog::FilterPtr filter_;
      49             : };
      50             : 
      51             : } // namespace Wasm
      52             : } // namespace AccessLoggers
      53             : } // namespace Extensions
      54             : } // namespace Envoy

Generated by: LCOV version 1.15