Skip to content

Commit

Permalink
fix issue #834: enable minitrace
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Jun 18, 2024
1 parent bcceae7 commit 38a15d3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ endif()

add_subdirectory(3rdparty/lexy)

add_library(minitrace STATIC 3rdparty/minitrace/minitrace.cpp)
target_compile_definitions(minitrace PRIVATE MTR_ENABLED=True)
set_property(TARGET minitrace PROPERTY POSITION_INDEPENDENT_CODE ON)

list(APPEND BT_SOURCE
src/action_node.cpp
src/basic_types.cpp
Expand Down Expand Up @@ -124,7 +128,6 @@ list(APPEND BT_SOURCE
src/loggers/bt_observer.cpp

3rdparty/tinyxml2/tinyxml2.cpp
3rdparty/minitrace/minitrace.cpp
)


Expand Down Expand Up @@ -163,6 +166,7 @@ target_link_libraries(${BTCPP_LIBRARY}
Threads::Threads
${CMAKE_DL_LIBS}
$<BUILD_INTERFACE:foonathan::lexy>
minitrace
PUBLIC
${BTCPP_EXTRA_LIBRARIES}
)
Expand Down
2 changes: 2 additions & 0 deletions examples/t11_groot_howto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "behaviortree_cpp/loggers/groot2_publisher.h"
#include "behaviortree_cpp/xml_parsing.h"
#include "behaviortree_cpp/json_export.h"
#include "behaviortree_cpp/loggers/bt_minitrace_logger.h"

/** We are using the same example in Tutorial 5,
* But this time we also show how to connect
Expand Down Expand Up @@ -120,6 +121,7 @@ int main()

// Logging with lightweight serialization
BT::FileLogger2 logger2(tree, "t12_logger2.btlog");
BT::MinitraceLogger minilog(tree, "minitrace.json");

while(1)
{
Expand Down
6 changes: 1 addition & 5 deletions include/behaviortree_cpp/loggers/bt_minitrace_logger.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#ifndef BT_MINITRACE_LOGGER_H
#define BT_MINITRACE_LOGGER_H
#pragma once

#include <cstring>
#include "behaviortree_cpp/loggers/abstract_logger.h"

namespace BT
Expand All @@ -23,5 +21,3 @@ class MinitraceLogger : public StatusChangeLogger
};

} // namespace BT

#endif // BT_MINITRACE_LOGGER_H
1 change: 1 addition & 0 deletions src/loggers/bt_minitrace_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void MinitraceLogger::callback(Duration /*timestamp*/, const TreeNode& node,
{
MTR_END(category, name);
}
mtr_flush();
}

void MinitraceLogger::flush()
Expand Down

0 comments on commit 38a15d3

Please sign in to comment.