xref: /aosp_15_r20/external/pigweed/pw_log_rpc/public/pw_log_rpc/internal/config.h (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1 // Copyright 2021 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://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, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 
15 // Configuration macros for the pw_rpc module.
16 #pragma once
17 
18 #include <cstddef>
19 
20 // Log filter modules are optionally tokenized, and thus their backing on-device
21 // container can have different sizes. A token may be represented by a 32-bit
22 // integer (though it is usually 2 bytes). Default the max module name size to
23 // 4 bytes.
24 #ifndef PW_LOG_RPC_CONFIG_MAX_FILTER_RULE_MODULE_NAME_SIZE
25 #define PW_LOG_RPC_CONFIG_MAX_FILTER_RULE_MODULE_NAME_SIZE 4
26 #endif  // PW_LOG_RPC_CONFIG_MAX_FILTER_RULE_MODULE_NAME_SIZE
27 
28 // Log filter threads are optionally tokenized,thus their backing on-device
29 // container can have different sizes. A token may be represented by a 32-bit
30 // integer, usually two. Default the max thread size to
31 // 10 bytes.
32 #ifndef PW_LOG_RPC_CONFIG_MAX_FILTER_RULE_THREAD_NAME_SIZE
33 #define PW_LOG_RPC_CONFIG_MAX_FILTER_RULE_THREAD_NAME_SIZE 10
34 #endif  // PW_LOG_RPC_CONFIG_MAX_FILTER_RULE_THREAD_NAME_SIZE
35 
36 // Log filter IDs are optionally tokenized, and thus their backing on-device
37 // container can have different sizes. A token may be represented by a 32-bit
38 // integer (though it is usually 2 bytes). Default the max module name size to
39 // 4 bytes.
40 #ifndef PW_LOG_RPC_CONFIG_MAX_FILTER_ID_SIZE
41 #define PW_LOG_RPC_CONFIG_MAX_FILTER_ID_SIZE 4
42 #endif  // PW_LOG_RPC_CONFIG_MAX_FILTER_ID_SIZE
43 
44 // The log level to use for this module. Logs below this level are omitted.
45 #ifndef PW_LOG_RPC_CONFIG_LOG_LEVEL
46 #define PW_LOG_RPC_CONFIG_LOG_LEVEL PW_LOG_LEVEL_INFO
47 #endif  // PW_LOG_RPC_CONFIG_LOG_LEVEL
48 
49 // The log module name to use for this module.
50 #ifndef PW_LOG_RPC_CONFIG_LOG_MODULE_NAME
51 #define PW_LOG_RPC_CONFIG_LOG_MODULE_NAME "PW_LOG_RPC"
52 #endif  // PW_LOG_RPC_CONFIG_LOG_MODULE_NAME
53 
54 // Messages to descrive the log drop reasons.
55 // See https://pigweed.dev/pw_log_rpc/#log-drops
56 //
57 // Message for when an entry could not be added to the MultiSink.
58 #ifndef PW_LOG_RPC_INGRESS_ERROR_MSG
59 #define PW_LOG_RPC_INGRESS_ERROR_MSG "Ingress error"
60 #endif  // PW_LOG_RPC_INGRESS_ERROR_MSG
61 
62 // Message for when a drain drains too slow and has to be advanced, dropping
63 // logs.
64 #ifndef PW_LOG_RPC_SLOW_DRAIN_MSG
65 #define PW_LOG_RPC_SLOW_DRAIN_MSG "Slow drain"
66 #endif  // PW_LOG_RPC_SLOW_DRAIN_MSG
67 
68 // Message for when a log is too large to fit in the outbound buffer, so it is
69 // dropped.
70 #ifndef PW_LOG_RPC_SMALL_OUTBOUND_BUFFER_MSG
71 #define PW_LOG_RPC_SMALL_OUTBOUND_BUFFER_MSG "Outbound log buffer too small"
72 #endif  // PW_LOG_RPC_SMALL_OUTBOUND_BUFFER_MSG
73 
74 // Message for when the log entry in the MultiSink is too large to be peeked or
75 // popped out, so it is dropped.
76 #ifndef PW_LOG_RPC_SMALL_STACK_BUFFER_MSG
77 #define PW_LOG_RPC_SMALL_STACK_BUFFER_MSG "Stack log buffer too small"
78 #endif  // PW_LOG_RPC_SMALL_STACK_BUFFER_MSG
79 
80 // Message for when a bulk of logs cannot be sent due to a writer error.
81 #ifndef PW_LOG_RPC_WRITER_ERROR_MSG
82 #define PW_LOG_RPC_WRITER_ERROR_MSG "Writer error"
83 #endif  // PW_LOG_RPC_WRITER_ERROR_MSG
84 
85 namespace pw::log_rpc::cfg {
86 inline constexpr size_t kMaxModuleNameBytes =
87     PW_LOG_RPC_CONFIG_MAX_FILTER_RULE_MODULE_NAME_SIZE;
88 
89 inline constexpr size_t kMaxFilterIdBytes =
90     PW_LOG_RPC_CONFIG_MAX_FILTER_ID_SIZE;
91 
92 inline constexpr size_t kMaxThreadNameBytes =
93     PW_LOG_RPC_CONFIG_MAX_FILTER_RULE_THREAD_NAME_SIZE;
94 }  // namespace pw::log_rpc::cfg
95