Skip to content
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

Reformat log statements so that they aren't susceptible to formatting errors and worse when {} are in the message #1084

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gregschohn
Copy link
Collaborator

Description

[Describe what this change achieves]

  • Category (Enhancement, New feature, Bug fix, Test fix, Refactoring, Maintenance, Documentation)
  • Why these changes are required?
  • What is the old behavior before changes and new behavior after changes?

Issues Resolved

[List any issues this PR will resolve]

Is this a backport? If so, please add backport PR # and/or commits #

Testing

[Please provide details of testing done: unit testing, integration testing and manual testing]

Check List

  • New functionality includes testing
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link

codecov bot commented Oct 19, 2024

Codecov Report

Attention: Patch coverage is 77.99145% with 103 lines in your changes missing coverage. Please review.

Project coverage is 80.75%. Comparing base (db0075e) to head (5e89383).

Files with missing lines Patch % Lines
...migrations/replay/kafka/TrackingKafkaConsumer.java 70.68% 17 Missing ⚠️
...y/CapturedTrafficToHttpTransactionAccumulator.java 87.03% 7 Missing ⚠️
.../opensearch/migrations/replay/TrafficReplayer.java 0.00% 6 Missing ⚠️
...rations/bulkload/common/LuceneDocumentsReader.java 37.50% 5 Missing ⚠️
...ad/workcoordination/OpenSearchWorkCoordinator.java 81.48% 5 Missing ⚠️
...ns/replay/traffic/expiration/BehavioralPolicy.java 0.00% 5 Missing ⚠️
...s/replay/traffic/source/BlockingTrafficSource.java 77.27% 5 Missing ⚠️
...search/migrations/replay/ClientConnectionPool.java 80.00% 4 Missing ⚠️
...replay/datahandlers/NettyPacketToHttpConsumer.java 91.11% 4 Missing ⚠️
.../datahandlers/http/NettyJsonContentAuthSigner.java 0.00% 4 Missing ⚠️
... and 20 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1084      +/-   ##
============================================
+ Coverage     80.66%   80.75%   +0.08%     
+ Complexity     2893     2838      -55     
============================================
  Files           383      383              
  Lines         14361    14349      -12     
  Branches        989      988       -1     
============================================
+ Hits          11584    11587       +3     
+ Misses         2184     2167      -17     
- Partials        593      595       +2     
Flag Coverage Δ
gradle-test 78.85% <77.99%> (+0.10%) ⬆️
python-test 90.33% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

… errors and worse when {} could end up directly in the 'message' string.

I tried to codify on a couple of standards as well.
1) setMessage(Supplier...) should not be used.  Placeholders and arguments should always be used instead.
2) All arguments being added should use a supplier if the argument requires any evaluation of a function.  To confirm, the regex `.addArgument\([^\(\)]+\([^\)]*` shouldn't found present.

On stylistic levels
3) The sequence of fluent/builder operations should be setCause, setMessage, addArguments...
4) If more than one argument is added, each argument should be on a separate line, followed by a log() also on its own line.

Signed-off-by: Greg Schohn <greg.schohn@gmail.com>
@gregschohn gregschohn marked this pull request as ready for review October 23, 2024 04:01
@gregschohn gregschohn changed the title WIP to reformat log statements so that they aren't susceptible to formatting errors and worse when {} are in the message. reformat log statements so that they aren't susceptible to formatting errors and worse when {} are in the message. Oct 24, 2024
@gregschohn gregschohn changed the title reformat log statements so that they aren't susceptible to formatting errors and worse when {} are in the message. Reformat log statements so that they aren't susceptible to formatting errors and worse when {} are in the message Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant