Skip to content

Commit d05720f

Browse files
committed
refactor(logging): use specific logger name
Updated appsettings override for: TELBlazor.Components.Components.BaseComponents.TELButton = Debug
1 parent 3896d7e commit d05720f

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

TELBlazor.Components/Components/BaseComponents/TELButton.razor

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@inherits TELComponentBase
22
@implements IAccessibleComponent
3-
@inject ILogger<TELButton> Logger
3+
@inject ILogger<TELButton> TELButtonLogger
44

55
@if (IsSubmitButtonForEditForm)
66
{
@@ -96,7 +96,8 @@ else
9696
[ExcludeFromCodeCoverage]
9797
private async Task HandleClick()
9898
{
99-
Logger.LogInformation($"Button clicked: {ButtonText}");
99+
TELButtonLogger.LogInformation($"Button clicked, text: {ButtonText}");
100+
TELButtonLogger.LogDebug($"Debug log should only happen if overide works");
100101

101102
if (PreventDoubleClick && !isClickedRecently)
102103
{

TELBlazor.Components/Core/TELComponentBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ public class TELComponentBase : ComponentBase
1515
private ITELBlazorBaseComponentConfiguration TELBlazorBaseComponentConfiguration { get; set; } = default!;
1616

1717
[Inject]
18-
public ILogger<TELComponentBase> Logger { get; set; } = default!;
18+
public ILogger<TELComponentBase> BaseLogger { get; set; } = default!;
1919

2020
protected bool JSEnabled => TELBlazorBaseComponentConfiguration.JSEnabled;
2121
protected string HostType => TELBlazorBaseComponentConfiguration.HostType;
2222
protected override void OnInitialized()
2323
{
2424
base.OnInitialized();
25-
Logger.LogInformation("TEL base component initialised made by {HostType}, JsEnabled is {JsEnabled}", HostType, JSEnabled);
25+
BaseLogger.LogInformation("TEL base component initialised made by {HostType}, JsEnabled is {JsEnabled}", HostType, JSEnabled);
2626
}
2727
}
2828
}

TELBlazor.Components/OptionalImplementations/Test/TestComponents/SearchExperiment/SearchExperiment.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
_debounceTimer = new Timer(async _ =>
124124
{
125125
// Invoke on UI thread
126-
Logger.LogInformation($"debounce searchText {searchText}");
126+
BaseLogger.LogInformation($"debounce searchText {searchText}");
127127
await InvokeAsync(() => GetSuggestionsAsync());
128128
_debounceTimer?.Dispose();
129129
_debounceTimer = null;
@@ -157,7 +157,7 @@
157157
158158
// try
159159
// {
160-
Logger.LogInformation($"GetSuggestionsAsync searchText {searchText}");
160+
BaseLogger.LogInformation($"GetSuggestionsAsync searchText {searchText}");
161161
suggestions = (await searchExperimentService.GetSuggestionsAsync(searchText)).ToList<string>();
162162
await InvokeAsync(StateHasChanged);
163163
// }
@@ -170,7 +170,7 @@
170170

171171
public async Task HandleInput(KeyboardEventArgs args)
172172
{
173-
Logger.LogInformation($"handleinput searchText {searchText}");
173+
BaseLogger.LogInformation($"handleinput searchText {searchText}");
174174
if (args.Key == null || args.Key.Equals("Enter"))
175175
{
176176

0 commit comments

Comments
 (0)