| 1 | |
| 2 | // Copyright (c) 2003-2019 Xsens Technologies B.V. or subsidiaries worldwide. |
| 3 | // All rights reserved. |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without modification, |
| 6 | // are permitted provided that the following conditions are met: |
| 7 | // |
| 8 | // 1. Redistributions of source code must retain the above copyright notice, |
| 9 | // this list of conditions, and the following disclaimer. |
| 10 | // |
| 11 | // 2. Redistributions in binary form must reproduce the above copyright notice, |
| 12 | // this list of conditions, and the following disclaimer in the documentation |
| 13 | // and/or other materials provided with the distribution. |
| 14 | // |
| 15 | // 3. Neither the names of the copyright holders nor the names of their contributors |
| 16 | // may be used to endorse or promote products derived from this software without |
| 17 | // specific prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
| 20 | // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 21 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 22 | // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 24 | // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 25 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR |
| 26 | // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 27 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS |
| 28 | // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES |
| 29 | // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE |
| 30 | // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES. |
| 31 | // |
| 32 | |
| 33 | #ifndef JOURNALLOGLEVEL_H |
| 34 | #define JOURNALLOGLEVEL_H |
| 35 | |
| 36 | #ifdef ANDROID |
| 37 | #include <android/log.h> |
| 38 | |
| 39 | #define JLL_TRACE ANDROID_LOG_VERBOSE |
| 40 | #define JLL_DEBUG ANDROID_LOG_DEBUG |
| 41 | #define JLL_ALERT ANDROID_LOG_WARN |
| 42 | #define JLL_ERROR ANDROID_LOG_ERROR |
| 43 | #define JLL_FATAL ANDROID_LOG_FATAL |
| 44 | #define JLL_WRITE ANDROID_LOG_SILENT |
| 45 | #define JLL_DISABLE (JLL_WRITE+1) |
| 46 | #else |
| 47 | #define JLL_TRACE 0 |
| 48 | #define JLL_DEBUG 1 |
| 49 | #define JLL_ALERT 2 |
| 50 | #define JLL_ERROR 3 |
| 51 | #define JLL_FATAL 4 |
| 52 | #define JLL_WRITE 5 |
| 53 | #define JLL_DISABLE 6 |
| 54 | #endif |
| 55 | |
| 56 | enum JournalLogLevel { |
| 57 | JLL_Trace = JLL_TRACE //!< log all messages, including function entry/exit |
| 58 | , JLL_Debug = JLL_DEBUG //!< log all messages, except function entry/exit (trace) |
| 59 | , JLL_Alert = JLL_ALERT //!< only log fatal, error and alert messages |
| 60 | , JLL_Error = JLL_ERROR //!< only log fatal and error messages |
| 61 | , JLL_Fatal = JLL_FATAL //!< only log fatal messages |
| 62 | , JLL_Write = JLL_WRITE //!< only log 'write' messages |
| 63 | , JLL_Diable= JLL_DISABLE //!< don't log any messages |
| 64 | }; |
| 65 | |
| 66 | #ifdef NO_JOURNALLER |
| 67 | #ifdef JLDEF_BUILD |
| 68 | #undef JLDEF_BUILD |
| 69 | #endif |
| 70 | #define JLDEF_BUILD JLL_DISABLE |
| 71 | #endif |
| 72 | |
| 73 | #ifdef XSENS_DEBUG |
| 74 | #ifndef XSENS_RELEASE |
| 75 | // full debug |
| 76 | #ifndef JLDEF_BUILD |
| 77 | #define JLDEF_BUILD JLL_DEBUG // 'trace' needs to be enabled explicitly since it potentially has a huge impact on performance |
| 78 | #endif |
| 79 | #ifndef JLDEF_FILE |
| 80 | #define JLDEF_FILE JLL_Debug |
| 81 | #endif |
| 82 | #ifndef JLDEF_DEBUGGER |
| 83 | #define JLDEF_DEBUGGER JLL_Alert |
| 84 | #endif |
| 85 | #else |
| 86 | // Release With Debug Info (non-optimized Release build) |
| 87 | #ifndef JLDEF_BUILD |
| 88 | #define JLDEF_BUILD JLL_DEBUG |
| 89 | #endif |
| 90 | #ifndef JLDEF_FILE |
| 91 | #define JLDEF_FILE JLL_Debug |
| 92 | #endif |
| 93 | #ifndef JLDEF_DEBUGGER |
| 94 | #define JLDEF_DEBUGGER JLL_Error |
| 95 | #endif |
| 96 | #endif |
| 97 | #else |
| 98 | // Full optimized Release build, logging should be reduced to a minimum |
| 99 | #ifndef JLDEF_BUILD |
| 100 | #define JLDEF_BUILD JLL_ALERT |
| 101 | #endif |
| 102 | #ifndef JLDEF_FILE |
| 103 | #define JLDEF_FILE JLL_Alert |
| 104 | #endif |
| 105 | #ifndef JLDEF_DEBUGGER |
| 106 | #define JLDEF_DEBUGGER JLL_Fatal |
| 107 | #endif |
| 108 | #define JLNOLINEINFO |
| 109 | #endif |
| 110 | |
| 111 | #endif |