/src/ocudu/lib/pdcp/pdcp_bearer_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/ran/rb_id.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 | | #include <string.h> |
13 | | |
14 | | namespace ocudu { |
15 | | |
16 | | class pdcp_bearer_log_prefix |
17 | | { |
18 | | public: |
19 | | pdcp_bearer_log_prefix(uint32_t ue_index, rb_id_t rb_id, const char* dir) |
20 | 298k | { |
21 | 298k | fmt::memory_buffer buffer; |
22 | 298k | fmt::format_to(std::back_inserter(buffer), "ue={} {} {}: ", ue_index, rb_id, dir); |
23 | 298k | prefix = ocudu::to_c_str(buffer); |
24 | 298k | } |
25 | 298k | const char* to_c_str() const { return prefix.c_str(); } |
26 | | |
27 | | private: |
28 | | std::string prefix; |
29 | | }; |
30 | | |
31 | | inline const char* format_as(const pdcp_bearer_log_prefix& o) |
32 | 298k | { |
33 | 298k | return o.to_c_str(); |
34 | 298k | } |
35 | | |
36 | | using pdcp_bearer_logger = prefixed_logger<pdcp_bearer_log_prefix>; |
37 | | |
38 | | } // namespace ocudu |