srs-control 0.2.2
Loading...
Searching...
No Matches
ExitLogger.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <source_location>
5#include <spdlog/spdlog.h>
6#include <string_view>
7
8namespace srs
9{
10
12 {
13 public:
14 explicit ExitLogger(std::string_view tag = "",
15 const std::source_location& location = std::source_location::current())
16 : function_name_{ location.function_name() }
17 , tag_{ tag }
18 {
19 if (tag_.empty())
20 {
21 tag_ = std::string_view{ "function" };
22 }
23 spdlog::trace("{} {} ({})", common::exit_logger_begin, function_name_, tag_);
24 }
25
26 ExitLogger(const ExitLogger&) = default;
28 ExitLogger& operator=(const ExitLogger&) = default;
30 ~ExitLogger() { spdlog::trace("{} {} ({})", common::exit_logger_end, function_name_, tag_); }
31
32 private:
33 std::string_view function_name_;
34 std::string_view tag_;
35 };
36
37} // namespace srs
std::string_view tag_
ExitLogger(std::string_view tag="", const std::source_location &location=std::source_location::current())
ExitLogger & operator=(ExitLogger &&)=delete
std::string_view function_name_
ExitLogger & operator=(const ExitLogger &)=default
ExitLogger(const ExitLogger &)=default
ExitLogger(ExitLogger &&)=delete
constexpr auto exit_logger_begin
constexpr auto exit_logger_end