Lightweight, modular logging library designed for Android NDK environments (armeabi-v7a / arm64-v8a), providing both C++ and C-compatible APIs with Android logcat integration.
This library provides:
- C++ object-oriented logging API
- C ABI-compatible wrapper (stable interface)
- Log levels with priority control (Info, Error, Debug, etc.)
- Dynamic tag system
- Callback hooks for external integration
va_listand variadic function support- Native Android logging via
__android_log_write - Formatting via
stb_sprintf(required)
logger.hpp / logger.cpp → Core C++ implementation
logger_c.h / logger_c.cpp → C ABI wrapper layer
stb_sprintf.h → Required formatter backend
stb_sprintf.h(formatting backend)
#include "logger.hpp"
Logger* log = Logger::GetLogger();
log->Info("Hello %s", "world");
log->Error("Error code: %d", 404);
log->SetTag("GameCore");
log->Print(LogP_Debug, "Debug value: %d", 123);🚀 Usage (C API)
#include "logger_c.h"
LoggerC* log = logger_get_global();
logger_info(log, "Hello %s", "world");
logger_error(log, "Fatal error: %d", -1);
logger_set_tag(log, "Engine");
logger_print(log, LogP_Debug, "Value: %f", 3.14f);🔗 Callback System
C++
logger->SetMessageCB(myCallback);
logger->SetTagCB(tagCallback);
logger->SetToggleCB(toggleCallback);C
logger_set_message_cb(log, myCallback);
logger_set_tag_cb(log, tagCallback);
logger_set_toggle_cb(log, toggleCallback);📱 Android Integration
The logger writes directly to Android logcat via:
#include <android/log.h>
__android_log_write(...)🧠 Technical Characteristics
- Fixed stack buffer (2048 bytes)
- Formatting powered by stb_sprintf
- No STL dependency required
- Optional compile-time logging disable (NOLOGGING)
- C ABI stability via opaque pointer design
- Low overhead (no allocations in hot path)
- stb_sprintf.h is required for compilation
- No fallback to standard vsnprintf is provided
- Designed for performance-sensitive runtime environments
📄 Licenses
- File: stb_sprintf.h
- Author: Sean Barrett
- License: MIT / Public Domain
- Files: logger.hpp, logger.cpp
- Author: Rusjj
- License: MIT
- Files: logger_c.h, logger_c.cpp
- Author: DeviceBlack
- License: MIT
👤 Credits
- Sean Barrett — stb_sprintf.h
- Rusjj — original C++ logger implementation
- DeviceBlack — refactoring, fixes, C API wrapper