tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

log_sink_registry.h (2201B)


      1 // Copyright 2022 The Abseil Authors.
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of 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,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 //
     15 // -----------------------------------------------------------------------------
     16 // File: log/log_sink_registry.h
     17 // -----------------------------------------------------------------------------
     18 //
     19 // This header declares APIs to operate on global set of registered log sinks.
     20 
     21 #ifndef ABSL_LOG_LOG_SINK_REGISTRY_H_
     22 #define ABSL_LOG_LOG_SINK_REGISTRY_H_
     23 
     24 #include "absl/base/config.h"
     25 #include "absl/base/nullability.h"
     26 #include "absl/log/internal/log_sink_set.h"
     27 #include "absl/log/log_sink.h"
     28 
     29 namespace absl {
     30 ABSL_NAMESPACE_BEGIN
     31 
     32 // AddLogSink(), RemoveLogSink()
     33 //
     34 // Adds or removes a `absl::LogSink` as a consumer of logging data.
     35 //
     36 // These functions are thread-safe.
     37 //
     38 // It is an error to attempt to add a sink that's already registered or to
     39 // attempt to remove one that isn't.
     40 //
     41 // To avoid unbounded recursion, dispatch to registered `absl::LogSink`s is
     42 // disabled per-thread while running the `Send()` method of registered
     43 // `absl::LogSink`s.  Affected messages are dispatched to a special internal
     44 // sink instead which writes them to `stderr`.
     45 //
     46 // Do not call these inside `absl::LogSink::Send`.
     47 inline void AddLogSink(absl::Nonnull<absl::LogSink*> sink) {
     48  log_internal::AddLogSink(sink);
     49 }
     50 inline void RemoveLogSink(absl::Nonnull<absl::LogSink*> sink) {
     51  log_internal::RemoveLogSink(sink);
     52 }
     53 
     54 // FlushLogSinks()
     55 //
     56 // Calls `absl::LogSink::Flush` on all registered sinks.
     57 //
     58 // Do not call this inside `absl::LogSink::Send`.
     59 inline void FlushLogSinks() { log_internal::FlushLogSinks(); }
     60 
     61 ABSL_NAMESPACE_END
     62 }  // namespace absl
     63 
     64 #endif  // ABSL_LOG_LOG_SINK_REGISTRY_H_