#include "partition_alloc/partition_alloc_base/log_message.h"
#if defined( \
BASE_ALLOCATOR_PARTITION_ALLOCATOR_SRC_PARTITION_ALLOC_PARTITION_ALLOC_BASE_CHECK_H_) || \
defined(BASE_CHECK_H_) || \
defined( \
BASE_ALLOCATOR_PARTITION_ALLOCATOR_SRC_PARTITION_ALLOC_PARTITION_ALLOC_CHECK_H_)
#error "log_message.h should not include check.h"
#endif
#include "partition_alloc/build_config.h"
#include "partition_alloc/partition_alloc_base/component_export.h"
#include "partition_alloc/partition_alloc_base/debug/alias.h"
#include "partition_alloc/partition_alloc_base/debug/stack_trace.h"
#include "partition_alloc/partition_alloc_base/immediate_crash.h"
#include "partition_alloc/partition_alloc_base/logging.h"
#include "partition_alloc/partition_alloc_base/strings/safe_sprintf.h"
#include "partition_alloc/partition_alloc_base/strings/string_util.h"
#include "partition_alloc/partition_alloc_base/strings/stringprintf.h"
#if PA_BUILDFLAG(IS_WIN)
#include <windows.h>
#include <io.h>
#endif
#if PA_BUILDFLAG(IS_POSIX) || PA_BUILDFLAG(IS_FUCHSIA)
#include <unistd.h>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#endif
#if PA_BUILDFLAG(IS_POSIX) || PA_BUILDFLAG(IS_FUCHSIA)
#include "partition_alloc/partition_alloc_base/posix/safe_strerror.h"
#endif
namespace partition_alloc::internal::logging {
namespace {
const char* const log_severity_names[] = …;
static_assert …;
const char* log_severity_name(int severity) { … }
LogMessageHandlerFunction g_log_message_handler = …;
}
#if PA_BUILDFLAG(DCHECK_IS_CONFIGURABLE)
PA_COMPONENT_EXPORT(PARTITION_ALLOC_BASE)
logging::LogSeverity LOGGING_DCHECK = LOGGING_ERROR;
#endif
base::strings::CStringBuilder* g_swallow_stream;
void SetLogMessageHandler(LogMessageHandlerFunction handler) { … }
LogMessageHandlerFunction GetLogMessageHandler() { … }
LogMessage::LogMessage(const char* file, int line, LogSeverity severity)
: … { … }
LogMessage::LogMessage(const char* file, int line, const char* condition)
: … { … }
LogMessage::~LogMessage() { … }
void LogMessage::Init(const char* file, int line) { … }
#if PA_BUILDFLAG(IS_WIN)
typedef DWORD SystemErrorCode;
#endif
SystemErrorCode GetLastSystemErrorCode() { … }
void SystemErrorCodeToStream(base::strings::CStringBuilder& os,
SystemErrorCode error_code) { … }
#if PA_BUILDFLAG(IS_WIN)
Win32ErrorLogMessage::Win32ErrorLogMessage(const char* file,
int line,
LogSeverity severity,
SystemErrorCode err)
: LogMessage(file, line, severity), err_(err) {}
Win32ErrorLogMessage::~Win32ErrorLogMessage() {
stream() << ": ";
SystemErrorCodeToStream(stream(), err_);
DWORD last_error = err_;
base::debug::Alias(&last_error);
}
#elif PA_BUILDFLAG(IS_POSIX) || PA_BUILDFLAG(IS_FUCHSIA)
ErrnoLogMessage::ErrnoLogMessage(const char* file,
int line,
LogSeverity severity,
SystemErrorCode err)
: … { … }
ErrnoLogMessage::~ErrnoLogMessage() { … }
#endif
}