sln_device_c.h (1701B)
1 /* Copyright (C) 2022, 2026 |Méso|Star> (contact@meso-star.com) 2 * Copyright (C) 2026 Université de Lorraine 3 * Copyright (C) 2022 Centre National de la Recherche Scientifique 4 * Copyright (C) 2022 Université Paul Sabatier 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 18 19 #ifndef SLN_DEVICE_C_H 20 #define SLN_DEVICE_C_H 21 22 #include <rsys/logger.h> 23 #include <rsys/ref_count.h> 24 25 #define MSG_INFO_PREFIX "" 26 #define MSG_ERROR_PREFIX "error: " 27 #define MSG_WARNING_PREFIX "warning: " 28 29 /* Helper macros for logging */ 30 #define LOG__(Dev, Lvl, Type, ...) { \ 31 if ((Dev)->verbose >= (Lvl)) \ 32 logger_print((Dev)->logger, Type, __VA_ARGS__); \ 33 } (void)0 34 #define ERROR(Dev, ...) LOG__(Dev, 1, LOG_ERROR, MSG_ERROR_PREFIX __VA_ARGS__) 35 #define WARN(Dev, ...) LOG__(Dev, 2, LOG_WARNING, MSG_WARNING_PREFIX __VA_ARGS__) 36 #define INFO(Dev, ...) LOG__(Dev, 3, LOG_OUTPUT, MSG_INFO_PREFIX __VA_ARGS__) 37 38 struct mem_allocator; 39 40 struct sln_device { 41 struct mem_allocator* allocator; 42 struct logger* logger; 43 struct logger logger__; /* Default logger */ 44 int verbose; 45 ref_T ref; 46 }; 47 48 #endif /* SLN_DEVICE_C_H */