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

Fix tracing issue: Exceptions information is not saved in trace file. It is completely ignored #1827

Merged
merged 1 commit into from
May 31, 2022

Conversation

OctaviaStan
Copy link
Contributor

@OctaviaStan OctaviaStan commented May 25, 2022

The formatter implementation from Microsoft.Extensions.Logging.Logger.Extensions class is ignoring the exception object and the exception information is not saved into log file. see the existing implemetation from below.

    private static string MessageFormatter(FormattedLogValues state, Exception error)
    {
        return state.ToString();
    }

Added handling for situation when the exception is not null and reused the existing code for formatting exceptions.

Proposed changes

if the exception is not null append the exception information formatted by the Utils.TraceExceptionMessage method

Related Issues

  • Fixes #

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply. You can also fill these out after creating the PR.

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

…Extensions class is ignoring the exception object and the exception information is not saved into log file. see the existing implemetation from below.

        private static string MessageFormatter(FormattedLogValues state, Exception error)
        {
            return state.ToString();
        }

Added handling for situation when the exception is not null and reused the existing code for formatting exceptions.
@codecov
Copy link

codecov bot commented May 25, 2022

Codecov Report

Merging #1827 (fc7b352) into master (a7cfe2f) will decrease coverage by 0.12%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master    #1827      +/-   ##
==========================================
- Coverage   55.59%   55.46%   -0.13%     
==========================================
  Files         319      319              
  Lines       58769    58768       -1     
==========================================
- Hits        32673    32598      -75     
- Misses      26096    26170      +74     
Impacted Files Coverage Δ
Stack/Opc.Ua.Core/Types/Utils/Utils.cs 60.26% <50.00%> (+0.18%) ⬆️
.../Opc.Ua.Core/Stack/Tcp/TcpReverseConnectChannel.cs 68.62% <0.00%> (-13.73%) ⬇️
Stack/Opc.Ua.Core/Stack/Tcp/TcpListenerChannel.cs 46.00% <0.00%> (-8.46%) ⬇️
Libraries/Opc.Ua.Client/ReverseConnectManager.cs 53.10% <0.00%> (-6.21%) ⬇️
...ack/Opc.Ua.Core/Stack/Transport/AsyncResultBase.cs 61.61% <0.00%> (-6.07%) ⬇️
Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryChannel.cs 69.60% <0.00%> (-2.81%) ⬇️
Stack/Opc.Ua.Core/Stack/Tcp/TcpServerChannel.cs 60.69% <0.00%> (-1.25%) ⬇️
...tack/Opc.Ua.Core/Stack/Tcp/TcpTransportListener.cs 73.00% <0.00%> (-1.15%) ⬇️
Libraries/Opc.Ua.Client/Session.cs 62.61% <0.00%> (-0.60%) ⬇️
...ack/Opc.Ua.Core/Security/Certificates/X509Utils.cs 79.42% <0.00%> (-0.58%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a7cfe2f...fc7b352. Read the comment docs.

@mrsuciu mrsuciu requested a review from mregen May 26, 2022 15:40
Copy link
Contributor

@mregen mregen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

@mregen mregen added this to the 1.4.369 milestone May 28, 2022
@mrsuciu mrsuciu merged commit 8cc18b3 into OPCFoundation:master May 31, 2022
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.

None yet

3 participants