Skip to content

Commit

Permalink
Starboardize absl raw logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jellefoks committed Jan 12, 2024
1 parent 702fccf commit 6abc2e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 1 addition & 2 deletions third_party/abseil-cpp/absl/base/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ absl_source_set("log_severity") {
}

absl_source_set("raw_logging_internal") {
if (!use_cobalt_customizations) {
sources = [ "internal/raw_logging.cc" ]
}
public = [ "internal/raw_logging.h" ]
deps = [ "//starboard:starboard_headers_only" ]
public_deps = [
":atomic_hook",
":config",
Expand Down
12 changes: 9 additions & 3 deletions third_party/abseil-cpp/absl/base/internal/raw_logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include "absl/base/internal/errno_saver.h"
#include "absl/base/log_severity.h"

#if defined(STARBOARD)
#include "starboard/log.h"
#endif
// We know how to perform low-level writes to stderr in POSIX and Windows. For
// these platforms, we define the token ABSL_LOW_LEVEL_WRITE_SUPPORTED.
// Much of raw_logging.cc becomes a no-op when we can't output messages,
Expand All @@ -37,9 +40,10 @@
//
// This preprocessor token is also defined in raw_io.cc. If you need to copy
// this, consider moving both to config.h instead.
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
defined(__Fuchsia__) || defined(__native_client__) || \
defined(__OpenBSD__) || defined(__EMSCRIPTEN__) || defined(__ASYLO__)
#if (defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
defined(__Fuchsia__) || defined(__native_client__) || \
defined(__OpenBSD__) || defined(__EMSCRIPTEN__) || defined(__ASYLO__)) && \
!defined(STARBOARD)

#include <unistd.h>

Expand Down Expand Up @@ -211,6 +215,8 @@ void AsyncSignalSafeWriteToStderr(const char* s, size_t len) {
write(STDERR_FILENO, s, len);
#elif defined(ABSL_HAVE_RAW_IO)
_write(/* stderr */ 2, s, static_cast<unsigned>(len));
#elif defined(STARBOARD)
SbLog(kSbLogPriorityError, s);
#else
// stderr logging unsupported on this platform
(void) s;
Expand Down

0 comments on commit 6abc2e6

Please sign in to comment.