Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Remove repetition of metadata in log messages #2953

Merged
merged 30 commits into from
Feb 8, 2021
Merged
Changes from 4 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
229c340
Attempt to remove task name and time metadata duplication in logs
aggarw13 Jan 25, 2021
b2108d9
Fix build issue
aggarw13 Jan 25, 2021
d201319
Fix bug in modified logic
aggarw13 Jan 25, 2021
059df8f
doc: add some comments for modified logic
aggarw13 Jan 26, 2021
2293563
test assembling string before logging messsage
aggarw13 Jan 27, 2021
a644c0f
Fix build issues
aggarw13 Jan 27, 2021
9eb99d1
Make __LINE__ value resolution accurate by removing formatting from S…
aggarw13 Jan 27, 2021
3662a78
Replace overflow assert with logic to end buffer with line endings
aggarw13 Jan 27, 2021
54d2d44
Merge branch 'poc/logging-thread-safety-issue' of github.com:aggarw13…
aggarw13 Jan 27, 2021
85848e9
Fix overflow handling logic
aggarw13 Jan 27, 2021
2548f9e
avoid double copy operation in messages through LogXXX macros
aggarw13 Jan 27, 2021
8a25224
Fix logic of updating state of newLogMessage flag
aggarw13 Jan 28, 2021
2874ecb
Remove code comminization in previous commit as string needs to be co…
aggarw13 Jan 28, 2021
c14785a
Add support for Keil compiler
aggarw13 Jan 28, 2021
ddca1e5
Refactor logging_stack.h to provide C99 and C89 compatible implementa…
aggarw13 Feb 3, 2021
5e86313
Add a README for the logging library
aggarw13 Feb 3, 2021
47d6ffa
Update vLoggingPrintf implementation to add newline characters
aggarw13 Feb 3, 2021
d46422d
FIx incorrect usage of snprintf when adding newling characters
aggarw13 Feb 4, 2021
7cd8530
Fix build issue
aggarw13 Feb 4, 2021
46e7110
Fix issue of undefined SdkLog
aggarw13 Feb 4, 2021
294b084
Remove extra space ERROR log messages
aggarw13 Feb 4, 2021
995c32c
Attempt to fix Windows build issues
aggarw13 Feb 4, 2021
809e490
Attempt to fix build failures for Microchip
aggarw13 Feb 4, 2021
006b35f
Improvements in README
aggarw13 Feb 4, 2021
1495715
Remove xEndofMessage static variable
aggarw13 Feb 4, 2021
c98a928
Fixes in Windows implementations
aggarw13 Feb 4, 2021
95d0028
Hygiene changes in logging task files
aggarw13 Feb 4, 2021
f6d3537
Minor changes from review comments
aggarw13 Feb 7, 2021
6512188
Improve README
aggarw13 Feb 8, 2021
de73cfc
Minor fixes in README
aggarw13 Feb 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion libraries/logging/iot_logging_task_dynamic_buffers.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,17 @@ void vLoggingPrintf( const char * pcFormat,

if( pcPrintString != NULL )
{
/* Variable to track when a stream of log message is completed. */
/* Note: A log message may be sent over multiple calls to vLoggingPrintf, thus, */
/* this variable tracks when the log message ends. */
static BaseType_t xEndOfMessage = pdTRUE;
leegeth marked this conversation as resolved.
Show resolved Hide resolved
size_t ulFormatStrLen = 0UL;

/* There are a variable number of parameters. */
va_start( args, pcFormat );

if( strcmp( pcFormat, "\n" ) != 0 )
/* Add metadata of task name and tick time for a new log message. */
if( ( strcmp( pcFormat, "\n" ) != 0 ) && ( xEndOfMessage == pdTRUE ) )
{
#if ( configLOGGING_INCLUDE_TIME_AND_TASK_NAME == 1 )
{
Expand Down Expand Up @@ -187,6 +194,19 @@ void vLoggingPrintf( const char * pcFormat,
#endif /* if ( configLOGGING_INCLUDE_TIME_AND_TASK_NAME == 1 ) */
}

ulFormatStrLen = strlen( pcFormat );

/* Look for new line character in message to detect if the log message has ended.
* This is done to ensure that the metadata is added only once per log message. */
if( ( ulFormatStrLen >= 2UL ) && ( strcmp( pcFormat + ulFormatStrLen - 2, "\r\n" ) == 0U ) )
{
xEndOfMessage = pdTRUE;
}
else
{
xEndOfMessage = pdFALSE;
}

xLength2 = vsnprintf( pcPrintString + xLength, configLOGGING_MAX_MESSAGE_LENGTH - xLength, pcFormat, args );

if( xLength2 < 0 )
Expand Down