F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
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 
10 #include <Fw/Logger/LogAssert.hpp>
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: %d:%d"
19 #define ASSERT_CAST static_cast<POINTER_CAST>
20 #else
21 #define fileIdFs "Assert: \"%s:%d\""
22 #define ASSERT_CAST reinterpret_cast<POINTER_CAST>
23 #endif
24 
25 
26 namespace 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,
44  FwAssertArgType arg6
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:
50  fileIdFs,
51  ASSERT_CAST(file),
52  lineNo,
53  0,
54  0,
55  0,
56  0);
57  break;
58  case 1:
60  fileIdFs " %d\n",
61  ASSERT_CAST(file),lineNo,
62  static_cast<POINTER_CAST>(arg1),
63  0,
64  0,
65  0);
66  break;
67  case 2:
69  fileIdFs " %d %d\n",
70  ASSERT_CAST(file),lineNo,
71  static_cast<POINTER_CAST>(arg1),
72  static_cast<POINTER_CAST>(arg2),
73  0,
74  0);
75  break;
76  case 3:
78  fileIdFs " %d %d %d\n",
79  ASSERT_CAST(file),lineNo,
80  static_cast<POINTER_CAST>(arg1),
81  static_cast<POINTER_CAST>(arg2),
82  static_cast<POINTER_CAST>(arg3),
83  0);
84  break;
85  case 4:
87  fileIdFs " %d %d %d %d\n",
88  ASSERT_CAST(file),lineNo,
89  static_cast<POINTER_CAST>(arg1),
90  static_cast<POINTER_CAST>(arg2),
91  static_cast<POINTER_CAST>(arg3),
92  static_cast<POINTER_CAST>(arg4));
93  break;
94  default: // can't fit remainder of arguments in log message
96  fileIdFs " %d %d %d %d +\n",
97  ASSERT_CAST(file),lineNo,
98  static_cast<POINTER_CAST>(arg1),
99  static_cast<POINTER_CAST>(arg2),
100  static_cast<POINTER_CAST>(arg3),
101  static_cast<POINTER_CAST>(arg4));
102  break;
103  }
104 
105  }
106 
107  void LogAssertHook::printAssert(const CHAR* msg) {
108  // do nothing since reportAssert() sends message
109  }
110 
111  void LogAssertHook::doAssert() {
112  }
113 
114 } // namespace Fw
115 
116 #endif
#define fileIdFs
Definition: Assert.cpp:9
#define FILE_NAME_ARG
Definition: Assert.hpp:16
PlatformPointerCastType POINTER_CAST
Definition: BasicTypes.h:53
char CHAR
Definition: BasicTypes.h:28
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:52
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:34
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)
destructor
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