1 // Copyright 2020 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 // clang-format off 16 #include "pw_log_rpc/internal/log_config.h" // PW_LOG_* macros must be first. 17 18 #include "pw_log_rpc/log_service.h" 19 // clang-format on 20 21 #include "pw_log/log.h" 22 #include "pw_log/proto/log.pwpb.h" 23 24 namespace pw::log_rpc { 25 Listen(ConstByteSpan,rpc::RawServerWriter & writer)26void LogService::Listen(ConstByteSpan, rpc::RawServerWriter& writer) { 27 uint32_t channel_id = writer.channel_id(); 28 Result<RpcLogDrain*> drain = drains_.GetDrainFromChannelId(channel_id); 29 if (!drain.ok()) { 30 return; 31 } 32 33 if (const Status status = drain.value()->Open(writer); !status.ok()) { 34 PW_LOG_DEBUG("Could not start new log stream. %d", 35 static_cast<int>(status.code())); 36 } 37 } 38 39 } // namespace pw::log_rpc 40