Stay organized with collections Save and categorize content based on your preferences.
A sink to receive log records.
Constructors LogSink Functions emptyReturn true if this object has no backends.
We want to avoid synchronization overhead when checking if a log message is enabled. Most of the time, most messages will be disabled, so incurring the locking overhead on each message would be too expensive and would discourage developers from creating logs. Furthermore, missing a few messages while the change of state "propagates" to other threads does not affect the correctness of the program.
Note that memory_order_relaxed
does not provide a compiler barrier either, so in theory stores into the atomic could be reordered by the optimizer. We have no reason to worry about that because all the writes are done inside a critical section protected by a mutex. The compiler cannot (or should not) reorder operations around those.
bool
is_enabled
Return true if severity
is enabled.
We want to avoid synchronization overhead when checking if a log message is enabled. Most of the time, most messages will be disabled, so incurring the locking overhead on each message would be too expensive and would discourage developers from creating logs. Furthermore, missing a few messages while the change of state "propagates" to other threads does not affect the correctness of the program.
Note that memory_order_relaxed
does not provide a compiler barrier either, so in theory stores into the atomic could be reordered by the optimizer. We have no reason to worry about that because all the writes are done inside a critical section protected by a mutex. The compiler cannot (or should not) reorder operations around those.
severity
Severity
bool
set_minimum_severity Parameter Name Description minimum
Severity
void
minimum_severity Returns Type Description Severity
AddBackend Parameter Name Description backend
std::shared_ptr< LogBackend >
BackendId
RemoveBackend Parameter Name Description id
BackendId
void
ClearBackends Returns Type Description void
BackendCount Returns Type Description std::size_t
Log Parameter Name Description log_record
LogRecord
void
Flush
Flush all the current backends.
Returns Type Descriptionvoid
CompileTimeEnabled
Return true if the severity is enabled at compile time.
Parameter Name Descriptionlevel
Severity
bool constexpr
Instance
Return the singleton instance for this application.
Returns Type DescriptionLogSink &
EnableStdClog
Enable std::clog
on LogSink::Instance()
.
This is also enabled if the "GOOGLE_CLOUD_CPP_ENABLE_CLOG" environment variable is set.
Parameter Name Descriptionmin_severity
Severity
void
DisableStdClog
Disable std::clog
on LogSink::Instance()
.
Note that this will remove the default logging backend.
Returns Type Descriptionvoid
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-14 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["This document provides the C++ reference documentation for the `LogSink` class, a component designed to receive and manage log records."],["The latest version of the `LogSink` class is `2.37.0-rc`, with a comprehensive list of previous versions also available for reference, ranging from `2.10.1` to `2.36.0`."],["`LogSink` offers functions such as `empty`, `is_enabled`, `set_minimum_severity`, `AddBackend`, `RemoveBackend`, and `Log`, enabling developers to manage log behaviors and backends effectively."],["Developers can control the output of logs, including the ability to enable or disable `std::clog` output with `EnableStdClog` and `DisableStdClog` methods."],["The `Instance` method provides access to the singleton instance of `LogSink` for application-wide log management."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4