Go to the documentation of this file.
15 #include "absl/base/internal/raw_logging.h"
24 #include "absl/base/attributes.h"
25 #include "absl/base/config.h"
26 #include "absl/base/internal/atomic_hook.h"
27 #include "absl/base/internal/errno_saver.h"
28 #include "absl/base/log_severity.h"
40 #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
41 defined(__Fuchsia__) || defined(__native_client__) || \
42 defined(__OpenBSD__) || defined(__EMSCRIPTEN__) || defined(__ASYLO__)
46 #define ABSL_HAVE_POSIX_WRITE 1
47 #define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1
49 #undef ABSL_HAVE_POSIX_WRITE
55 #if (defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && \
57 #include <sys/syscall.h>
58 #define ABSL_HAVE_SYSCALL_WRITE 1
59 #define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1
61 #undef ABSL_HAVE_SYSCALL_WRITE
67 #define ABSL_HAVE_RAW_IO 1
68 #define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1
70 #undef ABSL_HAVE_RAW_IO
75 namespace raw_logging_internal {
82 #ifdef ABSL_LOW_LEVEL_WRITE_SUPPORTED
83 constexpr
char kTruncated[] =
" ... (message truncated)\n";
89 bool VADoRawLog(
char**
buf,
int*
size,
const char*
format, va_list ap)
91 bool VADoRawLog(
char**
buf,
int*
size,
const char*
format, va_list ap) {
94 if (n < 0 || n > *
size) {
96 if (
static_cast<size_t>(*
size) >
sizeof(kTruncated)) {
97 n = *
size -
sizeof(kTruncated);
106 #endif // ABSL_LOW_LEVEL_WRITE_SUPPORTED
108 constexpr
int kLogBufSize = 3000;
116 bool DoRawLog(
char**
buf,
int*
size,
const char*
format, ...)
118 bool DoRawLog(
char**
buf,
int*
size,
const char*
format, ...) {
123 if (n < 0 || n > *
size)
return false;
130 char**
buf,
int* buf_size) {
131 DoRawLog(
buf, buf_size,
"[%s : %d] RAW: ",
file,
line);
137 log_filter_and_prefix_hook(DefaultLogFilterAndPrefix);
144 const char*
format, va_list ap) {
148 #ifdef ABSL_LOW_LEVEL_WRITE_SUPPORTED
151 bool enabled =
false;
154 #ifdef ABSL_MIN_LOG_LEVEL
162 const char*
const prefix_end =
buf;
164 #ifdef ABSL_LOW_LEVEL_WRITE_SUPPORTED
170 DoRawLog(&
buf, &
size,
"%s", kTruncated);
175 static_cast<void>(
format);
176 static_cast<void>(ap);
177 static_cast<void>(enabled);
202 #if defined(ABSL_HAVE_SYSCALL_WRITE)
206 #elif defined(ABSL_HAVE_POSIX_WRITE)
208 #elif defined(ABSL_HAVE_RAW_IO)
218 const char*
format, ...) {
226 #ifdef ABSL_LOW_LEVEL_WRITE_SUPPORTED
228 #else // !ABSL_LOW_LEVEL_WRITE_SUPPORTED
230 #endif // !ABSL_LOW_LEVEL_WRITE_SUPPORTED
238 log_filter_and_prefix_hook.Store(
func);
int __cdecl vsnprintf(char *buffer, size_t count, const char *format, va_list argptr)
void RegisterAbortHook(AbortHook func)
void AsyncSignalSafeWriteToStderr(const char *s, size_t len)
#define ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES
void(*)(absl::LogSeverity severity, const char *file, int line, const std::string &message) InternalLogFunction
#define ABSL_NAMESPACE_END
bool(*)(absl::LogSeverity severity, const char *file, int line, char **buf, int *buf_size) LogFilterAndPrefixHook
void(*)(const char *file, int line, const char *buf_start, const char *prefix_end, const char *buf_end) AbortHook
void RegisterLogFilterAndPrefixHook(LogFilterAndPrefixHook func)
#define ABSL_NAMESPACE_BEGIN
void RawLog(absl::LogSeverity severity, const char *file, int line, const char *format,...)
#define ABSL_PRINTF_ATTRIBUTE(string_index, first_to_check)
void RegisterInternalLogFunction(InternalLogFunction func)
ABSL_INTERNAL_ATOMIC_HOOK_ATTRIBUTES ABSL_DLL base_internal::AtomicHook< InternalLogFunction > internal_log_function
bool RawLoggingFullySupported()
grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:59