1 /* 2 * Copyright (c) 2023 Institute of Parallel And Distributed Systems (IPADS), Shanghai Jiao Tong University (SJTU) 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 #ifndef PROCMGR_DBG_H 13 #define PROCMGR_DBG_H 14 15 #include <assert.h> 16 #include <stdio.h> 17 18 #define PROCMGR_NOPRINT (-1) 19 #define PROCMGR_WARNING 0 20 #define PROCMGR_INFO 1 21 #define PROCMGR_DEBUG 2 22 23 #define PROCMGR_PRINT_LEVEL PROCMGR_NOPRINT 24 25 #define PREFIX "[procmgr]" 26 27 #if PROCMGR_PRINT_LEVEL >= PROCMGR_WARNING 28 #define warn(fmt, ...) printf(PREFIX " " fmt, ##__VA_ARGS__) 29 #else 30 #define warn(fmt, ...) 31 #endif 32 33 #if PROCMGR_PRINT_LEVEL >= PROCMGR_INFO 34 #define info(fmt, ...) printf(PREFIX " " fmt, ##__VA_ARGS__) 35 #else 36 #define info(fmt, ...) 37 #endif 38 39 #if PROCMGR_PRINT_LEVEL >= PROCMGR_DEBUG 40 #define debug(fmt, ...) \ 41 printf(PREFIX "<%s:%d>: " fmt, __func__, __LINE__, ##__VA_ARGS__) 42 #else 43 #define debug(fmt, ...) 44 #endif 45 46 #define error(fmt, ...) printf(PREFIX " " fmt, ##__VA_ARGS__) 47 48 #endif /* PROCMGR_DBG_H */