Logging » Historie » Version 2
  Maximilian Seesslen, 21.12.2022 13:29 
  
| 1 | 1 | Maximilian Seesslen | h1. Logging  | 
|---|---|---|---|
| 2 | |||
| 3 | 2 | Maximilian Seesslen | There is no clean logging concept at the moment.  | 
| 4 | 1 | Maximilian Seesslen | |
| 5 | 2 | Maximilian Seesslen | * Work within ISRs.  | 
| 6 | * Only short messages, e.g. 20 chars.  | 
||
| 7 | * Heart-beat LED might be involved  | 
||
| 8 | * CAN might be involved to transmit diagnose  | 
||
| 9 | * Debug can be disabled even for Debug-builds; BIWAK_LOG_DEBUG has to be defined to show bDebug  | 
||
| 10 | |||
| 11 | h2. Heartbeat-Class  | 
||
| 12 | |||
| 13 | An LED can indicate problems.  | 
||
| 14 | |||
| 15 | 1 | Maximilian Seesslen | * good (double)  | 
| 16 | * crytical error (fast blink)  | 
||
| 17 | * fatal error (slow blink)  | 
||
| 18 | * temporary error/ trouble (fast blink - off 1Hz) (goes away)  | 
||
| 19 | |||
| 20 | 2 | Maximilian Seesslen | h2. Usecases  | 
| 21 | 1 | Maximilian Seesslen | |
| 22 | * invalid eeprom causes "critical"-state  | 
||
| 23 | * Not being able to sen CAN messages causes "trouble"  | 
||
| 24 | * fatal: the application can not run for some reason but the led should work; e.g. a reception buffer is full  | 
||
| 25 | * exception: Don't even try to run any more. e.g. memory error.  | 
||
| 26 | |||
| 27 | 2 | Maximilian Seesslen | h2. Examples  | 
| 28 | |||
| 29 | <pre><code class="cpp">  | 
||
| 30 | add_definitions( BIWAK_LOG_HEARTBEAT )  | 
||
| 31 | add_definitions( BIWAK_LOG_CAN )  | 
||
| 32 | add_definitions( BIWAK_LOG_DEBUG )  | 
||
| 33 | |||
| 34 | #define bDebug(a,...) debug(a, __VA_ARGS__)  | 
||
| 35 | </code></pre>  | 
||
| 36 | |||
| 37 | <pre><code class="cpp">  | 
||
| 38 | #include <biwak/log.hpp>  | 
||
| 39 | |||
| 40 | main()  | 
||
| 41 | { | 
||
| 42 | bDebug(); // Just print some text  | 
||
| 43 | bCritical();  | 
||
| 44 | bTrouble(); //  | 
||
| 45 | bFatal();  | 
||
| 46 |    bException("Static text"); | 
||
| 47 | }  | 
||
| 48 | </code></pre>  |