Easy Navigation
Loading...
Searching...
No Matches
YTSession.hpp
Go to the documentation of this file.
1// Copyright 2025 Intelligent Robotics Lab
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15
16#ifndef EASYNAV_COMMON__YTSESSION_HPP_
17#define EASYNAV_COMMON__YTSESSION_HPP_
18
19#include <algorithm>
20#include <string>
21
23
24#include "yaets/tracing.hpp"
25
26namespace easynav
27{
28
33class YTSession : public yaets::TraceSession, public Singleton<YTSession>
34{
35public:
42 explicit YTSession(const std::string & ros_namespace = "")
43 : yaets::TraceSession(log_path(ros_namespace))
44 {}
45
47 {
48 stop();
49 }
50
52
53private:
60 static std::string log_path(const std::string & ros_namespace)
61 {
62 std::string ns = ros_namespace;
63 while (!ns.empty() && ns.front() == '/') {
64 ns.erase(ns.begin());
65 }
66 while (!ns.empty() && ns.back() == '/') {
67 ns.pop_back();
68 }
69 std::replace(ns.begin(), ns.end(), '/', '_');
70
71 if (ns.empty()) {
72 return "/tmp/easynav.log";
73 }
74 return "/tmp/easynav_" + ns + ".log";
75 }
76};
77
78} // namespace easynav
79
80#ifdef EASYNAV_DEBUG_WITH_YAETS
81 #define EASYNAV_TRACE_EVENT TRACE_EVENT(easynav::YTSession::get())
82 #define EASYNAV_TRACE_NAMED_EVENT(name) yaets::TraceGuard guard(easynav::YTSession::get(), name);
83#else
84 #define EASYNAV_TRACE_EVENT ((void)0)
85 #define EASYNAV_TRACE_NAMED_EVENT(name) ((void)0)
86#endif
87
88
89#endif // EASYNAV_COMMON__YTSESSION_HPP_
#define SINGLETON_DEFINITIONS(ClassName)
Definition Singleton.hpp:82
A Yaets Tracing Session.
Definition YTSession.hpp:34
YTSession(const std::string &ros_namespace="")
Definition YTSession.hpp:42
~YTSession()
Definition YTSession.hpp:46
Definition CircularBuffer.hpp:24