mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 13:37:10 +00:00
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>
46 lines
821 B
C
46 lines
821 B
C
/*
|
|
* 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);
|
|
}
|