157 lines
5.5 KiB
C
157 lines
5.5 KiB
C
/*****************************************************************************/
|
|
/* FILENAME : Log.h */
|
|
/* */
|
|
/* DESCRIPTION : Generic Uart Logger Library */
|
|
/* */
|
|
/* NOTES : Copyright Sathish Kumar P. All rights reserved. */
|
|
/* */
|
|
/* AUTHOR : Sathish Kumar */
|
|
/* sathishembeddedgeek@gmail.com */
|
|
/* */
|
|
/* START DATE : 3rd May 2021 */
|
|
/* */
|
|
/* VERSION DATE WHO DETAIL */
|
|
/* 00.00.01 03MAY21 Sathish Kumar initial version */
|
|
/* */
|
|
/*****************************************************************************/
|
|
|
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
#ifndef _LOG_H_
|
|
#define _LOG_H_
|
|
/*****************************************************************************/
|
|
/* I N C L U D E S */
|
|
/*****************************************************************************/
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <system.h>
|
|
#include <Log_conf.h>
|
|
|
|
/*****************************************************************************/
|
|
/* D E F I N I N T I O N S */
|
|
/*****************************************************************************/
|
|
|
|
/* log usage macro */
|
|
#define LOG(level,...) Log_TString(level,__VA_ARGS__)
|
|
|
|
/*****************************************************************************/
|
|
/* T Y P E D E F S */
|
|
/*****************************************************************************/
|
|
|
|
/**
|
|
* \enum LogLevel_t
|
|
* \brief Log Level enumerations
|
|
*/
|
|
typedef enum _log_type_t_
|
|
{
|
|
LOG_DEBUG = 0, /**< log level debug. */
|
|
LOG_INFO, /**< log level info. */
|
|
LOG_WARNING, /**< log level warning. */
|
|
LOG_ERROR, /**< log level error. */
|
|
LOG_FATAL, /**< log level fatal. */
|
|
LOG_ALL, /**< log level ALL. */
|
|
LOG_MAX=0xFF
|
|
}LogLevel_t;
|
|
|
|
extern const uint8_t *log_type[];
|
|
|
|
/*****************************************************************************/
|
|
/* F U N C T I O N P R O T O T Y P E S */
|
|
/*****************************************************************************/
|
|
|
|
/*!
|
|
* \fn Log_Init
|
|
* \brief This function Initialise the Log interface.
|
|
* \param None.
|
|
* \retval uint8_t 0 - success ,
|
|
* 1 - failure.
|
|
*/
|
|
uint8_t Log_Init( void );
|
|
|
|
/*!
|
|
* \fn Log_Task
|
|
* \brief This function Runs the task related to logging.
|
|
* \param call_rate(uint32_t) -> periodic task time in milliseconds.
|
|
* \retval none.
|
|
*/
|
|
void Log_Task(uint32_t call_rate);
|
|
|
|
/*!
|
|
* \fn Log_GetEnabledStatus
|
|
* \brief This get the status of Logging interface.
|
|
* \retval 1 if enabled.
|
|
* 0 if disabled.
|
|
*/
|
|
uint8_t Log_GetEnabledStatus();
|
|
|
|
/*!
|
|
* \fn Log_Enable
|
|
* \brief This function enables or disables the Logging interface.
|
|
* \param enable -> 1 to enable logging.
|
|
* 0 to disable logging.
|
|
* \retval none.
|
|
*/
|
|
void Log_Enable(uint8_t enable);
|
|
|
|
/*!
|
|
* \fn Log_LowPowerMode
|
|
* \brief Used to set the Log UART to low power mode
|
|
* \param enable -> 1 to enable low power mode.
|
|
* 0 to disable low power mode.
|
|
* \retval none.
|
|
*/
|
|
void Log_LowPowerMode(uint8_t enable);
|
|
|
|
/*!
|
|
* \fn Log_IsPendingTx
|
|
* \brief This function returns the whether there are active logs pending for transmission.
|
|
* \retval 1 if pending logs in queues.
|
|
* 0 if no pending logs.
|
|
*/
|
|
uint8_t Log_IsPendingTx(void);
|
|
|
|
/*!
|
|
* \fn Log_GetLogLvl
|
|
* \brief This get the current log level of Logging interface.
|
|
* \retval current log level @enum LogLevel_t.
|
|
*/
|
|
LogLevel_t Log_GetLogLvl();
|
|
|
|
/*!
|
|
* \fn Log_SetLogLvl
|
|
* \brief Used to change the current log level.
|
|
* \param new_log_lvl -> new log level to be set.
|
|
* \retval none.
|
|
*/
|
|
void Log_SetLogLvl(LogLevel_t new_log_lvl);
|
|
|
|
/*!
|
|
* \fn Log_TString
|
|
* \brief Logging a string based on the given parameeters.
|
|
* \param[in] log_lvl -> Logging level as per enum LogLevel_t.
|
|
* \param[in] str -> pointer to the string buffer to log.
|
|
* \param[in] ... -> argument list
|
|
* \retval none.
|
|
*/
|
|
void Log_TString(LogLevel_t log_lvl,const char *str, ...);
|
|
|
|
/*!
|
|
* \fn Log_UartSend
|
|
* \brief Send any 8bit buffer to log uart. Used in case of Production test prints.
|
|
* \param[in] buf -> pointer to the buffer to send.
|
|
* \param[in] bufLen -> lenght of buffer.
|
|
* \retval none.
|
|
*/
|
|
void Log_UartSend(uint8_t *buf,uint16_t bufLen);
|
|
|
|
/*!
|
|
* \fn Log_UartTxCompleteCallback
|
|
* \brief To be Called from Uart TX complete ISR();
|
|
* \retval none.
|
|
*/
|
|
void Log_UartTxCompleteCallback(void);
|
|
|
|
/*****************************************************************************/
|
|
/* E N D O F F I L E */
|
|
/*****************************************************************************/
|
|
#endif /* _LOG_H_ */
|