-
Notifications
You must be signed in to change notification settings - Fork 11
Extend Composite Logger log functions to have built in buffer #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #213 +/- ##
==========================================
+ Coverage 90.34% 90.39% +0.04%
==========================================
Files 90 90
Lines 14735 14810 +75
==========================================
+ Hits 13312 13387 +75
Misses 1423 1423
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
After some thought on this, I’m refining the last guidance on this PR to:
In detail:
Things to remove from PR to strip out unnecessary complexity:
|
kjohn-msft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tentative approval on test coverage with product code as in this iteration.
rane-rajasi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left one question inline. Outside of that, changes look good
…try_event_level is already handled and hence should not come in flush case.
Extend Composite Logger functions to have built in buffer. This will help in combining multiple messages in single log and hence decreasing number of logs and hence time loss due to telemetry throttling is decreased.
A new optional parameter is added in log functions. The data type of the parameter is enum whose values can be true, flush and false. The default value is false.
If the buffer is true, keep appending to built-in variable.
The buffer may be flushed to the log in the very last message meant to be part of the concatenation.
If it's false, write whatever is in memory, clear it out, and also separately write the new message that came in.
The buffer line separator is used to separate different messages in the same buffer - "\n|\t".
There is common buffer for different log levels i.e., error, warning, debug and verbose. This is simpler design than having separate buffers for each log level. The issue with having single buffer for all log levels is that if log function with warning level is called 3 times with different messages with buffer=true and then log function with error level is called with buffer=flush then all the 4 messages will be written with error level because there is single buffer for all log levels. The current use cases of decreasing number of logs by combining multiple messages to single log can be achievable with single buffer for all log levels.
If required later, the design can be expanded to have separate buffers each for error, warning, debug and verbose.
Manual testing done:
Tested the different sequences of logging messages with the buffer value true, false and flush. Tested following scenarios with all log levels i.e. error, warning, debug and verbose:
(a) When log function is called 2 times with buffer=true and third time with buffer=flush, then the three logs are combined to single log.
(b) When log function is called with buffer=false then the message is logged.
(c) When log function is called with buffer=true followed by log function with buffer=false then the message with buffer=true is logged first and then the message with buffer=false is logged as a separate log.
Tested the scenarios with number of characters in message exceed the limit of maximum characters.
(a) If log function is called with buffer=true and then a new log function is called with buffer=flush and if sum of characters of both the messages exceeds the limit then both messages are logged separately.