mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-06-16 12:29:00 -04:00
* fix for not switching to active call * Added missing icons during unaswered outgoing call + some error logging * Added additional logging to AT commands defult timeout set to 300 ms. Set different timeouts per each AT command. Minor code refactoring. * Added some logging, fixed some timeouts and number of returned tockens. * commented out not needed log * Added LOG_CUSTOM logging support. Remove unnecessary LOG_ERRORS. * set ATA cmd timeout to 90 sec * PR fixes
78 lines
2.4 KiB
C++
78 lines
2.4 KiB
C++
/*
|
|
* @file log.h
|
|
* @author mateuszpiesta (mateusz.piesta@mudita.com)
|
|
* @date 5 cze 2018
|
|
* @brief Generic logging utilities.
|
|
* This module is wrapper over printf with additional thread safety provided and common logs levels.
|
|
*
|
|
* USAGE:
|
|
*
|
|
* Include this header in any file that wishes to write to logger(s). In
|
|
* exactly one file (per executable), define LOG_MAIN first (e.g. in your
|
|
* main .c file).
|
|
*
|
|
* #define LOG_MAIN
|
|
* #include "logs/log.h"
|
|
*
|
|
* This will define the actual objects that all the other units will use.
|
|
* Then invoke log_Init(VFS_FILE* fp,logger_level level) function to initialize logger utility. If you want additionally store
|
|
* logs into file pass valid file descriptor to init function. By default logger logs info into STDOUT stream.
|
|
* After that logger is ready to use.
|
|
*
|
|
* Examples:
|
|
* 1)
|
|
* log_Init(NULL,LOGDEBUG);
|
|
* Send logs(level higher or equal to LOGDEBUG) to STDOUT stream.
|
|
*
|
|
* 2)
|
|
* log_Init('valid file pointer',LOGINFO);
|
|
* Send logs(level higher or equal to LOGINFO) to STDOUT stream and also to file specified by user.
|
|
*/
|
|
|
|
#ifndef LOG_LOG_H_
|
|
#define LOG_LOG_H_
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
|
|
typedef enum { LOGTRACE, LOGDEBUG, LOGINFO, LOGWARN, LOGERROR, LOGFATAL }logger_level;
|
|
|
|
|
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
|
|
|
|
|
|
/**
|
|
* Forward declarations
|
|
*/
|
|
void log_Log(logger_level level, const char *file, int line,const char *function, const char *fmt, ...);
|
|
void log_SetLevel(logger_level level);
|
|
void log_Printf(const char *fmt, ...);
|
|
|
|
|
|
/**
|
|
* Log functions (one per level).
|
|
*/
|
|
#define LOG_PRINTF(...) log_Printf(__VA_ARGS__)
|
|
#define LOG_TRACE(...) log_Log(LOGTRACE, __FILENAME__, __LINE__,__func__, __VA_ARGS__)
|
|
#define LOG_DEBUG(...) log_Log(LOGDEBUG, __FILENAME__, __LINE__,__func__, __VA_ARGS__)
|
|
#define LOG_INFO(...) log_Log(LOGINFO, __FILENAME__, __LINE__,__func__, __VA_ARGS__)
|
|
#define LOG_WARN(...) log_Log(LOGWARN, __FILENAME__, __LINE__,__func__, __VA_ARGS__)
|
|
#define LOG_ERROR(...) log_Log(LOGERROR, __FILENAME__, __LINE__,__func__, __VA_ARGS__)
|
|
#define LOG_FATAL(...) log_Log(LOGFATAL, __FILENAME__, __LINE__,__func__, __VA_ARGS__)
|
|
#define LOG_CUSTOM(loggerLevel, ...) log_Log(loggerLevel, __FILENAME__, __LINE__,__func__, __VA_ARGS__)
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* LOG_LOG_H_ */
|