mirror of
https://github.com/chararomandroid/android_device_samsung_a20
synced 2026-08-21 11:55:31 -04:00
universal7885: aidl-support: Add a common header for log format
This commit is contained in:
parent
ec1db378bd
commit
b5a6677f60
2 changed files with 19 additions and 0 deletions
5
universal7885-common/apps/aidl-support/Android.bp
Normal file
5
universal7885-common/apps/aidl-support/Android.bp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
cc_library_headers {
|
||||
name: "logformat",
|
||||
local_include_dirs: ["include"],
|
||||
export_include_dirs: ["include"],
|
||||
}
|
||||
14
universal7885-common/apps/aidl-support/include/LogFormat.h
Normal file
14
universal7885-common/apps/aidl-support/include/LogFormat.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#define make_str(a, ...) _make_str(__FILE__, __LINE__, a, ##__VA_ARGS__).c_str()
|
||||
|
||||
template <typename... Args>
|
||||
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<char> 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();
|
||||
}
|
||||
Loading…
Reference in a new issue