SpecsLog
SPECS NDK reference for the SpecsLog API, which writes printf-style messages at six priority levels to the system log.
SpecsLog is the system logging API for SPECS applications: printf-style formatted messages at six priority levels, routed to the system log.
Include and link SpecsLog
#include <SpecsLog.h>
target_link_libraries(myapp specs_log)
SpecsLog priorities
// Since: v1.3.0
typedef enum {
SPECS_LOG_VERBOSE = 0,
SPECS_LOG_DEBUG,
SPECS_LOG_INFO,
SPECS_LOG_WARN,
SPECS_LOG_ERROR,
SPECS_LOG_FATAL,
} SpecsLogPriority;
SpecsLog function reference
// printf-style formatted log write.
// Returns 0 on success, <0 on error (negative errno). NOT a byte count.
// Since: v1.3.0
int SpecsLog_print(SpecsLogPriority prio, const char *tag, const char *fmt, ...);
// va_list variant.
// Since: v1.3.0
int SpecsLog_vprint(SpecsLogPriority prio, const char *tag, const char *fmt, va_list ap);
Both SpecsLog functions carry __attribute__((format(printf, ...))), so the compiler checks format strings and arguments at the call site.
Threading and safety:
- Thread-safe—may be called concurrently from any thread.
- NOT async-signal-safe—do not call from a signal handler (internally allocates). Signal/crash-handler logging can deadlock; route it via a self-pipe or deferred path instead.
- errno-neutral—never modifies the caller's
errno; failure is reported only via the negative return value.
SpecsLog per-level macros
SpecsLog.h provides convenience macros that pass a compile-time tag. Define SPECS_LOG_TAG before including the header, or the tag defaults to NULL:
#define SPECS_LOG_TAG "MyApp"
#include <SpecsLog.h>
SPECS_LOGV("verbose: %d", v); // SPECS_LOG_VERBOSE
SPECS_LOGD("debug"); // SPECS_LOG_DEBUG
SPECS_LOGI("info"); // SPECS_LOG_INFO
SPECS_LOGW("warning"); // SPECS_LOG_WARN
SPECS_LOGE("error: %s", msg); // SPECS_LOG_ERROR
SPECS_LOGF("fatal"); // SPECS_LOG_FATAL
SpecsLog is the general-purpose application logging API. The SpecsMedia_setLogLevel() function documented under SpecsMedia controls the verbosity of SpecsMedia's own internal logs and is unrelated.