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.
Fork of AWS-test by
aws-iot/include/aws_iot_log.h@0:cd5404401c2f, 2017-04-12 (annotated)
- Committer:
- peyo
- Date:
- Wed Apr 12 14:07:09 2017 +0200
- Revision:
- 0:cd5404401c2f
first commit
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| peyo |
0:cd5404401c2f | 1 | /* |
| peyo |
0:cd5404401c2f | 2 | * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| peyo |
0:cd5404401c2f | 3 | * |
| peyo |
0:cd5404401c2f | 4 | * Licensed under the Apache License, Version 2.0 (the "License"). |
| peyo |
0:cd5404401c2f | 5 | * You may not use this file except in compliance with the License. |
| peyo |
0:cd5404401c2f | 6 | * A copy of the License is located at |
| peyo |
0:cd5404401c2f | 7 | * |
| peyo |
0:cd5404401c2f | 8 | * http://aws.amazon.com/apache2.0 |
| peyo |
0:cd5404401c2f | 9 | * |
| peyo |
0:cd5404401c2f | 10 | * or in the "license" file accompanying this file. This file is distributed |
| peyo |
0:cd5404401c2f | 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| peyo |
0:cd5404401c2f | 12 | * express or implied. See the License for the specific language governing |
| peyo |
0:cd5404401c2f | 13 | * permissions and limitations under the License. |
| peyo |
0:cd5404401c2f | 14 | */ |
| peyo |
0:cd5404401c2f | 15 | |
| peyo |
0:cd5404401c2f | 16 | /** |
| peyo |
0:cd5404401c2f | 17 | * @file aws_iot_log.h |
| peyo |
0:cd5404401c2f | 18 | * @brief Logging macros for the SDK. |
| peyo |
0:cd5404401c2f | 19 | * This file defines common logging macros with log levels to be used within the SDK. |
| peyo |
0:cd5404401c2f | 20 | * These macros can also be used in the IoT application code as a common way to output |
| peyo |
0:cd5404401c2f | 21 | * logs. The log levels can be tuned by modifying the makefile. Removing (commenting |
| peyo |
0:cd5404401c2f | 22 | * out) the IOT_* statement in the makefile disables that log level. |
| peyo |
0:cd5404401c2f | 23 | * |
| peyo |
0:cd5404401c2f | 24 | * It is expected that the macros below will be modified or replaced when porting to |
| peyo |
0:cd5404401c2f | 25 | * specific hardware platforms as printf may not be the desired behavior. |
| peyo |
0:cd5404401c2f | 26 | */ |
| peyo |
0:cd5404401c2f | 27 | |
| peyo |
0:cd5404401c2f | 28 | #ifndef _IOT_LOG_H |
| peyo |
0:cd5404401c2f | 29 | #define _IOT_LOG_H |
| peyo |
0:cd5404401c2f | 30 | |
| peyo |
0:cd5404401c2f | 31 | #ifdef __cplusplus |
| peyo |
0:cd5404401c2f | 32 | extern "C" { |
| peyo |
0:cd5404401c2f | 33 | #endif |
| peyo |
0:cd5404401c2f | 34 | |
| peyo |
0:cd5404401c2f | 35 | #include <stdio.h> |
| peyo |
0:cd5404401c2f | 36 | #include <stdlib.h> |
| peyo |
0:cd5404401c2f | 37 | |
| peyo |
0:cd5404401c2f | 38 | /** |
| peyo |
0:cd5404401c2f | 39 | * @brief Debug level logging macro. |
| peyo |
0:cd5404401c2f | 40 | * |
| peyo |
0:cd5404401c2f | 41 | * Macro to expose function, line number as well as desired log message. |
| peyo |
0:cd5404401c2f | 42 | */ |
| peyo |
0:cd5404401c2f | 43 | #ifdef ENABLE_IOT_DEBUG |
| peyo |
0:cd5404401c2f | 44 | #define IOT_DEBUG(...) \ |
| peyo |
0:cd5404401c2f | 45 | {\ |
| peyo |
0:cd5404401c2f | 46 | printf("DEBUG: %s L#%d ", __func__, __LINE__); \ |
| peyo |
0:cd5404401c2f | 47 | printf(__VA_ARGS__); \ |
| peyo |
0:cd5404401c2f | 48 | printf("\n"); \ |
| peyo |
0:cd5404401c2f | 49 | } |
| peyo |
0:cd5404401c2f | 50 | #else |
| peyo |
0:cd5404401c2f | 51 | #define IOT_DEBUG(...) |
| peyo |
0:cd5404401c2f | 52 | #endif |
| peyo |
0:cd5404401c2f | 53 | |
| peyo |
0:cd5404401c2f | 54 | /** |
| peyo |
0:cd5404401c2f | 55 | * @brief Debug level trace logging macro. |
| peyo |
0:cd5404401c2f | 56 | * |
| peyo |
0:cd5404401c2f | 57 | * Macro to print message function entry and exit |
| peyo |
0:cd5404401c2f | 58 | */ |
| peyo |
0:cd5404401c2f | 59 | #ifdef ENABLE_IOT_TRACE |
| peyo |
0:cd5404401c2f | 60 | #define FUNC_ENTRY \ |
| peyo |
0:cd5404401c2f | 61 | {\ |
| peyo |
0:cd5404401c2f | 62 | printf("FUNC_ENTRY: %s L#%d \n", __func__, __LINE__); \ |
| peyo |
0:cd5404401c2f | 63 | } |
| peyo |
0:cd5404401c2f | 64 | #define FUNC_EXIT \ |
| peyo |
0:cd5404401c2f | 65 | {\ |
| peyo |
0:cd5404401c2f | 66 | printf("FUNC_EXIT: %s L#%d \n", __func__, __LINE__); \ |
| peyo |
0:cd5404401c2f | 67 | } |
| peyo |
0:cd5404401c2f | 68 | #define FUNC_EXIT_RC(x) \ |
| peyo |
0:cd5404401c2f | 69 | {\ |
| peyo |
0:cd5404401c2f | 70 | printf("FUNC_EXIT: %s L#%d Return Code : %d \n", __func__, __LINE__, x); \ |
| peyo |
0:cd5404401c2f | 71 | return x; \ |
| peyo |
0:cd5404401c2f | 72 | } |
| peyo |
0:cd5404401c2f | 73 | #else |
| peyo |
0:cd5404401c2f | 74 | #define FUNC_ENTRY |
| peyo |
0:cd5404401c2f | 75 | |
| peyo |
0:cd5404401c2f | 76 | #define FUNC_EXIT |
| peyo |
0:cd5404401c2f | 77 | #define FUNC_EXIT_RC(x) { return x; } |
| peyo |
0:cd5404401c2f | 78 | #endif |
| peyo |
0:cd5404401c2f | 79 | |
| peyo |
0:cd5404401c2f | 80 | /** |
| peyo |
0:cd5404401c2f | 81 | * @brief Info level logging macro. |
| peyo |
0:cd5404401c2f | 82 | * |
| peyo |
0:cd5404401c2f | 83 | * Macro to expose desired log message. Info messages do not include automatic function names and line numbers. |
| peyo |
0:cd5404401c2f | 84 | */ |
| peyo |
0:cd5404401c2f | 85 | #ifdef ENABLE_IOT_INFO |
| peyo |
0:cd5404401c2f | 86 | #define IOT_INFO(...) \ |
| peyo |
0:cd5404401c2f | 87 | {\ |
| peyo |
0:cd5404401c2f | 88 | printf(__VA_ARGS__); \ |
| peyo |
0:cd5404401c2f | 89 | printf("\n"); \ |
| peyo |
0:cd5404401c2f | 90 | } |
| peyo |
0:cd5404401c2f | 91 | #else |
| peyo |
0:cd5404401c2f | 92 | #define IOT_INFO(...) |
| peyo |
0:cd5404401c2f | 93 | #endif |
| peyo |
0:cd5404401c2f | 94 | |
| peyo |
0:cd5404401c2f | 95 | /** |
| peyo |
0:cd5404401c2f | 96 | * @brief Warn level logging macro. |
| peyo |
0:cd5404401c2f | 97 | * |
| peyo |
0:cd5404401c2f | 98 | * Macro to expose function, line number as well as desired log message. |
| peyo |
0:cd5404401c2f | 99 | */ |
| peyo |
0:cd5404401c2f | 100 | #ifdef ENABLE_IOT_WARN |
| peyo |
0:cd5404401c2f | 101 | #define IOT_WARN(...) \ |
| peyo |
0:cd5404401c2f | 102 | { \ |
| peyo |
0:cd5404401c2f | 103 | printf("WARN: %s L#%d ", __func__, __LINE__); \ |
| peyo |
0:cd5404401c2f | 104 | printf(__VA_ARGS__); \ |
| peyo |
0:cd5404401c2f | 105 | printf("\n"); \ |
| peyo |
0:cd5404401c2f | 106 | } |
| peyo |
0:cd5404401c2f | 107 | #else |
| peyo |
0:cd5404401c2f | 108 | #define IOT_WARN(...) |
| peyo |
0:cd5404401c2f | 109 | #endif |
| peyo |
0:cd5404401c2f | 110 | |
| peyo |
0:cd5404401c2f | 111 | /** |
| peyo |
0:cd5404401c2f | 112 | * @brief Error level logging macro. |
| peyo |
0:cd5404401c2f | 113 | * |
| peyo |
0:cd5404401c2f | 114 | * Macro to expose function, line number as well as desired log message. |
| peyo |
0:cd5404401c2f | 115 | */ |
| peyo |
0:cd5404401c2f | 116 | #ifdef ENABLE_IOT_ERROR |
| peyo |
0:cd5404401c2f | 117 | #define IOT_ERROR(...) \ |
| peyo |
0:cd5404401c2f | 118 | { \ |
| peyo |
0:cd5404401c2f | 119 | printf("ERROR: %s L#%d ", __func__, __LINE__); \ |
| peyo |
0:cd5404401c2f | 120 | printf(__VA_ARGS__); \ |
| peyo |
0:cd5404401c2f | 121 | printf("\n"); \ |
| peyo |
0:cd5404401c2f | 122 | } |
| peyo |
0:cd5404401c2f | 123 | #else |
| peyo |
0:cd5404401c2f | 124 | #define IOT_ERROR(...) |
| peyo |
0:cd5404401c2f | 125 | #endif |
| peyo |
0:cd5404401c2f | 126 | |
| peyo |
0:cd5404401c2f | 127 | #ifdef __cplusplus |
| peyo |
0:cd5404401c2f | 128 | } |
| peyo |
0:cd5404401c2f | 129 | #endif |
| peyo |
0:cd5404401c2f | 130 | |
| peyo |
0:cd5404401c2f | 131 | #endif // _IOT_LOG_H |
