-
Notifications
You must be signed in to change notification settings - Fork 1
TRACE Levels
Each TRACE or TLOG in code has a trace “name” associated with it. Each
TRACE or TLOG also has a level
associated with it. The “name” is static and the level can be variable
from 0-63, corresponding to bits in a 64 bit mask.
There are actually 3 masks that control 3 functions: 1) fast/memory, 2)
slow/stdout, and 3) trigger.
The names and level masks are displayed using the “tlvls” function:
mode: M=1 S=1
TID NAME maskM maskS maskT
---- ------- ------------------ ------------------ ------------------
268 TRACE 0x00000000000001ff 0x00000000000000ff 0x0000000000000000
1021 _TRACE_ 0x00000000000001ff 0x00000000000000ff 0x0000000000000000
The “trace level” corresponds to bits in the TRACE_LVLS value (mask)
(and also, and more generally, to
bits in the level masks in the trace file). If the value of the
TRACE_LVLS was 2 (bit 1 set), then the
output would contain just the 2nd TRACE:
02-05 10:12:43.616737 0 1 hello 2nd
5* - TRACE, by default, will not be activated. Setting TRACE_LVLS in
the environment (as above) is one
way to activate TRACEs (to stdout). One alternative would be to set the
environment variable from the code:
#include "trace.h"
int main(void)
{
setenv("TRACE_LVLS","0xf",0); // set env, unless already in environment
TRACE(0, "hello 1st");
TRACE(1, "hello 2nd");
TRACE(4, "hello 3rd -- not enabled by trace level mask == 0xf"
return 0;
}
In the example above, the TRACE_LVLS environment variable is set to 0xf
which would only enable traces “levels”
0-3. The 3rd TRACE would not be output unless TRACE_LVLS is in the
enviroment and either a) has a value with bit 4 set
or b) has a null value and a trace file is active which has bit 4 of the
appropriate mask set.
You can change the default time format in the stdout output by changing
the default format from “%m-d%H:%M:S.%%06d”
For example, you could even eliminate the time you setting
TRACE_TIME_FMT=’’ which would make TRACE behave even more
printf-like:
$ TRACE_TIME_FMT= ./simple
0 0 hello 1st
0 1 hello 2nd