-
I want to send messages out over RTT to our telnet program that breaks them apart and displays them in a unique way for us. Our strings have fields between
The combination of proper header information, correct argument sizing, and maintaining proper file/line information seems challenging without the ability to abstract through functions or macros. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
The Trice tool shows the location information automatically using the information inside li.json. Transmitting the file names as runtime strings I would not recommend for performance reasons but you can try this in your code: TRICE_ENTER_CRITICAL_SECTION triceS("err:%s", __FILE__); trice16("err::%d\n", __LINE__); TRICE_LEAVE_CRITICAL_SECTION
What kind of syntax you expect? Please see the information about Trice format string tags inside the TriceUserManual. There is also a
What do you mean with a missing
Would you please explain in more detail, what this questions means. The Trice tool log output contains per default location information and you can also have a binary or ASCII log file.
I assume this is not possible out of the box, but we can think about it and maybe find a solution, by extension of the Trice functionality. Right now you could do s.th. similar to this: \\\ \file myModuleA.c
static void logModule(void){
trice("myModuleA-" );
}
static void logProcess(void){
switch(processID){
case 1: trice("myProcessX-"); break;
case 2: trice("myProcessY-"); break;
default: trice("unknown_ProcessID-" ); break;
}
static void log_error(char* msg, int value ){
TRICE_ENTER_CRITICAL_SECTION
logModule();
logProcess();
trice("task_%d-timestamp_%d-", TASK_CONTEXT, TIMESTAMP);
trice("%s", msg);
trice(" %2X\n", value);
TRICE_LEAVE_CRITICAL_SECTION
}
void aFunction(void){
...
log_error("My Error", 42);
...
} This has the advantage having just one call, but the disadvantages compiling the error message into the target, the need to transmit it byte by byte and to have a somehow fixed formatting of the error value. Also the location information, file and line, are pointing into function log_error. An alternative: \\\ \file myModuleA.c
static void logModule(void){
trice("myModuleA-" );
}
static void logProcess(void){
switch(processID){
case 1: trice("myProcessX-"); break;
case 2: trice("myProcessY-"); break;
default: trice("unknown_ProcessID-" ); break;
}
static void log_context(void){
logModule();
logProcess();
trice("task_%d-timestamp_%d-", TASK_CONTEXT, TIMESTAMP);
}
void aFunction(void){
...
TRICE_ENTER_CRITICAL_SECTION log_context(); trice("My Error %2X\n", 42); TRICE_LEAVE_CRITICAL_SECTION
...
} Disadvantage is to have 2 calls for each error and the need for protection, but the messages are not going into the targets, trasmitted as IDs and the location information is correct. Also free formatting of the error value(s). If we create a Trice macro
That's the same theme. We need to find a kind of generic/universal syntax. One more info: If several trices build a single log line, thats when only the last one ends with "\n", the target timestamp, if any, and the location information are taken from the first Trice macro.
Yes, the Trice preprocessing is very limited - I am not able to do it better. Maybe some additional tool could be written to construct combined strings for Trice macros like this: Do not write: trice("<XMODULE><YPROCESS><ZLEVEL><ETC> My Error string %c", myArg); Just write: triceCTX("My Error string %c", myArg); run context insert ==> trice("myModuleX-myProcessY-myZLevel-myETCMy Error string %c", myArg); run trice insert ==> trice(iD(1234), "myModuleX-myProcessY-myZLevel-myETCMy Error string %c", myArg); run trice clean ==> trice("myModuleX-myProcessY-myZLevel-myETCMy Error string %c", myArg); run context clean ==> triceCTX(iD(1234), "My Error string %c", myArg); run trice clean ==> triceCTX("My Error string %c", myArg);
I understand your needs and i think this is an important extension. It would be great, if you put down s.th. like a specification draft, so that we can discuss the details.
I do not think so, deferred and direct mode are part of the Trice runtime and orthogonal to the compile-time Trice tool handling.
Within one Trice macro you can only have a single Finally: Sorry for the delayed answer, but I realized your post only today. UPDATE: Some thoughts on implementing structured logging as binary logging with Trice
|
Beta Was this translation helpful? Give feedback.
-
There is now a new chapter: TriceUserManual.md/#trice-structured-logging |
Beta Was this translation helpful? Give feedback.
-
TriceUserManual.md/#trice-structured-logging got an update, which, I guess, will fit your needs. |
Beta Was this translation helpful? Give feedback.
The Trice tool shows the location information automatically using the information inside li.json. Transmitting the file names as runtime strings I would not recommend for performance reasons but you can try this in your code:
What kind of syntax you expect? Please see the information about Trice format string tags inside the TriceUserManual. There is also a
-logLevel
CLI switch.