mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-08 10:04:42 +00:00
tools: acrn-crashlog: framework of acrn-crashlog
This is the first patch of acrn-crashlog. This patch initializes the framework of acrn-crashlog: acrnprobe, common, data, and usercrash. And it initializes the Makefile for each part. Signed-off-by: Liu Xinwu <xinwu.liu@intel.com> Signed-off-by: CHEN Gang <gang.c.chen@intel.com> Reviewed-by: Zhang Yanmin <yanmin.zhang@intel.com> Reviewed-by: Liu Chuansheng <chuansheng.liu@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com> Reviewed-by: Geoffroy Van Cutsem <geoffroy.vancutsem@intel.com> Acked-by: Eddie Dong <Eddie.dong@intel.com>
This commit is contained in:
45
tools/acrn-crashlog/common/log_sys.c
Normal file
45
tools/acrn-crashlog/common/log_sys.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) <2018> Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <systemd/sd-journal.h>
|
||||
#include "log_sys.h"
|
||||
|
||||
void do_log(int level,
|
||||
#ifdef DEBUG_ACRN_CRASHLOG
|
||||
const char *func, int line,
|
||||
#endif
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
char *fmt;
|
||||
char log[MAX_LOG_LEN] = {0};
|
||||
#ifdef DEBUG_ACRN_CRASHLOG
|
||||
char header_fmt[] = "<%-20s%d>: ";
|
||||
#endif
|
||||
|
||||
if (level > LOG_LEVEL)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_ACRN_CRASHLOG
|
||||
va_start(args, line);
|
||||
#else
|
||||
va_start(args, level);
|
||||
#endif
|
||||
fmt = va_arg(args, char *);
|
||||
if (!fmt)
|
||||
return;
|
||||
|
||||
#ifdef DEBUG_ACRN_CRASHLOG
|
||||
/* header */
|
||||
snprintf(log, sizeof(log) - 1, header_fmt, func, line);
|
||||
#endif
|
||||
/* msg */
|
||||
vsnprintf(log + strlen(log), sizeof(log) - strlen(log) - 1, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
sd_journal_print(level, log);
|
||||
}
|
||||
Reference in New Issue
Block a user