Host API Example for the ADMW1001

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers admw_log.h Source File

admw_log.h

Go to the documentation of this file.
00001 /*
00002 Copyright 2019 (c) Analog Devices, Inc.
00003 
00004 All rights reserved.
00005 
00006 Redistribution and use in source and binary forms, with or without
00007 modification, are permitted provided that the following conditions are met:
00008   - Redistributions of source code must retain the above copyright
00009     notice, this list of conditions and the following disclaimer.
00010   - Redistributions in binary form must reproduce the above copyright
00011     notice, this list of conditions and the following disclaimer in
00012     the documentation and/or other materials provided with the
00013     distribution.
00014   - Neither the name of Analog Devices, Inc. nor the names of its
00015     contributors may be used to endorse or promote products derived
00016     from this software without specific prior written permission.
00017   - The use of this software may or may not infringe the patent rights
00018     of one or more patent holders. This license does not release you
00019     from the requirement that you obtain separate licenses from these
00020     patent holders to use this software.
00021   - Use of the software either in source or binary form, must be run
00022     on or directly connected to an Analog Devices Inc. component.
00023 
00024 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
00025 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
00026 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00027 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
00028 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00029 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
00030 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00032 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00033 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034 */
00035 
00036 /*!
00037  ******************************************************************************
00038  * @file:   admw_log.h
00039  * @brief:  ADMW OS-dependent wrapper layer for log functions
00040  *-----------------------------------------------------------------------------
00041  */
00042 
00043 #ifndef __ADMW_LOG_H__
00044 #define __ADMW_LOG_H__
00045 
00046 #include "inc/admw_types.h"
00047 
00048 /*! @ingroup ADMW_Host */
00049 
00050 /*! @addtogroup ADMW_Log ADMW Host Logging functions
00051  *  @{
00052  */
00053 
00054 /*! Macro function for logging an error message */
00055 #define ADMW_LOG_ERROR(...)                                        \
00056     admw_Log(ADMW_LOG_LEVEL_ERROR, "[ERROR] " __VA_ARGS__)
00057 /*! Macro function for logging a warning message */
00058 #define ADMW_LOG_WARN(...)  \
00059     admw_Log(ADMW_LOG_LEVEL_WARN,  "[WARN] "  __VA_ARGS__)
00060 /*! Macro function for logging an information message */
00061 #define ADMW_LOG_INFO(...)  \
00062     admw_Log(ADMW_LOG_LEVEL_INFO,  "[INFO] "  __VA_ARGS__)
00063 /*! Macro function for logging a debug message */
00064 #define ADMW_LOG_DEBUG(...) \
00065     admw_Log(ADMW_LOG_LEVEL_DEBUG, "[DEBUG] " __VA_ARGS__)
00066 
00067 /*!
00068  * Log message priority levels
00069  */
00070 typedef enum
00071 {
00072     ADMW_LOG_LEVEL_ERROR  = 0, /*!< Error message priority */
00073     ADMW_LOG_LEVEL_WARN ,      /*!< Warning message priority */
00074     ADMW_LOG_LEVEL_INFO ,      /*!< Information message priority */
00075     ADMW_LOG_LEVEL_DEBUG ,     /*!< Debug message priority */
00076 } ADMW_LOG_LEVEL ;
00077 
00078 
00079 #ifdef __cplusplus
00080 extern "C"
00081 {
00082 #endif
00083 
00084 /*!
00085  * @brief Initialise the Log interface and allocate resources.
00086  *
00087  * @return Status
00088  *         - #ADMW_SUCCESS Call completed successfully.
00089  *         - #ADMW_NO_MEM  Failed to allocate memory for device context.
00090  */
00091 ADMW_RESULT  admw_LogOpen(
00092     ADMW_PLATFORM_LOG_CONFIG *pConfig);
00093 
00094 /*!
00095  * @brief Close the Log interface and free resources.
00096  */
00097 void admw_LogClose(void);
00098 
00099 /*!
00100  * @brief Set the minimum priority level for the log messages.
00101  *
00102  * @param[in]  maxLevel priority level
00103  *
00104  * @details Sets the log priority level.  Messages with priority lower
00105             that this level will not be passed to the log interface.
00106  */
00107 void admw_LogLevel(
00108     ADMW_LOG_LEVEL  maxLevel);
00109 
00110 /*!
00111  * @brief Print a log message to the platform log interface.
00112  *
00113  * @param[in] level  Log message priority level
00114  * @param[in] format Format string and variable argument list, if any
00115  */
00116 void admw_Log(
00117     ADMW_LOG_LEVEL    level,
00118     const char          * format,
00119     ...);
00120 
00121 #ifdef __cplusplus
00122 }
00123 #endif
00124 
00125 /*!
00126  * @}
00127  */
00128 
00129 #endif /* __ADMW_LOG_H__ */