Foxtrek_64
Foxtrek_64
CC#
Created by Foxtrek_64 on 11/22/2024 in #help
Custom Logger
I was able to figure it out. My SqlServer library was named Microsoft.Extensions.Logging.SqlServer and the tests library adds the .Tests node to the namespace. It was correctly pulling in appsettings data that told it that
{
"Logging:LogLevel:Microsoft": "Warning"
}
{
"Logging:LogLevel:Microsoft": "Warning"
}
So naturally an information message was being excluded. I created a new type with a new namespace in my test library to simulate a consumer and now everything is happy
14 replies
CC#
Created by Foxtrek_64 on 11/22/2024 in #help
Custom Logger
This is the important part of the body of the database logger. I'm not hitting the if check to see if the logger is enabled though.
public bool IsEnabled(LogLevel logLevel)
{
return options.LevelSwitch is not LogLevel.None && logLevel >= options.LevelSwitch;
}

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
if (IsEnabled(logLevel))
{
logAgent.WriteToDatabase(logLevel, eventId, state, exception, formatter);
}
}
public bool IsEnabled(LogLevel logLevel)
{
return options.LevelSwitch is not LogLevel.None && logLevel >= options.LevelSwitch;
}

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
if (IsEnabled(logLevel))
{
logAgent.WriteToDatabase(logLevel, eventId, state, exception, formatter);
}
}
14 replies
CC#
Created by Foxtrek_64 on 11/22/2024 in #help
Custom Logger
But I'm not hitting any breakpoints inside of the logger nor the log agent.
14 replies
CC#
Created by Foxtrek_64 on 11/22/2024 in #help
Custom Logger
I do see a lot of calls to my logger provider's CreateLogger() function
public ILogger CreateLogger(string categoryName)
=> _loggers.GetOrAdd(categoryName, name => new MSSqlDatabaseLogger(name, _currentConfig, _logAgent, _scopeProvider));
public ILogger CreateLogger(string categoryName)
=> _loggers.GetOrAdd(categoryName, name => new MSSqlDatabaseLogger(name, _currentConfig, _logAgent, _scopeProvider));
_loggers is a concurrent dictionary (made it that in case of this being issues with async, but it can probaby be a regular dictionary) of string, MSSqlDatabaseLogger. The current options are provided by IOptionsMonitor<> And the scope provider is an IExternalScopeProvider instance, which defaults to a no-op scope shamelessly copied from the M.E.L.Console no-scope provider.
14 replies
CC#
Created by Foxtrek_64 on 11/22/2024 in #help
Custom Logger
Everything is synchronous in my db access library. There could be some asynchronicity with regards to the application host though.
14 replies
CC#
Created by Foxtrek_64 on 11/22/2024 in #help
Custom Logger
Not sure how to see the output from that console logger in an xunit process
14 replies
CC#
Created by Foxtrek_64 on 11/22/2024 in #help
SqlConnection Connection Disposed
I've got the test to a state where it's passing. Thanks for your help.
13 replies
CC#
Created by Foxtrek_64 on 11/22/2024 in #help
SqlConnection Connection Disposed
Let me look at this test logic and see if I can't further isolate where it is failing
13 replies
CC#
Created by Foxtrek_64 on 11/22/2024 in #help
SqlConnection Connection Disposed
As far as I can see, I am no longer getting the exception.
13 replies
CC#
Created by Foxtrek_64 on 11/22/2024 in #help
SqlConnection Connection Disposed
That's a good catch Doesn't seem to pass a unit test though. The test is pretty rudimentary - it checks the number of rows in a table, attempts to insert a row, checks the number of rows again, and asserts the counts are not equal (I'm sure there are better ways, it's just what worked in the few seconds that I was writing this test). Before and after the insert both have the same number of rows.
13 replies
CC#
Created by Foxtrek_64 on 11/22/2024 in #help
SqlConnection Connection Disposed
Nothing particularly special here, but I can share. https://gist.github.com/Foxtrek64/ba9864e7c65bc9e8b42c7702d493a6dc The interfaces are just for describing the features of the accessor. This library is intended to implement several types, like SqlServer and Mongo and a few others, but that's not particularly important. None of the interfaces here are DIMs.
13 replies
CC#
Created by Foxtrek_64 on 9/30/2024 in #help
VS hangs while typing
Sure
13 replies
CC#
Created by Foxtrek_64 on 9/30/2024 in #help
VS hangs while typing
I'll look at this, thanks
13 replies
CC#
Created by Foxtrek_64 on 9/30/2024 in #help
VS hangs while typing
I have neither
13 replies
CC#
Created by Foxtrek_64 on 9/20/2024 in #help
Blazor - Identity Scaffolding Fails
Both of these say that I need a package installed, which I have already.
14 replies
CC#
Created by Foxtrek_64 on 9/20/2024 in #help
Blazor - Identity Scaffolding Fails
I have, yes
14 replies
CC#
Created by Foxtrek_64 on 9/20/2024 in #help
Blazor - Identity Scaffolding Fails
I may have to manually migrate these to .razor files and put them in the Components directory, but it's a step in the right direction
14 replies
CC#
Created by Foxtrek_64 on 9/20/2024 in #help
Blazor - Identity Scaffolding Fails
Ran dotnet aspnet-codegenerator identity -dc AuthDbContext and it worked. I got a new folder called Areas and it correctly scaffolded all of the items, albeit as cshtml instead of razor.
14 replies
CC#
Created by Foxtrek_64 on 9/20/2024 in #help
Blazor - Identity Scaffolding Fails
The logs do say "Empty or invalid namespace provided, using default namespace" Not sure if that matters here
14 replies