1 /*
2  * Copyright (C) 2018-2022 Intel Corporation.
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef __LOG_SYS_H__
7 #define __LOG_SYS_H__
8 
9 #include <syslog.h>
10 #include <systemd/sd-journal.h>
11 
12 void debug_log(int level, const char *func, int line, ...);
13 
14 #define LOG_LEVEL LOG_WARNING
15 
16 #ifdef DEBUG_ACRN_CRASHLOG
17 #define LOGE(...) \
18 		debug_log(LOG_ERR, __func__, __LINE__,  __VA_ARGS__)
19 
20 #define LOGW(...) \
21 		debug_log(LOG_WARNING, __func__, __LINE__, __VA_ARGS__)
22 
23 #define LOGI(...) \
24 		debug_log(LOG_INFO, __func__, __LINE__, __VA_ARGS__)
25 
26 #define LOGD(...) \
27 		debug_log(LOG_DEBUG, __func__, __LINE__, __VA_ARGS__)
28 #else
29 #define ac_log(level, ...) \
30 	do { \
31 		if (level <= LOG_LEVEL) \
32 			sd_journal_print(level, __VA_ARGS__); \
33 	} while (0)
34 
35 #define LOGE(...) \
36 		ac_log(LOG_ERR, __VA_ARGS__)
37 
38 #define LOGW(...) \
39 		ac_log(LOG_WARNING, __VA_ARGS__)
40 
41 #define LOGI(...) \
42 		ac_log(LOG_INFO, __VA_ARGS__)
43 
44 #define LOGD(...) \
45 		ac_log(LOG_DEBUG, __VA_ARGS__)
46 #endif
47 
48 #endif
49