2018-04-25 10:19:46 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) <2018> Intel Corporation
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LOG_SYS_H__
|
|
|
|
#define __LOG_SYS_H__
|
|
|
|
|
|
|
|
#include <syslog.h>
|
2018-09-27 14:00:34 +08:00
|
|
|
#include <systemd/sd-journal.h>
|
2018-04-25 10:19:46 +08:00
|
|
|
|
2018-09-27 14:00:34 +08:00
|
|
|
void debug_log(int level, const char *func, int line, ...);
|
2018-04-25 10:19:46 +08:00
|
|
|
|
|
|
|
#define LOG_LEVEL LOG_WARNING
|
|
|
|
|
|
|
|
#ifdef DEBUG_ACRN_CRASHLOG
|
|
|
|
#define LOGE(...) \
|
2018-09-27 14:00:34 +08:00
|
|
|
debug_log(LOG_ERR, __func__, __LINE__, __VA_ARGS__)
|
2018-04-25 10:19:46 +08:00
|
|
|
|
|
|
|
#define LOGW(...) \
|
2018-09-27 14:00:34 +08:00
|
|
|
debug_log(LOG_WARNING, __func__, __LINE__, __VA_ARGS__)
|
2018-04-25 10:19:46 +08:00
|
|
|
|
|
|
|
#define LOGI(...) \
|
2018-09-27 14:00:34 +08:00
|
|
|
debug_log(LOG_INFO, __func__, __LINE__, __VA_ARGS__)
|
2018-04-25 10:19:46 +08:00
|
|
|
|
|
|
|
#define LOGD(...) \
|
2018-09-27 14:00:34 +08:00
|
|
|
debug_log(LOG_DEBUG, __func__, __LINE__, __VA_ARGS__)
|
2018-04-25 10:19:46 +08:00
|
|
|
#else
|
2018-09-27 14:00:34 +08:00
|
|
|
#define ac_log(level, ...) \
|
|
|
|
do { \
|
|
|
|
if (level <= LOG_LEVEL) \
|
|
|
|
sd_journal_print(level, __VA_ARGS__); \
|
|
|
|
} while (0)
|
|
|
|
|
2018-04-25 10:19:46 +08:00
|
|
|
#define LOGE(...) \
|
2018-09-27 14:00:34 +08:00
|
|
|
ac_log(LOG_ERR, __VA_ARGS__)
|
2018-04-25 10:19:46 +08:00
|
|
|
|
|
|
|
#define LOGW(...) \
|
2018-09-27 14:00:34 +08:00
|
|
|
ac_log(LOG_WARNING, __VA_ARGS__)
|
2018-04-25 10:19:46 +08:00
|
|
|
|
|
|
|
#define LOGI(...) \
|
2018-09-27 14:00:34 +08:00
|
|
|
ac_log(LOG_INFO, __VA_ARGS__)
|
2018-04-25 10:19:46 +08:00
|
|
|
|
|
|
|
#define LOGD(...) \
|
2018-09-27 14:00:34 +08:00
|
|
|
ac_log(LOG_DEBUG, __VA_ARGS__)
|
2018-04-25 10:19:46 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|