Print metadata only after a line break (#397)

* Fix logging stack to print message in the first SdkLog

* Do not log metadata if on the same line

* Fix wrong var name

* Change task names to DemoTask

* Change for shadow too

* Move declaration to a separate line

Co-authored-by: Gary Wicker <14828980+gkwicker@users.noreply.github.com>
This commit is contained in:
Oscar Michael Abrina 2020-11-10 10:51:01 -08:00 committed by GitHub
parent 9939374379
commit 1876800382
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 22 additions and 19 deletions

View file

@ -532,7 +532,7 @@ void vStartShadowDemo( void )
* use Device Shadow library to get shadow topics and validate shadow topics
* via MQTT APIs communicating with the MQTT broker. */
xTaskCreate( prvShadowDemoTask, /* Function that implements the task. */
"ShadowDemo", /* Text name for the task - only used for debugging. */
"DemoTask", /* Text name for the task - only used for debugging. */
democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
NULL, /* Task parameter - not used in this case. */
tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */

View file

@ -263,6 +263,7 @@ void vLoggingPrintf( const char * pcFormat,
char * pcSource, * pcTarget, * pcBegin;
size_t xLength, xLength2, rc;
static BaseType_t xMessageNumber = 0;
static BaseType_t xAfterLineBreak = pdTRUE;
va_list args;
uint32_t ulIPAddress;
const char * pcTaskName;
@ -286,17 +287,19 @@ void vLoggingPrintf( const char * pcFormat,
pcTaskName = pcNoTask;
}
if( strcmp( pcFormat, "\r\n" ) != 0 )
if( ( xAfterLineBreak == pdTRUE ) && ( strcmp( pcFormat, "\r\n" ) != 0 ) )
{
xLength = snprintf( cPrintString, dlMAX_PRINT_STRING_LENGTH, "%lu %lu [%s] ",
xMessageNumber++,
( unsigned long ) xTaskGetTickCount(),
pcTaskName );
xAfterLineBreak = pdFALSE;
}
else
{
xLength = 0;
memset( cPrintString, 0x00, dlMAX_PRINT_STRING_LENGTH );
xAfterLineBreak = pdTRUE;
}
xLength2 = vsnprintf( cPrintString + xLength, dlMAX_PRINT_STRING_LENGTH - xLength, pcFormat, args );

View file

@ -343,7 +343,7 @@ void vStartSimpleMQTTDemo( void )
* connect, subscribe, publish, unsubscribe, and disconnect from the MQTT
* broker. */
xTaskCreate( prvMQTTDemoTask, /* Function that implements the task. */
"MQTTDemo", /* Text name for the task - only used for debugging. */
"DemoTask", /* Text name for the task - only used for debugging. */
democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
NULL, /* Task parameter - not used in this case. */
tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */

View file

@ -441,7 +441,7 @@ void vStartSimpleMQTTDemo( void )
* connect, subscribe, publish, unsubscribe and disconnect from the MQTT
* broker. */
xTaskCreate( prvMQTTDemoTask, /* Function that implements the task. */
"MQTTDemo", /* Text name for the task - only used for debugging. */
"DemoTask", /* Text name for the task - only used for debugging. */
democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
NULL, /* Task parameter - not used in this case. */
tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */

View file

@ -112,11 +112,11 @@
/* If no username is defined, then a client certificate/key is required. */
#ifndef democonfigCLIENT_USERNAME
/*
*!!! Please note democonfigCLIENT_PRIVATE_KEY_PEM in used for
*!!! convenience of demonstration only. Production devices should
*!!! store keys securely, such as within a secure element.
*/
/*
*!!! Please note democonfigCLIENT_PRIVATE_KEY_PEM in used for
*!!! convenience of demonstration only. Production devices should
*!!! store keys securely, such as within a secure element.
*/
#ifndef democonfigCLIENT_CERTIFICATE_PEM
#error "Please define client certificate(democonfigCLIENT_CERTIFICATE_PEM) in demo_config.h."
@ -859,7 +859,7 @@ void vStartSimpleMQTTDemo( void )
* MQTT operations, and creates additional tasks to add operations to that
* queue. */
xTaskCreate( prvMQTTDemoTask, /* Function that implements the task. */
"MQTTDemo", /* Text name for the task - only used for debugging. */
"DemoTask", /* Text name for the task - only used for debugging. */
democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
NULL, /* Task parameter - not used in this case. */
tskIDLE_PRIORITY + 1, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */

View file

@ -73,11 +73,11 @@
/* If no username is defined, then a client certificate/key is required. */
#ifndef democonfigCLIENT_USERNAME
/*
*!!! Please note democonfigCLIENT_PRIVATE_KEY_PEM in used for
*!!! convenience of demonstration only. Production devices should
*!!! store keys securely, such as within a secure element.
*/
/*
*!!! Please note democonfigCLIENT_PRIVATE_KEY_PEM in used for
*!!! convenience of demonstration only. Production devices should
*!!! store keys securely, such as within a secure element.
*/
#ifndef democonfigCLIENT_CERTIFICATE_PEM
#error "Please define client certificate(democonfigCLIENT_CERTIFICATE_PEM) in demo_config.h."
@ -432,7 +432,7 @@ void vStartSimpleMQTTDemo( void )
* connect, subscribe, publish, unsubscribe and disconnect from the MQTT
* broker. */
xTaskCreate( prvMQTTDemoTask, /* Function that implements the task. */
"MQTTDemo", /* Text name for the task - only used for debugging. */
"DemoTask", /* Text name for the task - only used for debugging. */
democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
NULL, /* Task parameter - not used in this case. */
tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */

View file

@ -327,7 +327,7 @@ void vStartSimpleMQTTDemo( void )
* connect, subscribe, publish, unsubscribe and disconnect from the MQTT
* broker. */
xTaskCreate( prvMQTTDemoTask, /* Function that implements the task. */
"MQTTDemo", /* Text name for the task - only used for debugging. */
"DemoTask", /* Text name for the task - only used for debugging. */
democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
NULL, /* Task parameter - not used in this case. */
tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */

View file

@ -383,7 +383,7 @@ void vStartSimpleMQTTDemo( void )
* connect, subscribe, publish, unsubscribe and disconnect from the MQTT
* broker. */
xTaskCreate( prvMQTTDemoTask, /* Function that implements the task. */
"MQTTSerializerDemo", /* Text name for the task - only used for debugging. */
"DemoTask", /* Text name for the task - only used for debugging. */
democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
NULL, /* Task parameter - not used in this case. */
tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */

View file

@ -299,7 +299,7 @@ void vStartPKCSMutualAuthDemo( void )
* connect, subscribe, publish, unsubscribe and disconnect from the MQTT
* broker. */
xTaskCreate( prvMQTTDemoTask, /* Function that implements the task. */
"MQTTDemo", /* Text name for the task - only used for debugging. */
"DemoTask", /* Text name for the task - only used for debugging. */
democonfigDEMO_STACKSIZE, /* Size of stack (in words, not bytes) to allocate for the task. */
NULL, /* Task parameter - not used in this case. */
tskIDLE_PRIORITY, /* Task priority, must be between 0 and configMAX_PRIORITIES - 1. */