Carlos Chinchilla | 5e645b2 | 2021-08-02 20:48:33 -0700 | [diff] [blame] | 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 | |
Carlos Chinchilla | 6ea8f21 | 2021-12-06 12:12:48 -0800 | [diff] [blame] | 15 | // clang-format off |
| 16 | #include "pw_log_rpc/internal/log_config.h" // PW_LOG_* macros must be first. |
| 17 | |
Carlos Chinchilla | 5e645b2 | 2021-08-02 20:48:33 -0700 | [diff] [blame] | 18 | #include "pw_log_rpc/log_service.h" |
Carlos Chinchilla | 6ea8f21 | 2021-12-06 12:12:48 -0800 | [diff] [blame] | 19 | // clang-format on |
Carlos Chinchilla | 5e645b2 | 2021-08-02 20:48:33 -0700 | [diff] [blame] | 20 | |
| 21 | #include "pw_log/log.h" |
| 22 | #include "pw_log/proto/log.pwpb.h" |
| 23 | |
| 24 | namespace pw::log_rpc { |
| 25 | |
Wyatt Hepler | 8e756e3 | 2021-11-18 09:59:27 -0800 | [diff] [blame] | 26 | void LogService::Listen(ConstByteSpan, rpc::RawServerWriter& writer) { |
Wyatt Hepler | ebf33b7 | 2021-09-09 13:33:56 -0700 | [diff] [blame] | 27 | uint32_t channel_id = writer.channel_id(); |
Carlos Chinchilla | 5e645b2 | 2021-08-02 20:48:33 -0700 | [diff] [blame] | 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()) { |
Carlos Chinchilla | 6ea8f21 | 2021-12-06 12:12:48 -0800 | [diff] [blame] | 34 | PW_LOG_DEBUG("Could not start new log stream. %d", |
Carlos Chinchilla | 5e645b2 | 2021-08-02 20:48:33 -0700 | [diff] [blame] | 35 | static_cast<int>(status.code())); |
| 36 | } |
| 37 | } |
| 38 | |
Carlos Chinchilla | 5e645b2 | 2021-08-02 20:48:33 -0700 | [diff] [blame] | 39 | } // namespace pw::log_rpc |