Closed nganju98 closed 6 months ago
The update enhances the logging functionality by introducing a new Initialize
method in the Log.cs
file. This method allows setting the logger instance with an ILogger
parameter, crucial for configuring the logger at the application's start to align logging behaviors with user specifications or system requirements.
File Path | Change Summary |
---|---|
Deepgram/.../Log.cs |
Added public static void Initialize(ILogger logger) |
Thanks for the quick response!
Looks good, can you merge it so I can use yours instead of the fork I'm on? Thanks!
Ok pushed another version with PR feedback. Please merge, thanks!
Thanks for the contribution @nganju98
This is nice, but not practical because it uses a static initializer. A lot of apps work with dependency injection, which is not statically injected (and easier to test when not using statics). I can't do another PR right now but I thought the feedback could be useful to the maintainers. In short, any kind of static accessor, even if practical, makes testing and IoC harder.
I would also recommend that you do not depend directly on Serilog, and instead depend on Microsoft.Extensions.Logging.Abstractions
, which was made to allow libraries to receive any logging mechanism. I use Serilog, but I still rely on those abstractions.
This is nice, but not practical because it uses a static initializer. A lot of apps work with dependency injection, which is not statically injected (and easier to test when not using statics). I can't do another PR right now but I thought the feedback could be useful to the maintainers. In short, any kind of static accessor, even if practical, makes testing and IoC harder.
I would also recommend that you do not depend directly on Serilog, and instead depend on
Microsoft.Extensions.Logging.Abstractions
, which was made to allow libraries to receive any logging mechanism. I use Serilog, but I still rely on those abstractions.
Thanks for the feedback. When the logging was implemented, it was done so just to have some logging available. Previously, if something were to happen in the field, there was no real way to find out what was going on for a production system. This helps with that but as you pointed out, this is far from perfect. This PR also doesn't solve the root of this ask, as you mention. When we get more time, we will take a look at abstracting the logging and also provide a default logger in the event the user doesn't have an opinion.
Hi, right now you're creating a log.txt file in my working directory which is not something I need there. Furthermore my actual logger writes to remote logging services etc. I've already got a carefully configured Serilog logger and I'd like your library to use the one I've already made.
The way you've made your library, it's quite easy to add this. Please accept my 3-line pull request. Thanks!