1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 #ifndef H_MODLOG_ 21 #define H_MODLOG_ 22 23 #include <stdio.h> 24 25 #include "log/log.h" 26 27 #define MODLOG_MODULE_DFLT 3 28 29 #if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_DEBUG || defined __DOXYGEN__ 30 #define MODLOG_DEBUG(ml_mod_, ml_msg_, ...) \ 31 printf((ml_msg_), ##__VA_ARGS__) 32 #else 33 #define MODLOG_DEBUG(ml_mod_, ...) IGNORE(__VA_ARGS__) 34 #endif 35 36 #if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_INFO || defined __DOXYGEN__ 37 #define MODLOG_INFO(ml_mod_, ml_msg_, ...) \ 38 printf((ml_msg_), ##__VA_ARGS__) 39 #else 40 #define MODLOG_INFO(ml_mod_, ...) IGNORE(__VA_ARGS__) 41 #endif 42 43 #if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_WARN || defined __DOXYGEN__ 44 #define MODLOG_WARN(ml_mod_, ml_msg_, ...) \ 45 printf((ml_msg_), ##__VA_ARGS__) 46 #else 47 #define MODLOG_WARN(ml_mod_, ...) IGNORE(__VA_ARGS__) 48 #endif 49 50 #if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_ERROR || defined __DOXYGEN__ 51 #define MODLOG_ERROR(ml_mod_, ml_msg_, ...) \ 52 printf((ml_msg_), ##__VA_ARGS__) 53 #else 54 #define MODLOG_ERROR(ml_mod_, ...) IGNORE(__VA_ARGS__) 55 #endif 56 57 #if MYNEWT_VAL(LOG_LEVEL) <= LOG_LEVEL_CRITICAL || defined __DOXYGEN__ 58 #define MODLOG_CRITICAL(ml_mod_, ml_msg_, ...) \ 59 printf((ml_msg_), ##__VA_ARGS__) 60 #else 61 #define MODLOG_CRITICAL(ml_mod_, ...) IGNORE(__VA_ARGS__) 62 #endif 63 64 #define MODLOG(ml_lvl_, ml_mod_, ...) \ 65 MODLOG_ ## ml_lvl_((ml_mod_), __VA_ARGS__) 66 67 #define MODLOG_DFLT(ml_lvl_, ...) \ 68 MODLOG(ml_lvl_, LOG_MODULE_DEFAULT, __VA_ARGS__) 69 70 #endif 71