/src/ocudu/lib/e1ap/common/e1ap_logger.h
Line | Count | Source |
1 | | // SPDX-FileCopyrightText: Copyright (C) 2021-2026 Software Radio Systems Limited |
2 | | // SPDX-FileCopyrightText: Copyright (C) 2026 OCUDU contributors |
3 | | // SPDX-License-Identifier: BSD-3-Clause-Open-MPI |
4 | | // Portions of this file may implement 3GPP specifications, which may be subject to additional licensing requirements. |
5 | | |
6 | | #pragma once |
7 | | |
8 | | #include "ocudu/e1ap/common/e1ap_types.h" |
9 | | #include "ocudu/support/format/fmt_to_c_str.h" |
10 | | #include "ocudu/support/format/prefixed_logger.h" |
11 | | #include "fmt/format.h" |
12 | | |
13 | | namespace ocudu { |
14 | | |
15 | | class e1ap_log_prefix |
16 | | { |
17 | | public: |
18 | | e1ap_log_prefix(cu_up_e1_index_t e1_index) |
19 | 0 | { |
20 | 0 | fmt::memory_buffer buffer; |
21 | 0 | fmt::format_to(std::back_inserter(buffer), "e1={}: ", fmt::underlying(e1_index)); |
22 | 0 | prefix = ocudu::to_c_str(buffer); |
23 | 0 | } |
24 | 0 | const char* to_c_str() const { return prefix.c_str(); } |
25 | | |
26 | | private: |
27 | | std::string prefix; |
28 | | }; |
29 | | |
30 | | inline const char* format_as(const e1ap_log_prefix& o) |
31 | 0 | { |
32 | 0 | return o.to_c_str(); |
33 | 0 | } |
34 | | |
35 | | using e1ap_logger = prefixed_logger<e1ap_log_prefix>; |
36 | | |
37 | | } // namespace ocudu |