summaryrefslogtreecommitdiff
path: root/absl
diff options
context:
space:
mode:
authorGravatar Andy Getzendanner <durandal@google.com>2022-05-17 13:49:22 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-05-17 13:50:22 -0700
commit7d3b4c86928ff7b17b3b881d42355062c23f6b44 (patch)
tree8e5e7ae21a9f93fe865003b0d8084282b9435313 /absl
parent9444b11e0c4e1f079c87067b5bbab1c5ff718809 (diff)
raw_logging: Extract the inlined no-hook-registered behavior for LogPrefixHook to a default implementation.
PiperOrigin-RevId: 449306617 Change-Id: Ia3e87d2edcae7e9874998f21a0e2ff245e48fd96
Diffstat (limited to 'absl')
-rw-r--r--absl/base/internal/raw_logging.cc27
1 files changed, 13 insertions, 14 deletions
diff --git a/absl/base/internal/raw_logging.cc b/absl/base/internal/raw_logging.cc
index ca2a75f3..8c49f9a6 100644
--- a/absl/base/internal/raw_logging.cc
+++ b/absl/base/internal/raw_logging.cc
@@ -79,12 +79,6 @@ namespace {
// Explicitly `#error` out when not `ABSL_LOW_LEVEL_WRITE_SUPPORTED`, except for
// a selected set of platforms for which we expect not to be able to raw log.
-ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES
-absl::base_internal::AtomicHook<LogFilterAndPrefixHook>
- log_filter_and_prefix_hook;
-ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES
-absl::base_internal::AtomicHook<AbortHook> abort_hook;
-
#ifdef ABSL_LOW_LEVEL_WRITE_SUPPORTED
constexpr char kTruncated[] = " ... (message truncated)\n";
@@ -132,6 +126,18 @@ bool DoRawLog(char** buf, int* size, const char* format, ...) {
return true;
}
+bool DefaultLogFilterAndPrefix(absl::LogSeverity, const char* file, int line,
+ char** buf, int* buf_size) {
+ DoRawLog(buf, buf_size, "[%s : %d] RAW: ", file, line);
+ return true;
+}
+
+ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES
+absl::base_internal::AtomicHook<LogFilterAndPrefixHook>
+ log_filter_and_prefix_hook(DefaultLogFilterAndPrefix);
+ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES
+absl::base_internal::AtomicHook<AbortHook> abort_hook;
+
void RawLogVA(absl::LogSeverity severity, const char* file, int line,
const char* format, va_list ap) ABSL_PRINTF_ATTRIBUTE(4, 0);
void RawLogVA(absl::LogSeverity severity, const char* file, int line,
@@ -152,14 +158,7 @@ void RawLogVA(absl::LogSeverity severity, const char* file, int line,
}
#endif
- auto log_filter_and_prefix_hook_ptr = log_filter_and_prefix_hook.Load();
- if (log_filter_and_prefix_hook_ptr) {
- enabled = log_filter_and_prefix_hook_ptr(severity, file, line, &buf, &size);
- } else {
- if (enabled) {
- DoRawLog(&buf, &size, "[%s : %d] RAW: ", file, line);
- }
- }
+ enabled = log_filter_and_prefix_hook(severity, file, line, &buf, &size);
const char* const prefix_end = buf;
#ifdef ABSL_LOW_LEVEL_WRITE_SUPPORTED