Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
using System;
using System.Text;

using LogExpert.Core.Helpers;

using Newtonsoft.Json;

namespace LogExpert.Core.Classes.JsonConverters;
Expand DownExpand Up@@ -53,19 +55,6 @@ public override void WriteJson (JsonWriter writer, object? value, JsonSerializer
return null;
}

var encodingName = reader.Value?.ToString();
if (string.IsNullOrEmpty(encodingName))
{
return Encoding.Default;
}

try
{
return Encoding.GetEncoding(encodingName);
}
catch (ArgumentException)
{
return Encoding.Default;
}
return EncodingRegistry.GetEncoding(reader.Value?.ToString(), Encoding.Default);
}
}
53 changes: 0 additions & 53 deletions src/LogExpert.Core/Classes/Log/LineOffsetIndex.cs

This file was deleted.

24 changes: 0 additions & 24 deletions src/LogExpert.Core/Classes/Log/LogfileReader.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,8 +37,6 @@ public partial class LogfileReader : ILogfileReader, IMultiFileNavigation, ILogf

private readonly ILoadProgressReporter _progressReporter;

private readonly MemoryMappedFileReader _mmfReader;

private const int WAIT_TIME = 1000;

private bool _contentDeleted;
Expand DownExpand Up@@ -186,18 +184,6 @@ private LogfileReader (

_watchedILogFileInfo = fileInfo;

if (!IsMultiFile && _watchedILogFileInfo.Uri?.Scheme is null or "file")
{
try
{
_mmfReader = new MemoryMappedFileReader(_watchedILogFileInfo.FullName, EncodingOptions.Encoding ?? Encoding.Default);
}
catch (IOException)
{
_mmfReader = null; // fallback to buffer path
}
}

StartGCThread();
}

Expand DownExpand Up@@ -959,12 +945,6 @@ private ValueTask<ILogLineMemory> GetLogLineMemoryInternal (int lineNum)
return default;
}

if (_mmfReader != null && lineNum < _mmfReader.LineCount)
{
var line = _mmfReader.GetLine(lineNum);
return new ValueTask<ILogLineMemory>(line);
}

using var readLock = BufferIndex.AcquireReadLock();
{
var logBufferEntry = BufferIndex.GetBufferForLineWithIndex(lineNum);
Expand DownExpand Up@@ -1568,8 +1548,6 @@ private void FileChanged ()
_logger.Info(CultureInfo.InvariantCulture, "file size changed. new size={0}, file: {1}", newSize, _fileName);
FireChangeEvent();
}

_mmfReader?.ExtendIndex();
}

/// <summary>
Expand DownExpand Up@@ -1874,8 +1852,6 @@ protected virtual void Dispose (bool disposing)
_cts.Dispose();
BufferIndex.Dispose();
_progressReporter.Dispose();
_mmfReader?.Dispose();

}

_disposed = true;
Expand Down
146 changes: 0 additions & 146 deletions src/LogExpert.Core/Classes/Log/MemoryMappedFileReader.cs

This file was deleted.

33 changes: 16 additions & 17 deletions src/LogExpert.Core/Classes/Persister/PersisterXML.cs
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@

using LogExpert.Core.Classes.Filter;
using LogExpert.Core.Entities;
using LogExpert.Core.Helpers;

using NLog;

Expand DownExpand Up@@ -266,26 +267,24 @@ private static PersistenceData ReadPersistenceDataFromNode (XmlNode node)
private static Encoding ReadEncoding (XmlElement fileElement)
{
XmlNode encodingNode = fileElement.SelectSingleNode("encoding");
if (encodingNode != null)
if (encodingNode == null)
{
XmlAttribute encAttr = encodingNode.Attributes["name"];
try
{
return encAttr == null ? null : Encoding.GetEncoding(encAttr.Value);
}
catch (ArgumentException e)
{
_logger.Error(e);
return Encoding.Default;
}
catch (NotSupportedException e)
{
_logger.Error(e);
return Encoding.Default;
}
return null;
}

XmlAttribute encAttr = encodingNode.Attributes["name"];
if (encAttr == null)
{
return null;
}

if (EncodingRegistry.TryGetEncoding(encAttr.Value, out var encoding))
{
return encoding;
}

return null;
_logger.Error($"Persisted encoding '{encAttr.Value}' is not supported, falling back to the default encoding");
return Encoding.Default;
}

/// <summary>
Expand Down
Loading
Loading