F´ Flight Software - C/C++ Documentation NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
LogAssert.cpp
Go to the documentation of this file.
1/*
2 * LogAssert.cpp
3 *
4 * Created on: Sep 9, 2016
5 * Author: tcanham
6 * Note: this file was originally a log assert file, under Fw::Types. It now made generic
7 * to log asserts to Fw::Logger
8 */
9
11#include <Fw/Logger/Logger.hpp>
12
13#if FW_ASSERT_LEVEL == FW_NO_ASSERT
14
15#else
16
17#if FW_ASSERT_LEVEL == FW_FILEID_ASSERT
18#define fileIdFs "Assert file ID %d: Line: %d "
19#define ASSERT_CAST static_cast<POINTER_CAST>
20#else
21#define fileIdFs "Assert file \"%s\": Line: %d "
22#define ASSERT_CAST reinterpret_cast<POINTER_CAST>
23#endif
24
25
26namespace Fw {
27
29
30 }
31
33 }
34
36 FILE_NAME_ARG file,
37 NATIVE_UINT_TYPE lineNo,
38 NATIVE_UINT_TYPE numArgs,
39 FwAssertArgType arg1,
40 FwAssertArgType arg2,
41 FwAssertArgType arg3,
42 FwAssertArgType arg4,
43 FwAssertArgType arg5,
45 ) {
46 // Assumption is that file (when string) goes back to static macro in the code and will persist
47 switch (numArgs) {
48 case 0:
49 Fw::Logger::logMsg(fileIdFs,ASSERT_CAST(file),lineNo,0,0,0,0);
50 break;
51 case 1:
52 Fw::Logger::logMsg(fileIdFs " %d\n",ASSERT_CAST(file),lineNo,arg1,0,0,0);
53 break;
54 case 2:
55 Fw::Logger::logMsg(fileIdFs " %d %d\n",ASSERT_CAST(file),lineNo,arg1,arg2,0,0);
56 break;
57 case 3:
58 Fw::Logger::logMsg(fileIdFs " %d %d %d\n",ASSERT_CAST(file),lineNo,arg1,arg2,arg3,0);
59 break;
60 case 4:
61 Fw::Logger::logMsg(fileIdFs " %d %d %d %d\n",ASSERT_CAST(file),lineNo,arg1,arg2,arg3,arg4);
62 break;
63 default: // can't fit remainder of arguments in log message
64 Fw::Logger::logMsg(fileIdFs " %d %d %d %d +\n",ASSERT_CAST(file),lineNo,arg1,arg2,arg3,arg4);
65 break;
66 }
67
68 }
69
70 void LogAssertHook::printAssert(const CHAR* msg) {
71 // do nothing since reportAssert() sends message
72 }
73
75 }
76
77} // namespace Fw
78
79#endif
char CHAR
Definition BasicTypes.h:28
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:52
PlatformAssertArgType FwAssertArgType
Definition FpConfig.h:21
virtual ~LogAssertHook()
void printAssert(const CHAR *msg)
void reportAssert(FILE_NAME_ARG file, NATIVE_UINT_TYPE lineNo, NATIVE_UINT_TYPE numArgs, FwAssertArgType arg1, FwAssertArgType arg2, FwAssertArgType arg3, FwAssertArgType arg4, FwAssertArgType arg5, FwAssertArgType arg6)
static void logMsg(const char *fmt, POINTER_CAST a0=0, POINTER_CAST a1=0, POINTER_CAST a2=0, POINTER_CAST a3=0, POINTER_CAST a4=0, POINTER_CAST a5=0, POINTER_CAST a6=0, POINTER_CAST a7=0, POINTER_CAST a8=0, POINTER_CAST a9=0)
Definition Logger.cpp:18
Definition Buffer.cpp:21