Skip to content

Conversation

@axunonb
Copy link
Collaborator

@axunonb axunonb commented Aug 8, 2025

Updated project to remove NLog references and integrate Serilog.
Added flexible logging options in the configuration.

Updated project to remove NLog references and integrate Serilog.
Added flexible logging options in the configuration.
@codecov
Copy link

codecov bot commented Aug 8, 2025

Codecov Report

❌ Patch coverage is 95.34884% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
Ical.Net/Logging/Internal/Logger.cs 90.0% 0 Missing and 1 partial ⚠️
Ical.Net/Logging/Internal/NullLoggerFactory.cs 85.7% 0 Missing and 1 partial ⚠️

Impacted file tree graph

@@           Coverage Diff           @@
##            main    #853     +/-   ##
=======================================
+ Coverage   67.7%   68.0%   +0.3%     
=======================================
  Files        106     112      +6     
  Lines       4224    4267     +43     
  Branches     951     956      +5     
=======================================
+ Hits        2860    2901     +41     
  Misses      1038    1038             
- Partials     326     328      +2     
Files with missing lines Coverage Δ
Ical.Net/Logging/Internal/LoggerT.cs 100.0% <100.0%> (ø)
Ical.Net/Logging/Internal/NullLogger.cs 100.0% <100.0%> (ø)
Ical.Net/Logging/LoggerExtensions.cs 100.0% <100.0%> (ø)
Ical.Net/Logging/LoggingProvider.cs 100.0% <100.0%> (ø)
Ical.Net/Logging/Internal/Logger.cs 90.0% <90.0%> (ø)
Ical.Net/Logging/Internal/NullLoggerFactory.cs 85.7% <85.7%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 8, 2025

@axunonb axunonb changed the base branch from main to wip/axunonb/pr/logging August 8, 2025 22:03
@axunonb axunonb marked this pull request as ready for review August 8, 2025 22:03
@axunonb axunonb merged commit d659711 into wip/axunonb/pr/logging Aug 8, 2025
11 checks passed
@axunonb axunonb deleted the wip/axunonb/pr/logging-serilog branch August 8, 2025 22:03
axunonb added a commit that referenced this pull request Aug 13, 2025
* Add logging infrastructure

`Ical.Net`:
* Added package `Microsoft.Extensions.Logging.Abstractions` to `Ical.Net`
* Introduced `LoggingProvider` to support global logger factory configuration.
* `NullLoggerFactory` is the default factory

`Ical.Net.Tests`:
* Added ``TestLoggingProvider`

**Target:**
- The `TestLoggingProvider` is designed for use in testing scenarios within the iCal.NET project.
- It enables logging operations by configuring log targets, which can be either in-memory (`MemoryTarget`) or file-based (`FileTarget`).
- The target (where logs are stored) is set during construction, allowing flexibility for different test requirements.

**Usage:**
- Instantiate `TestLoggingProvider` in unit or integration tests to capture and inspect log output generated by iCal.NET components.
- You can specify logging options (like minimum/maximum log levels and logger name patterns) to control which log messages are recorded.
- Retrieve log entries via the `Logs` property, which returns the most recent logs up to a configurable maximum count (`Options.MaxLogsCount`).
- Useful for verifying that expected log messages are produced during test execution, or for debugging test failures by examining log output.
- Logging can be disabled in case no debugger is attached (`Options.DebugModeOnly`)

---

**Example Usage:**
```csharp
// Create a provider with in-memory logging
var provider = new TestLoggingProvider();

// Use provider.LoggerFactory to create loggers in your tests
var logger = provider.LoggerFactory.CreateLogger("TestLogger");

// Log something
logger.LogInformation("Test message");

// Retrieve logs for assertions
var logs = provider.Logs.ToList();
```

* Refactor logging framework and update tests (#852)

## Ical.Net
- Removed dependency `Microsoft.Extensions.Logging.Abstraction`
- Introduced new logging classes and interfaces (`ILogger`, `ILoggerFactory`, `NullLogger`, `NullLoggerFactory` et al) in namespace `Ical.Net.Logging`
- Refactored `LoggingProvider` to utilize `AsyncLocal<ILoggerFactory?>` for better async context management.
- Added extension methods for simplified logging calls.

## Ical.Net.Tests
- Added `Microsoft.Extensions.Logging` package
- Enhanced `LoggingProviderUnitTests` with new tests for logger factory initialization and multi-threaded logging behavior.
- Modified `TestLoggingProviderBase` to correctly use `NullTarget`.
- Updated `LogLevel` mappings for compatibility with `Ical.Net.Logging` implementation.

* Remove unused `ILoggerT`, implement `IDisposable` pattern for `NullLoggerFactory`

* Switch logging framework from NLog to Serilog (#853)

Updated project to remove NLog references and integrate Serilog.
Added flexible logging options in the configuration.

* Remove obsolete TestLoggingManager CTOR overloads
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.

2 participants