A library for easier setup and prototyping of IoT devices (pucks), by collecting everything that is common for all pucks in one place.
Dependencies: BLE_API nRF51822
Fork of Puck by
Log.h
00001 /** 00002 * Copyright 2014 Nordic Semiconductor 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License 00015 */ 00016 00017 00018 #ifndef __LOG__H__ 00019 #define __LOG__H__ 00020 00021 00022 #ifdef LOG_LEVEL_VERBOSE 00023 #define __PUCK_LOG_LEVEL_VERBOSE__ 00024 #endif 00025 #ifdef LOG_LEVEL_DEBUG 00026 #define __PUCK_LOG_LEVEL_DEBUG__ 00027 #endif 00028 #ifdef LOG_LEVEL_INFO 00029 #define __PUCK_LOG_LEVEL_INFO__ 00030 #endif 00031 #ifdef LOG_LEVEL_WARN 00032 #define __PUCK_LOG_LEVEL_WARN__ 00033 #endif 00034 #ifdef LOG_LEVEL_ERROR 00035 #define __PUCK_LOG_LEVEL_ERROR__ 00036 #endif 00037 00038 #ifdef __PUCK_LOG_LEVEL_VERBOSE__ 00039 #define LOG_VERBOSE(fmt, ...) do { logger.printf("[V] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) 00040 #define __PUCK_LOG_LEVEL_DEBUG__ 00041 #else 00042 #define LOG_VERBOSE(fmt, ...) 00043 #endif 00044 00045 #ifdef __PUCK_LOG_LEVEL_DEBUG__ 00046 #define LOG_DEBUG(fmt, ...) do { logger.printf("[D] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) 00047 #define __PUCK_LOG_LEVEL_INFO__ 00048 #else 00049 #define LOG_DEBUG(fmt, ...) 00050 #endif 00051 00052 #ifdef __PUCK_LOG_LEVEL_INFO__ 00053 #define LOG_INFO(fmt, ...) do { logger.printf("[I] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) 00054 #define __PUCK_LOG_LEVEL_WARN__ 00055 #else 00056 #define LOG_INFO(fmt, ...) 00057 #endif 00058 00059 #ifdef __PUCK_LOG_LEVEL_WARN__ 00060 #define LOG_WARN(fmt, ...) do { logger.printf("![W] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) 00061 #define __PUCK_LOG_LEVEL_ERROR__ 00062 #else 00063 #define LOG_WARN(fmt, ...) 00064 #endif 00065 00066 #ifdef __PUCK_LOG_LEVEL_ERROR__ 00067 #define LOG_ERROR(fmt, ...) do { logger.printf("!![E] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) 00068 #else 00069 #define LOG_ERROR(fmt, ...) 00070 #endif 00071 00072 #ifdef __PUCK_LOG_LEVEL_ERROR__ 00073 static Serial logger(USBTX, USBRX); 00074 #endif 00075 00076 00077 #endif //__LOG__H__
Generated on Wed Jul 13 2022 02:24:32 by 1.7.2