AI-generated Key Takeaways
-
Defines the
SbLogPriority
enum for specifying the priority of log messages (Info, Warning, Error, Fatal). -
Provides functions for writing messages to the platform's debug output log, including
SbLog
for basic logging andSbLogFormat
for formatted logging. -
Includes async-signal-safe logging functions, like
SbLogRaw
, for use in signal handlers to ensure safe logging during critical events. -
Offers
SbLogRawDumpStack
to dump the current thread's stack for debugging purposes, with options to skip irrelevant frames. -
Provides functionality to flush the log buffer using
SbLogFlush
, ensuring that logged messages are written to the output.
Defines core debug logging functions.
Enums
SbLogPriority
The priority at which a message should be logged. The platform may be configured to filter logs by priority, or render them differently.
Values
kSbLogPriorityUnknown
kSbLogPriorityInfo
kSbLogPriorityWarning
kSbLogPriorityError
kSbLogPriorityFatal
Functions
SbLog
Writes message
to the platform's debug output log. This method is thread-safe,
and responsible for ensuring that the output from multiple threads is not mixed.
priority
: The SbLogPriority at which the message should be logged. Note that
passing kSbLogPriorityFatal
does not terminate the program. Such a policy must
be enforced at the application level. In fact, priority
may be completely
ignored on many platforms. message
: The message to be logged. Must not be
NULL. No formatting is required to be done on the value, including newline
termination. That said, platforms can adjust the message to be more suitable for
their output method by wrapping the text, stripping unprintable characters, etc.
Declaration
void SbLog(SbLogPriority priority, const char *message)
SbLogFlush
Flushes the log buffer on some platforms. This method is safe to call from multiple threads.
Declaration
void SbLogFlush()
SbLogFormat
A log output method that additionally performs a string format on the data being logged.
Declaration
void SbLogFormat(const char *format, va_list args) SB_PRINTF_FORMAT(1
SbLogFormatF
Inline wrapper of SbLogFormat that converts from ellipsis to va_args.
Declaration
void static void static void SbLogFormatF(const char *format,...) SB_PRINTF_FORMAT(1
SbLogRaw
A bare-bones log output method that is async-signal-safe, i.e. safe to call from
an asynchronous signal handler (e.g. a SIGSEGV
handler). It should not do any
additional formatting.
message
: The message to be logged. Must not be NULL.
Declaration
void SbLogRaw(const char *message)
SbLogRawDumpStack
Dumps the stack of the current thread to the log in an async-signal-safe manner,
i.e. safe to call from an asynchronous signal handler (e.g. a SIGSEGV
handler). Does not include SbLogRawDumpStack itself.
frames_to_skip
: The number of frames to skip from the top of the stack when
dumping the current thread to the log. This parameter lets you remove noise from
helper functions that might end up on top of every stack dump so that the stack
dump is just the relevant function stack where the problem occurred.
Declaration
void SbLogRawDumpStack(int frames_to_skip)
SbLogRawFormat
A formatted log output method that is async-signal-safe, i.e. safe to call from
an asynchronous signal handler (e.g. a SIGSEGV
handler).
Declaration
void SbLogRawFormat(const char *format, va_list args) SB_PRINTF_FORMAT(1
SbLogRawFormatF
Inline wrapper of SbLogFormat to convert from ellipsis to va_args.
Declaration
void static void static void SbLogRawFormatF(const char *format,...) SB_PRINTF_FORMAT(1