mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Fix dev-integrated samples and remove MemoryLogger
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CSharpAvalonia;
|
||||
|
||||
public class LogUpdatedEventArgs : EventArgs
|
||||
{
|
||||
public string Text { get; set; }
|
||||
}
|
||||
|
||||
public class MemoryLogger : ILogger
|
||||
{
|
||||
public event EventHandler<LogUpdatedEventArgs> LogUpdated;
|
||||
private readonly StringBuilder _sb = new StringBuilder();
|
||||
|
||||
public IDisposable BeginScope<TState>(TState state)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool IsEnabled(LogLevel logLevel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
|
||||
{
|
||||
lock (_sb) {
|
||||
var message = formatter(state, exception);
|
||||
if (exception != null) message += "\n" + exception.ToString();
|
||||
Console.WriteLine("log: " + message);
|
||||
_sb.AppendLine(message);
|
||||
LogUpdated?.Invoke(this, new LogUpdatedEventArgs { Text = _sb.ToString() });
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
lock (_sb) {
|
||||
return _sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user