00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef LOW_HELPER_MSGLOG_H
00019 #define LOW_HELPER_MSGLOG_H
00020
00021
00022 #include <stdint.h>
00023 #include <stdarg.h>
00024 #include <stdio.h>
00025
00026
00027 #include "LOW_semaphoreSet.h"
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class LOW_helper_msglog {
00040
00041
00042 public:
00043
00044
00045
00046
00047
00048
00049 typedef enum {
00050 portSerial_dl,
00051 devDS1820_dl,
00052 linkLock_dl,
00053 all_dl
00054 } debugLevel_t;
00055
00056
00057
00058
00059
00060
00061
00062 static void enableDebugLevel( const debugLevel_t inLevel, const bool isEnabled = true);
00063
00064
00065
00066
00067 static void printPerror( const int inErrno, const char *inFormat, ...);
00068
00069
00070
00071
00072 static void printError( const char *inFormat, ...);
00073
00074
00075
00076
00077 static void printWarning( const char *inFormat, ...);
00078
00079
00080
00081
00082 static void printMessage( const char *inFormat, ...);
00083
00084
00085
00086
00087 static void printDebug( const debugLevel_t inLevel, const char *inFormat, ...);
00088
00089
00090
00091 private:
00092
00093
00094
00095
00096
00097
00098 class msgLock {
00099 public:
00100 msgLock();
00101 ~msgLock();
00102 static LOW_semaphoreSet* semaphoreInit();
00103
00104 private:
00105 static LOW_semaphoreSet *semSet;
00106 };
00107
00108
00109
00110
00111
00112
00113
00114 typedef enum { msg_log, warn_log, err_log, debug_log} logType_t;
00115
00116
00117
00118
00119
00120
00121
00122 static bool errorOccured;
00123 static bool debugLevels[all_dl];
00124
00125 static bool useStdMsgStream;
00126 static bool useStdWarnStream;
00127 static bool useStdErrStream;
00128 static bool useStdDebugStream;
00129 static bool useExtraMsgStream;
00130 static bool useExtraWarnStream;
00131 static bool useExtraErrStream;
00132 static bool useExtraDebugStream;
00133
00134 static FILE* stdOutStream;
00135 static FILE* stdWarnStream;
00136 static FILE* stdErrStream;
00137 static FILE* stdDebugStream;
00138 static FILE* extraOutStream;
00139 static FILE* extraWarnStream;
00140 static FILE* extraErrStream;
00141 static FILE* extraDebugStream;
00142
00143
00144
00145
00146
00147
00148
00149 static void va_printToLog( const logType_t inLogType, const char *inFormat, va_list inParamList);
00150 static unsigned int fprintLogHeader( FILE *inExtraStream, FILE *inStdStream);
00151 static void fprintfMulti( FILE *inExtraStream, FILE *inStdStream, const char *inFormat, ...);
00152 static void vfprintfMulti( FILE *inExtraStream, FILE *inStdStream, const char *inFormat, va_list inAp);
00153 static void* callocCheck( const size_t inSize);
00154
00155 };
00156
00157 #endif
00158