Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:01:06

0001 // Copyright 2022 The Abseil Authors.
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 //      https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 //
0015 // -----------------------------------------------------------------------------
0016 // File: log/log_sink.h
0017 // -----------------------------------------------------------------------------
0018 //
0019 // This header declares the interface class `absl::LogSink`.
0020 
0021 #ifndef ABSL_LOG_LOG_SINK_H_
0022 #define ABSL_LOG_LOG_SINK_H_
0023 
0024 #include "absl/base/config.h"
0025 #include "absl/log/log_entry.h"
0026 
0027 namespace absl {
0028 ABSL_NAMESPACE_BEGIN
0029 
0030 // absl::LogSink
0031 //
0032 // `absl::LogSink` is an interface which can be extended to intercept and
0033 // process particular messages (with `LOG.ToSinkOnly()` or
0034 // `LOG.ToSinkAlso()`) or all messages (if registered with
0035 // `absl::AddLogSink`).  Implementations must be thread-safe, and should take
0036 // care not to take any locks that might be held by the `LOG` caller.
0037 class LogSink {
0038  public:
0039   virtual ~LogSink() = default;
0040 
0041   // LogSink::Send()
0042   //
0043   // `Send` is called synchronously during the log statement.
0044   //
0045   // It is safe to use `LOG` within an implementation of `Send`.  `ToSinkOnly`
0046   // and `ToSinkAlso` are safe in general but can be used to create an infinite
0047   // loop if you try.
0048   virtual void Send(const absl::LogEntry& entry) = 0;
0049 
0050   // LogSink::Flush()
0051   //
0052   // Sinks that buffer messages should override this method to flush the buffer
0053   // and return.
0054   virtual void Flush() {}
0055 
0056  private:
0057   // https://lld.llvm.org/missingkeyfunction.html#missing-key-function
0058   virtual void KeyFunction() const final;  // NOLINT(readability/inheritance)
0059 };
0060 
0061 ABSL_NAMESPACE_END
0062 }  // namespace absl
0063 
0064 #endif  // ABSL_LOG_LOG_SINK_H_