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 #pragma once 15 16 // TODO(pwbug.dev/351): This file is very similar to pw_log_multisink/sink.h, 17 // which will be deprecated in a later change. 18 19 #include "pw_bytes/span.h" 20 #include "pw_containers/intrusive_list.h" 21 22 namespace pw { 23 namespace log_sink { 24 25 class Sink : public IntrusiveList<Sink>::Item { 26 public: 27 virtual ~Sink() = default; 28 29 // Write an entry to the sink. This is a best-effort attempt to send data to 30 // the sink, so failures are ignored. 31 virtual void HandleEntry(ConstByteSpan entry) = 0; 32 33 // Notifies the sink of messages dropped before ingress. The writer may use 34 // this to signal to sinks that an entry (or entries) was lost before sending 35 // to the sink (e.g. the log sink failed to encode the message). 36 virtual void HandleDropped(uint32_t drop_count) = 0; 37 }; 38 39 } // namespace log_sink 40 } // namespace pw 41