diff --git a/universal7885-common/apps/aidl-support/Android.bp b/universal7885-common/apps/aidl-support/Android.bp new file mode 100644 index 0000000..85a2008 --- /dev/null +++ b/universal7885-common/apps/aidl-support/Android.bp @@ -0,0 +1,5 @@ +cc_library_headers { + name: "logformat", + local_include_dirs: ["include"], + export_include_dirs: ["include"], +} diff --git a/universal7885-common/apps/aidl-support/include/LogFormat.h b/universal7885-common/apps/aidl-support/include/LogFormat.h new file mode 100644 index 0000000..6350e2f --- /dev/null +++ b/universal7885-common/apps/aidl-support/include/LogFormat.h @@ -0,0 +1,14 @@ +#include +#include + +#define make_str(a, ...) _make_str(__FILE__, __LINE__, a, ##__VA_ARGS__).c_str() + +template +std::string _make_str(const std::string& filename, int line, const std::string& fmt, Args... args) { + const int size = std::snprintf(nullptr, 0, fmt.c_str(), args...); + std::vector buf(size + 1); + std::snprintf(buf.data(), buf.size(), fmt.c_str(), args...); + std::stringstream ss; + ss << "[" << filename << ":" << line << "] " << std::string(buf.begin(), buf.end()); + return ss.str(); +}