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:
Liu Xinwu
2018-04-25 10:19:46 +08:00
committed by lijinxia
parent 7c9cc6bcd4
commit 6f9dfa49bf
10 changed files with 272 additions and 0 deletions

View 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);
}