Logging » Historie » Revision 5
Revision 4 (Maximilian Seesslen, 21.12.2022 14:07) → Revision 5/6 (Maximilian Seesslen, 21.12.2022 14:39)
h1. Logging
There is no clean logging concept at the moment.
* Low footprint
* Work within ISRs. The output is delayed. The order is preserved.
* Only short messages, e.g. 20 chars.
* Heart-beat LED might be involved
* CAN might be involved to transmit diagnose
* Debug can be disabled even for Debug-builds; BIWAK_LOG_DEBUG has to be defined to show bDebug
h2. Heartbeat-Class
An LED can indicate problems.
* good (double heartbeat)
* critical error/ exception (fast blink)
* fatal error (slow blink)
* temporary error/ trouble (fast blink - off 1Hz) (goes away)
h2. Usecases
* invalid eeprom causes "critical"-state
* Not being able to sen CAN messages causes "trouble"
* fatal: the application can not run for some reason but the led should work; e.g. a reception buffer is full
* exception: Don't even try to run any more. e.g. memory error.
h2. Notes
There is already a doublebuffer-class for CAN.
h2. Examples
<pre><code class="cpp">
add_definitions( BIWAK_LOG_HEARTBEAT )
add_definitions( BIWAK_LOG_CAN )
add_definitions( BIWAK_LOG_DEBUG )
#define bDebug(a,...) debug(a, __VA_ARGS__)
</code></pre>
<pre><code class="cpp">
#include <biwak/log.hpp>
main()
{
bDebug(); // Just print some text
bCritical();
bTrouble(); //
bFatal();
bException("Static text");
}
</code></pre>
<pre><code class="cpp">
static struct {
char buf[20];
bool used;
}buffers[2]={0};
void bWarning(const char *text, ...)
{
va_list list;
va_start(list, text);
int bufid;
for(bufid=0; bufid < ARRAY_ELEMENTS(buffers); bufid++)
{
if(!buffers[bufid].used)
{
break;
}
}
if(bufid >= ARRAY_ELEMENTS(buffers))
{
bException("Out of log buffers!");
}
buffers[bufid].used=true;
vsnprintf(buffers[bufid].buf, 20, text, list);
puts(buffers[bufid].buf);
printf("Bufid: %d; elements: %d\n", bufid, ARRAY_ELEMENTS(buffers));
};
</code></pre>
There is no clean logging concept at the moment.
* Low footprint
* Work within ISRs. The output is delayed. The order is preserved.
* Only short messages, e.g. 20 chars.
* Heart-beat LED might be involved
* CAN might be involved to transmit diagnose
* Debug can be disabled even for Debug-builds; BIWAK_LOG_DEBUG has to be defined to show bDebug
h2. Heartbeat-Class
An LED can indicate problems.
* good (double heartbeat)
* critical error/ exception (fast blink)
* fatal error (slow blink)
* temporary error/ trouble (fast blink - off 1Hz) (goes away)
h2. Usecases
* invalid eeprom causes "critical"-state
* Not being able to sen CAN messages causes "trouble"
* fatal: the application can not run for some reason but the led should work; e.g. a reception buffer is full
* exception: Don't even try to run any more. e.g. memory error.
h2. Notes
There is already a doublebuffer-class for CAN.
h2. Examples
<pre><code class="cpp">
add_definitions( BIWAK_LOG_HEARTBEAT )
add_definitions( BIWAK_LOG_CAN )
add_definitions( BIWAK_LOG_DEBUG )
#define bDebug(a,...) debug(a, __VA_ARGS__)
</code></pre>
<pre><code class="cpp">
#include <biwak/log.hpp>
main()
{
bDebug(); // Just print some text
bCritical();
bTrouble(); //
bFatal();
bException("Static text");
}
</code></pre>
<pre><code class="cpp">
static struct {
char buf[20];
bool used;
}buffers[2]={0};
void bWarning(const char *text, ...)
{
va_list list;
va_start(list, text);
int bufid;
for(bufid=0; bufid < ARRAY_ELEMENTS(buffers); bufid++)
{
if(!buffers[bufid].used)
{
break;
}
}
if(bufid >= ARRAY_ELEMENTS(buffers))
{
bException("Out of log buffers!");
}
buffers[bufid].used=true;
vsnprintf(buffers[bufid].buf, 20, text, list);
puts(buffers[bufid].buf);
printf("Bufid: %d; elements: %d\n", bufid, ARRAY_ELEMENTS(buffers));
};
</code></pre>