Skip to content

Commit

Permalink
junhao review
Browse files Browse the repository at this point in the history
  • Loading branch information
davemarco committed Dec 9, 2024
1 parent 90b977f commit 8cc73d0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
15 changes: 6 additions & 9 deletions src/clp_ffi_js/ir/StructuredIrUnitHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <clp/ffi/KeyValuePairLogEvent.hpp>
#include <clp/ffi/SchemaTree.hpp>
#include <clp/ffi/Value.hpp>
#include <clp/ir/types.hpp>
#include <clp/time_types.hpp>
#include <emscripten/val.h>
#include <spdlog/spdlog.h>
Expand Down Expand Up @@ -102,13 +103,10 @@ auto StructuredIrUnitHandler::get_log_level(
if (false == m_log_level_node_id.has_value()) {
return log_level;
}

auto const& log_level_pair{id_value_pairs.at(m_log_level_node_id.value())};

if (false == log_level_pair.has_value()) {
return log_level;
}

if (log_level_pair->is<std::string>()) {
auto const& log_level_node_value = log_level_pair.value().get_immutable_view<std::string>();
log_level = parse_log_level(log_level_node_value);
Expand All @@ -130,21 +128,20 @@ auto StructuredIrUnitHandler::get_log_level(

auto StructuredIrUnitHandler::get_timestamp(
StructuredLogEvent::NodeIdValuePairs const& id_value_pairs
) const -> clp::ffi::value_int_t {
clp::ffi::value_int_t timestamp{0};
) const -> clp::ir::epoch_time_ms_t {
clp::ir::epoch_time_ms_t timestamp{0};

if (false == m_timestamp_node_id.has_value()) {
return timestamp;
}

auto const& timestamp_pair{id_value_pairs.at(m_timestamp_node_id.value())};

if (false == timestamp_pair.has_value()) {
return timestamp;
}

if (timestamp_pair->is<clp::ffi::value_int_t>()) {
timestamp = timestamp_pair.value().get_immutable_view<clp::ffi::value_int_t>();
timestamp = static_cast<clp::ir::epoch_time_ms_t>(
timestamp_pair.value().get_immutable_view<clp::ffi::value_int_t>()
);
} else {
// TODO: Add support for parsing timestamp values of string type.
auto log_event_idx = m_deserialized_log_events->size();
Expand Down
5 changes: 3 additions & 2 deletions src/clp_ffi_js/ir/StructuredIrUnitHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <clp/ffi/KeyValuePairLogEvent.hpp>
#include <clp/ffi/SchemaTree.hpp>
#include <clp/ffi/Value.hpp>
#include <clp/ir/types.hpp>
#include <clp/time_types.hpp>

#include <clp_ffi_js/constants.hpp>
Expand Down Expand Up @@ -43,7 +44,7 @@ class StructuredIrUnitHandler {

// Methods implementing `clp::ffi::ir_stream::IrUnitHandlerInterface`.
/**
* Buffers the log event.
* Buffers the log event with filter data extracted.
* @param log_event
* @return IRErrorCode::IRErrorCode_Success
*/
Expand Down Expand Up @@ -91,7 +92,7 @@ class StructuredIrUnitHandler {
* @return Timestamp from node with id `m_timestamp_node_id`.
*/
[[nodiscard]] auto get_timestamp(StructuredLogEvent::NodeIdValuePairs const& id_value_pairs
) const -> clp::ffi::value_int_t;
) const -> clp::ir::epoch_time_ms_t;

// Variables
std::string m_log_level_key;
Expand Down
1 change: 1 addition & 0 deletions src/clp_ffi_js/ir/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ auto generic_decode_range(
}

auto const results{emscripten::val::array()};
std::string generic_event_string;

for (size_t i = begin_idx; i < end_idx; ++i) {
size_t log_event_idx{0};
Expand Down

0 comments on commit 8cc73d0

Please sign in to comment.