AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.62k stars 2.22k forks source link

Add LogToSink extensions for assign the implementation of ILogSink to Logger #4324

Open rstm-sf opened 4 years ago

rstm-sf commented 4 years ago

Hello!

Maybe add LogToSink extensions for assign the implementation of ILogSink to Logger?

Logging Errors and Warnings / Removing Serilog

/// <summary>
/// Logs Avalonia events to the <see cref="Avalonia.Logging.ILogSink"/> implementation.
/// </summary>
/// <typeparam name="T">The application class type.</typeparam>
/// <param name="builder">The app builder instance.</param>
/// <param name="logSink">The <see cref="Avalonia.Logging.ILogSink"/> implementation.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="logSink"/> is null.</exception>
/// <returns>The app builder instance.</returns>
public static T LogToSink<T>(this T builder, ILogSink logSink)
    where T : AppBuilderBase<T>, new()
{
    Logger.Sink = logSink ?? throw new ArgumentNullException(nameof(logSink));
    return builder;
}
maxkatz6 commented 4 years ago

I believe "LogToSink" should be cleaner name for the method.