A sink to receive log records.
More...
#include <google/cloud/log.h>
A sink to receive log records.
Definition at line 247 of file log.h.
◆ BackendId
◆ LogSink()
google::cloud::LogSink::LogSink |
( |
| ) |
|
◆ AddBackend()
◆ BackendCount()
std::size_t google::cloud::LogSink::BackendCount |
( |
| ) |
const |
◆ ClearBackends()
void google::cloud::LogSink::ClearBackends |
( |
| ) |
|
◆ CompileTimeEnabled()
static constexpr bool google::cloud::LogSink::CompileTimeEnabled |
( |
Severity |
level | ) |
|
|
inlinestaticconstexpr |
Return true if the severity is enabled at compile time.
Definition at line 252 of file log.h.
◆ DisableStdClog()
static void google::cloud::LogSink::DisableStdClog |
( |
| ) |
|
|
inlinestatic |
Disable std::clog
on LogSink::Instance()
.
Note that this will remove the default logging backend.
Definition at line 340 of file log.h.
◆ empty()
bool google::cloud::LogSink::empty |
( |
| ) |
const |
|
inline |
Return 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.
Definition at line 277 of file log.h.
◆ EnableStdClog()
Enable std::clog
on LogSink::Instance()
.
This is also enabled if the "GOOGLE_CLOUD_CPP_ENABLE_CLOG" environment variable is set.
Definition at line 330 of file log.h.
◆ Flush()
void google::cloud::LogSink::Flush |
( |
| ) |
|
Flush all the current backends.
◆ Instance()
static LogSink& google::cloud::LogSink::Instance |
( |
| ) |
|
|
static |
Return the singleton instance for this application.
◆ is_enabled()
bool google::cloud::LogSink::is_enabled |
( |
Severity |
severity | ) |
const |
|
inline |
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.
Definition at line 295 of file log.h.
◆ Log()
void google::cloud::LogSink::Log |
( |
LogRecord |
log_record | ) |
|
◆ minimum_severity()
Severity google::cloud::LogSink::minimum_severity |
( |
| ) |
const |
|
inline |
◆ RemoveBackend()
void google::cloud::LogSink::RemoveBackend |
( |
BackendId |
id | ) |
|
◆ set_minimum_severity()
void google::cloud::LogSink::set_minimum_severity |
( |
Severity |
minimum | ) |
|
|
inline |