Files
hsb/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/hsb-mrts/inc/Logger.h
mmi 1bcb4809db - added IODevice support
- fixed some issues with the logger and stack sizes

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@216 05563f52-14a8-4384-a975-3d1654cca0fa
2017-09-26 11:11:33 +00:00

126 lines
4.0 KiB
C

// -----------------------------------------------------------------------------
/// @file Logger.h
/// @brief File description
// -----------------------------------------------------------------------------
// Micro-Key bv
// Industrieweg 28, 9804 TG Noordhorn
// Postbus 92, 9800 AB Zuidhorn
// The Netherlands
// Tel: +31 594 503020
// Fax: +31 594 505825
// Email: support@microkey.nl
// Web: www.microkey.nl
// -----------------------------------------------------------------------------
/// $Revision$
/// $Author$
/// $Date$
// (c) 2017 Micro-Key bv
// -----------------------------------------------------------------------------
/// @defgroup {group_name} {group_description}
/// Description
/// @file Logger.h
/// @ingroup {group_name}
#ifndef _LOGGER_H_
#define _LOGGER_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include "stm32f10x.h"
#include "platform.h"
#include "IODevice.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
/**
* Logs an error
* \memberof Logger
*/
#define LOGGER_ERROR(...) \
Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_ERROR, ##__VA_ARGS__)
#define LOGGER_WARNING(...) \
Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_WARNING, ##__VA_ARGS__)
#define LOGGER_INFO(...) \
Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_INFO, ##__VA_ARGS__)
#define LOGGER_DEBUG(...) \
Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_DEBUG, ##__VA_ARGS__)
#define LOGGER_PRINT(...) \
Logger_log("", "", 0, LOGTYPE_PRINT, ##__VA_ARGS__)
#define LOGGER_ERROR_ISR(...) \
Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_ERROR, ##__VA_ARGS__)
#define LOGGER_WARNING_ISR(...) \
Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_WARNING, ##__VA_ARGS__)
#define LOGGER_INFO_ISR(...) \
Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_INFO, ##__VA_ARGS__)
#define LOGGER_DEBUG_ISR(...) \
Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_DEBUG, ##__VA_ARGS__)
#define LOGGER_PRINT_ISR(...) \
Logger_logISR("", "", 0, LOGTYPE_PRINT, ##__VA_ARGS__)
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
typedef enum
{
LOGTYPE_PRINT, /**< Raw print */
LOGTYPE_DEBUG, /**< Debug information only; will not be stored on SD-card */
LOGTYPE_INFO, /**< Informational messages of important events */
LOGTYPE_WARNING, /**< Recoverable fault */
LOGTYPE_ERROR /**< Unrecoverable fault */
} LogType;
struct LogQueueItem
{
char fileName[32];
char functionName[32];
char context[128];
int lineNumber;
LogType logType;
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
ErrorStatus Logger_construct(struct IODevice* const device);
void Logger_terminate(void);
void Logger_logISR(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* context);
ErrorStatus Logger_addCommandHandlers(void);
extern ErrorStatus Logger_logModuleInfo(void);
/**
* Logs a string.
* Use the Logging macros instead
* \memberof Logger
* \private
* \param fileName File name to be logged
* \param functionName Function name to be logged
* \param lineNumber Line number to be logged
* \param logType Type of logging
* \param format printf-type formatting string
* \param ... Variable arguments according to the formatting string
*/
void Logger_log(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...) __attribute__((format(printf, 5, 6)));
#endif