• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 IDs are optionally tokenized, and thus their backing on-device
29 // container can have different sizes. A token may be represented by a 32-bit
30 // integer (though it is usually 2 bytes). Default the max module name size to
31 // 4 bytes.
32 #ifndef PW_LOG_RPC_CONFIG_MAX_FILTER_ID_SIZE
33 #define PW_LOG_RPC_CONFIG_MAX_FILTER_ID_SIZE 4
34 #endif  // PW_LOG_RPC_CONFIG_MAX_FILTER_ID_SIZE
35 
36 // The log level to use for this module. Logs below this level are omitted.
37 #ifndef PW_LOG_RPC_CONFIG_LOG_LEVEL
38 #define PW_LOG_RPC_CONFIG_LOG_LEVEL PW_LOG_LEVEL_INFO
39 #endif  // PW_LOG_RPC_CONFIG_LOG_LEVEL
40 
41 // The log module name to use for this module.
42 #ifndef PW_LOG_RPC_CONFIG_LOG_MODULE_NAME
43 #define PW_LOG_RPC_CONFIG_LOG_MODULE_NAME "PW_LOG_RPC"
44 #endif  // PW_LOG_RPC_CONFIG_LOG_MODULE_NAME
45 
46 // Messages to descrive the log drop reasons.
47 // See https://pigweed.dev/pw_log_rpc/#log-drops
48 //
49 // Message for when an entry could not be added to the MultiSink.
50 #ifndef PW_LOG_RPC_INGRESS_ERROR_MSG
51 #define PW_LOG_RPC_INGRESS_ERROR_MSG "Ingress error"
52 #endif  // PW_LOG_RPC_INGRESS_ERROR_MSG
53 
54 // Message for when a drain drains too slow and has to be advanced, dropping
55 // logs.
56 #ifndef PW_LOG_RPC_SLOW_DRAIN_MSG
57 #define PW_LOG_RPC_SLOW_DRAIN_MSG "Slow drain"
58 #endif  // PW_LOG_RPC_SLOW_DRAIN_MSG
59 
60 // Message for when a is too too large to fit in the outbound buffer, so it is
61 // dropped.
62 #ifndef PW_LOG_RPC_SMALL_OUTBOUND_BUFFER_MSG
63 #define PW_LOG_RPC_SMALL_OUTBOUND_BUFFER_MSG "Outbound log buffer too small"
64 #endif  // PW_LOG_RPC_SMALL_OUTBOUND_BUFFER_MSG
65 
66 // Message for when the log entry in the MultiSink is too large to be peeked or
67 // popped out, so it is dropped.
68 #ifndef PW_LOG_RPC_SMALL_STACK_BUFFER_MSG
69 #define PW_LOG_RPC_SMALL_STACK_BUFFER_MSG "Stack log buffer too small"
70 #endif  // PW_LOG_RPC_SMALL_STACK_BUFFER_MSG
71 
72 // Message for when a bulk of logs cannot be sent due to a writer error.
73 #ifndef PW_LOG_RPC_WRITER_ERROR_MSG
74 #define PW_LOG_RPC_WRITER_ERROR_MSG "Writer error"
75 #endif  // PW_LOG_RPC_WRITER_ERROR_MSG
76 
77 namespace pw::log_rpc::cfg {
78 inline constexpr size_t kMaxModuleNameBytes =
79     PW_LOG_RPC_CONFIG_MAX_FILTER_RULE_MODULE_NAME_SIZE;
80 
81 inline constexpr size_t kMaxFilterIdBytes =
82     PW_LOG_RPC_CONFIG_MAX_FILTER_ID_SIZE;
83 }  // namespace pw::log_rpc::cfg
84