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

Feature: Caller Member on Static Default Logger #569

Merged
merged 34 commits into from
Jan 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8021dc6
#341 caller member initial work
dpvreony Aug 22, 2020
87e963e
#341 further work on static logger class
dpvreony Aug 22, 2020
609545a
add write line mvp to get build green
dpvreony Aug 22, 2020
db9e436
#341 full static logger implementation, ns tidyup
dpvreony Aug 23, 2020
c77ec9c
api approval updates
dpvreony Aug 28, 2020
4420eeb
Merge branch 'main' into callermemberlogging
dpvreony Aug 28, 2020
2eeefb6
#341 update static logging doc
dpvreony Aug 31, 2020
6a41ce4
#341 add some unit tests
dpvreony Aug 31, 2020
a263492
test coverage, removed a generic with design issue
dpvreony Aug 31, 2020
2953d98
Merge branch 'main' into callermemberlogging
dpvreony Sep 30, 2020
018793b
Merge branch 'main' into callermemberlogging
glennawatson Oct 28, 2020
7a1cbc0
Merge branch 'main' into callermemberlogging
dpvreony Dec 3, 2020
31f0dde
Merge branch 'main' into callermemberlogging
dpvreony Dec 3, 2020
9b3fce2
Merge branch 'main' into callermemberlogging
glennawatson Dec 16, 2020
71b6f0e
Merge branch 'main' into callermemberlogging
dpvreony Dec 27, 2020
6576ea5
api approval txt updates
dpvreony Dec 27, 2020
4dc473d
added more tests, fixed callermembername attribute being missing
dpvreony Dec 27, 2020
6675cbe
Merge branch 'main' into callermemberlogging
glennawatson Dec 27, 2020
12d2cb9
Add updated api approvals
glennawatson Dec 27, 2020
471768d
fixed some tests
dpvreony Dec 28, 2020
91c2237
Merge branch 'main' into callermemberlogging
dpvreony Dec 29, 2020
cd0546e
Merge branch 'main' into callermemberlogging
dpvreony Jan 6, 2021
c4921da
Merge branch 'main' into callermemberlogging
dpvreony Jan 9, 2021
815f9c3
Merge branch 'main' into callermemberlogging
dpvreony Jan 16, 2021
e2a403f
increase coverage
dpvreony Jan 17, 2021
a87e360
Merge branch 'main' into callermemberlogging
glennawatson Jan 18, 2021
d6b1288
set as version 10
dpvreony Jan 18, 2021
b3a6b72
add wrapper for withfeatureusagetracking
dpvreony Jan 18, 2021
0563365
wrapper for withsubfeaturetrackingsession
dpvreony Jan 18, 2021
f4ffaba
api approval and feature extension tests
dpvreony Jan 18, 2021
993ec26
Merge branch 'main' into callermemberlogging
dpvreony Jan 18, 2021
745e899
more coverage
dpvreony Jan 19, 2021
0aef425
full coverage
dpvreony Jan 20, 2021
cb5cd17
Merge branch 'main' into callermemberlogging
dpvreony Jan 21, 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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ this.Log().ErrorException("Tried to do a thing and failed", exception);
```

For static methods, `LogHost.Default` can be used as the object to write a log
entry for.
entry for. The Static logger uses a different interface from the main logger to allow capture of additional
caller context as it doesn't have the details of the class instance etc. when compared to the normal logger.
To get the benefit of these you don't need to do much as they are optional parameters at the end of the methods
that are utilised by the compiler\framework. Currently we only capture [CallerMemberName](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.callermembernameattribute).

### Available logging adapters

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,49 @@ public void SubFeatureHandlesOnException()
}
}
}

/// <summary>
/// Unit tests for the WithFeatureUsageTrackingSession Method.
/// </summary>
public sealed class WithFeatureUsageTrackingSessionMethod
{
/// <summary>
/// Test to ensure a default feature usage tracking session is set up.
/// </summary>
[Fact]
public void HandlesAction()
{
var instance = new TestObjectThatSupportsFeatureUsageTracking();
var handled = false;

instance.WithFeatureUsageTrackingSession(
"FeatureName",
_ => handled = true);

Assert.True(handled);
}
}

/// <summary>
/// Unit tests for the WithSubFeatureUsageTrackingSession Method.
/// </summary>
public sealed class WithSubFeatureUsageTrackingSessionMethod
{
/// <summary>
/// Test to ensure a default feature usage tracking session is set up.
/// </summary>
[Fact]
public void HandlesAction()
{
var instance = new TestObjectThatSupportsFeatureUsageTracking();
var handled = false;

instance.WithFeatureUsageTrackingSession(
"FeatureName",
session => session.WithSubFeatureUsageTrackingSession("SubFeature", _ => handled = true));

Assert.True(handled);
}
}
}
}
Loading