2929#define LXC_LOG_PREFIX_SIZE 32
3030#define LXC_LOG_BUFFER_SIZE 4096
3131
32+ #ifndef LXC_LOG_TAG
33+ #define LXC_LOG_TAG "lxc"
34+ #endif
35+
36+ #ifdef USE_ANDROID_LOG
37+ #include <android/log.h>
38+ #endif
39+
3240/* predefined lxc log priorities. */
3341enum lxc_loglevel {
3442 LXC_LOG_LEVEL_TRACE ,
@@ -392,6 +400,9 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
392400#if (defined(__GNU_LIBRARY__ ) || defined(__MUSL__ )) && !ENABLE_COVERITY_BUILD
393401#define SYSTRACE (format , ...) \
394402 TRACE("%m - " format, ##__VA_ARGS__)
403+ #elif IS_BIONIC && USE_ANDROID_LOG
404+ #define SYSTRACE (format , ...) \
405+ __android_log_print(ANDROID_LOG_VERBOSE, LXC_LOG_TAG, format, ##__VA_ARGS__)
395406#else
396407#define SYSTRACE (format , ...) \
397408 do { \
@@ -403,6 +414,9 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
403414#if (defined(__GNU_LIBRARY__ ) || defined(__MUSL__ )) && !ENABLE_COVERITY_BUILD
404415#define SYSDEBUG (format , ...) \
405416 DEBUG("%m - " format, ##__VA_ARGS__)
417+ #elif IS_BIONIC && USE_ANDROID_LOG
418+ #define SYSDEBUG (format , ...) \
419+ __android_log_print(ANDROID_LOG_DEBUG, LXC_LOG_TAG, format, ##__VA_ARGS__)
406420#else
407421#define SYSDEBUG (format , ...) \
408422 do { \
@@ -415,6 +429,9 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
415429#if (defined(__GNU_LIBRARY__ ) || defined(__MUSL__ )) && !ENABLE_COVERITY_BUILD
416430#define SYSINFO (format , ...) \
417431 INFO("%m - " format, ##__VA_ARGS__)
432+ #elif IS_BIONIC && USE_ANDROID_LOG
433+ #define SYSINFO (format , ...) \
434+ __android_log_print(ANDROID_LOG_INFO, LXC_LOG_TAG, format, ##__VA_ARGS__)
418435#else
419436#define SYSINFO (format , ...) \
420437 do { \
@@ -426,6 +443,9 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
426443#if (defined(__GNU_LIBRARY__ ) || defined(__MUSL__ )) && !ENABLE_COVERITY_BUILD
427444#define SYSNOTICE (format , ...) \
428445 NOTICE("%m - " format, ##__VA_ARGS__)
446+ #elif IS_BIONIC && USE_ANDROID_LOG
447+ #define SYSNOTICE (format , ...) \
448+ __android_log_print(ANDROID_LOG_INFO, LXC_LOG_TAG, format, ##__VA_ARGS__)
429449#else
430450#define SYSNOTICE (format , ...) \
431451 do { \
@@ -437,6 +457,9 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
437457#if (defined(__GNU_LIBRARY__ ) || defined(__MUSL__ )) && !ENABLE_COVERITY_BUILD
438458#define SYSWARN (format , ...) \
439459 WARN("%m - " format, ##__VA_ARGS__)
460+ #elif IS_BIONIC && USE_ANDROID_LOG
461+ #define SYSWARN (format , ...) \
462+ __android_log_print(ANDROID_LOG_WARN, LXC_LOG_TAG, format, ##__VA_ARGS__)
440463#else
441464#define SYSWARN (format , ...) \
442465 do { \
@@ -448,6 +471,9 @@ __lxc_unused static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
448471#if (defined(__GNU_LIBRARY__ ) || defined(__MUSL__ )) && !ENABLE_COVERITY_BUILD
449472#define SYSERROR (format , ...) \
450473 ERROR("%m - " format, ##__VA_ARGS__)
474+ #elif IS_BIONIC && USE_ANDROID_LOG
475+ #define SYSERROR (format , ...) \
476+ __android_log_print(ANDROID_LOG_ERROR, LXC_LOG_TAG, format, ##__VA_ARGS__)
451477#else
452478#define SYSERROR (format , ...) \
453479 do { \
0 commit comments