Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e6bc62e

Browse files
committed
1 parent 81833cf commit e6bc62e

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

src/loggers/bt_minitrace_logger.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ MinitraceLogger::~MinitraceLogger()
2727
ref_count = false;
2828
}
2929

30+
const char* toConstStr(NodeType type)
31+
{
32+
switch (type)
33+
{
34+
case NodeType::ACTION:
35+
return "Action";
36+
case NodeType::CONDITION:
37+
return "Condition";
38+
case NodeType::DECORATOR:
39+
return "Decorator";
40+
case NodeType::CONTROL:
41+
return "Control";
42+
case NodeType::SUBTREE:
43+
return "SubTree";
44+
default:
45+
return "Undefined";
46+
}
47+
}
48+
3049
void MinitraceLogger::callback(Duration /*timestamp*/,
3150
const TreeNode& node, NodeStatus prev_status,
3251
NodeStatus status)
@@ -35,20 +54,20 @@ void MinitraceLogger::callback(Duration /*timestamp*/,
3554

3655
const bool statusCompleted = (status == NodeStatus::SUCCESS || status == NodeStatus::FAILURE);
3756

38-
const std::string& category = toStr(node.type());
57+
const char* category = toConstStr(node.type());
3958
const char* name = node.name().c_str();
4059

4160
if (prev_status == NodeStatus::IDLE && statusCompleted)
4261
{
43-
MTR_INSTANT(category.c_str(), name);
62+
MTR_INSTANT(category, name);
4463
}
4564
else if (status == NodeStatus::RUNNING)
4665
{
47-
MTR_BEGIN(category.c_str(), name);
66+
MTR_BEGIN(category, name);
4867
}
4968
else if (prev_status == NodeStatus::RUNNING && statusCompleted)
5069
{
51-
MTR_END(category.c_str(), name);
70+
MTR_END(category, name);
5271
}
5372
}
5473

0 commit comments

Comments
 (0)