drv/virtgpu: add log level for logging

Harmless initialization logging should be info instead of error.

TEST=build and check logcat
BUG=b:234143058

Change-Id: I41ff39b428feb85d01663eec74b3f826007337c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3759415
Commit-Queue: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
This commit is contained in:
Yiwei Zhang 2022-07-13 00:25:11 +00:00 committed by Chromeos LUCI
parent 52be91e21b
commit 7b3cbeabbb
4 changed files with 47 additions and 10 deletions

29
drv.c
View file

@ -744,7 +744,8 @@ uint32_t drv_num_buffers_per_bo(struct bo *bo)
return count;
}
void drv_log_prefix(const char *prefix, const char *file, int line, const char *format, ...)
void drv_log_prefix(enum drv_log_level level, const char *prefix, const char *file, int line,
const char *format, ...)
{
char buf[50];
snprintf(buf, sizeof(buf), "[%s:%s(%d)]", prefix, basename(file), line);
@ -752,10 +753,30 @@ void drv_log_prefix(const char *prefix, const char *file, int line, const char *
va_list args;
va_start(args, format);
#ifdef __ANDROID__
__android_log_vprint(ANDROID_LOG_ERROR, buf, format, args);
int prio = ANDROID_LOG_ERROR;
switch (level) {
case DRV_LOGV:
prio = ANDROID_LOG_VERBOSE;
break;
case DRV_LOGD:
prio = ANDROID_LOG_DEBUG;
break;
case DRV_LOGI:
prio = ANDROID_LOG_INFO;
break;
case DRV_LOGE:
default:
break;
};
__android_log_vprint(prio, buf, format, args);
#else
fprintf(stderr, "%s ", buf);
vfprintf(stderr, format, args);
if (level == DRV_LOGE) {
fprintf(stderr, "%s ", buf);
vfprintf(stderr, format, args);
} else {
fprintf(stdout, "%s ", buf);
vfprintf(stdout, format, args);
}
#endif
va_end(args);
}