maskit commented on code in PR #13059:
URL: https://github.com/apache/trafficserver/pull/13059#discussion_r3061288484


##########
src/proxy/logging/CMakeLists.txt:
##########
@@ -54,6 +54,10 @@ if(BUILD_TESTING)
   target_compile_definitions(test_RolledLogDeleter PRIVATE TEST_LOG_UTILS)
   target_link_libraries(test_RolledLogDeleter tscore ts::inkevent records 
Catch2::Catch2WithMain)
   add_catch2_test(NAME test_RolledLogDeleter COMMAND test_RolledLogDeleter)
+
+  add_executable(test_LogAccess unit-tests/test_LogAccess.cc)
+  target_link_libraries(test_LogAccess ts::logging ts::http ts::inkevent 
records Catch2::Catch2WithMain)

Review Comment:
   I wonder what requires `ts::http`.



##########
src/proxy/http/TransactionLogData.cc:
##########
@@ -0,0 +1,284 @@
+/** @file
+
+  TransactionLogData implementation: populate LogData from a live HttpSM.
+
+  @section license License
+
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+ */
+
+#include "proxy/http/TransactionLogData.h"
+#include "proxy/http/HttpSM.h"
+#include "proxy/logging/LogAccess.h"
+#include "proxy/hdrs/MIME.h"
+#include "../private/SSLProxySession.h"
+
+namespace
+{
+/** Map HttpTransact::CacheWriteStatus_t to LogCacheWriteCodeType. */
+int
+convert_cache_write_code(HttpTransact::CacheWriteStatus_t t)
+{
+  switch (t) {
+  case HttpTransact::CacheWriteStatus_t::NO_WRITE:
+    return LOG_CACHE_WRITE_NONE;
+  case HttpTransact::CacheWriteStatus_t::LOCK_MISS:
+    return LOG_CACHE_WRITE_LOCK_MISSED;
+  case HttpTransact::CacheWriteStatus_t::IN_PROGRESS:
+    return LOG_CACHE_WRITE_LOCK_ABORTED;
+  case HttpTransact::CacheWriteStatus_t::ERROR:
+    return LOG_CACHE_WRITE_ERROR;
+  case HttpTransact::CacheWriteStatus_t::COMPLETE:
+    return LOG_CACHE_WRITE_COMPLETE;
+  default:
+    ink_assert(!"bad cache write code");
+    return LOG_CACHE_WRITE_NONE;
+  }
+}
+
+int
+compute_client_finish_status(HttpSM *sm)
+{
+  HttpTransact::AbortState_t cl_abort_state = sm->t_state.client_info.abort;
+  if (cl_abort_state == HttpTransact::ABORTED) {
+    if (sm->t_state.client_info.state == HttpTransact::ACTIVE_TIMEOUT ||
+        sm->t_state.client_info.state == HttpTransact::INACTIVE_TIMEOUT) {
+      return LOG_FINISH_TIMEOUT;
+    }
+    return LOG_FINISH_INTR;
+  }
+  return LOG_FINISH_FIN;
+}
+
+int
+compute_proxy_finish_status(HttpSM *sm)
+{
+  if (sm->t_state.current.server) {
+    switch (sm->t_state.current.server->state) {
+    case HttpTransact::ACTIVE_TIMEOUT:
+    case HttpTransact::INACTIVE_TIMEOUT:
+      return LOG_FINISH_TIMEOUT;
+    case HttpTransact::CONNECTION_ERROR:
+      return LOG_FINISH_INTR;
+    default:
+      if (sm->t_state.current.server->abort == HttpTransact::ABORTED) {
+        return LOG_FINISH_INTR;
+      }
+      break;
+    }
+  }
+  return LOG_FINISH_FIN;
+}
+} // end anonymous namespace
+
+TransactionLogData::TransactionLogData(HttpSM *sm) : m_http_sm(sm)
+{
+  ink_assert(sm != nullptr);
+
+  milestones = &sm->milestones;

Review Comment:
   I think we don't do these copies now, do we? Since `TransactionLogData` has 
`m_http_sm`, it should be able to provide getters.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to