1 // Copyright 2023 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 #define PW_LOG_MODULE_NAME "PW_RPC"
16
17 #include "pw_rpc_transport/socket_rpc_transport.h"
18
19 #include "pw_log/log.h"
20 #include "pw_status/status.h"
21
22 namespace pw::rpc::internal {
23
LogSocketListenError(pw::Status status)24 void LogSocketListenError(pw::Status status) {
25 PW_LOG_ERROR("SocketRpcTransport: socket listen error. Status %d",
26 status.code());
27 }
28
LogSocketAcceptError(pw::Status status)29 void LogSocketAcceptError(pw::Status status) {
30 PW_LOG_ERROR("SocketRpcTransport: socket accept error. Status %d",
31 status.code());
32 }
33
LogSocketConnectError(pw::Status status)34 void LogSocketConnectError(pw::Status status) {
35 PW_LOG_ERROR("SocketRpcTransport: socket connect error. Status %d",
36 status.code());
37 }
38
LogSocketReadError(pw::Status status)39 void LogSocketReadError(pw::Status status) {
40 if (status.IsOutOfRange()) {
41 PW_LOG_ERROR("SocketRpcTransport: read from a closed socket. Status %d",
42 status.code());
43 return;
44 }
45 PW_LOG_ERROR("SocketRpcTransport: socket read error. Status %d",
46 status.code());
47 }
48
LogSocketIngressHandlerError(pw::Status status)49 void LogSocketIngressHandlerError(pw::Status status) {
50 PW_LOG_ERROR("SocketRpcTransport: ingress handler error. Status %d",
51 status.code());
52 }
53
54 } // namespace pw::rpc::internal
55