Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 #ifndef __LOG__H__ 00018 #define __LOG__H__ 00019 00020 /** 00021 * Warning: remove LOG_LEVEL_* defines in production for major power savings. 00022 * 00023 * Defining a log level will set up a serial connection to use for logging. 00024 * This serial connection sets up a timer prohibiting the mbed chip 00025 * from entering low power states, drawing ~1.4mAh instead of ~20µAh with logging disabled. 00026 */ 00027 00028 #ifdef LOG_LEVEL_VERBOSE 00029 #define __PUCK_LOG_LEVEL_VERBOSE__ 00030 #endif 00031 #ifdef LOG_LEVEL_DEBUG 00032 #define __PUCK_LOG_LEVEL_DEBUG__ 00033 #endif 00034 #ifdef LOG_LEVEL_INFO 00035 #define __PUCK_LOG_LEVEL_INFO__ 00036 #endif 00037 #ifdef LOG_LEVEL_WARN 00038 #define __PUCK_LOG_LEVEL_WARN__ 00039 #endif 00040 #ifdef LOG_LEVEL_ERROR 00041 #define __PUCK_LOG_LEVEL_ERROR__ 00042 #endif 00043 00044 #ifdef __PUCK_LOG_LEVEL_VERBOSE__ 00045 #define LOG_VERBOSE(fmt, ...) do { logger.printf("[V] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) 00046 #define __PUCK_LOG_LEVEL_DEBUG__ 00047 #else 00048 #define LOG_VERBOSE(fmt, ...) 00049 #endif 00050 00051 #ifdef __PUCK_LOG_LEVEL_DEBUG__ 00052 #define LOG_DEBUG(fmt, ...) do { logger.printf("[D] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) 00053 #define __PUCK_LOG_LEVEL_INFO__ 00054 #else 00055 #define LOG_DEBUG(fmt, ...) 00056 #endif 00057 00058 #ifdef __PUCK_LOG_LEVEL_INFO__ 00059 #define LOG_INFO(fmt, ...) do { logger.printf("[I] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) 00060 #define __PUCK_LOG_LEVEL_WARN__ 00061 #else 00062 #define LOG_INFO(fmt, ...) 00063 #endif 00064 00065 #ifdef __PUCK_LOG_LEVEL_WARN__ 00066 #define LOG_WARN(fmt, ...) do { logger.printf("![W] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) 00067 #define __PUCK_LOG_LEVEL_ERROR__ 00068 #else 00069 #define LOG_WARN(fmt, ...) 00070 #endif 00071 00072 #ifdef __PUCK_LOG_LEVEL_ERROR__ 00073 #define LOG_ERROR(fmt, ...) do { logger.printf("!![E] "); logger.printf(fmt, ##__VA_ARGS__); } while(0) 00074 #else 00075 #define LOG_ERROR(fmt, ...) 00076 #endif 00077 00078 #ifdef __PUCK_LOG_LEVEL_ERROR__ 00079 static Serial logger(USBTX, USBRX); 00080 #endif 00081 00082 00083 #endif //__LOG__H__
Generated on Tue Jul 12 2022 17:25:21 by
1.7.2