Skip to content

Commit 0f5c3f4

Browse files
authored
Merge pull request #319 from Hirogen/issue31
MaximumLineLength is no configurable, but beware it can impact the performance to change it to more then 20.000
2 parents 320744d + e3d7226 commit 0f5c3f4

16 files changed

Lines changed: 1930 additions & 1842 deletions

src/LogExpert.Tests/JSONSaveTest.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using LogExpert.Config;
2+
23
using Newtonsoft.Json;
4+
35
using NUnit.Framework;
6+
47
using System.IO;
58

69
namespace LogExpert.Tests
@@ -17,14 +20,14 @@ public void SaveOptionsAsJSON()
1720
string settingsFile = configDir + "\\settings.json";
1821

1922
Settings settings = null;
20-
23+
2124
Assert.DoesNotThrow(CastSettings);
2225
Assert.That(settings, Is.Not.Null);
2326
Assert.That(settings.alwaysOnTop, Is.True);
2427

2528
ConfigManager.Settings.alwaysOnTop = false;
2629
ConfigManager.Save(SettingsFlags.All);
27-
30+
2831
settings = null;
2932
Assert.DoesNotThrow(CastSettings);
3033

src/LogExpert/Classes/Log/PositionAwareStreamReaderBase.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
using System;
1+
using LogExpert.Config;
2+
using LogExpert.Entities;
3+
4+
using System;
25
using System.IO;
36
using System.Text;
4-
using LogExpert.Entities;
57

68
namespace LogExpert.Classes.Log
79
{
810
public abstract class PositionAwareStreamReaderBase : LogStreamReaderBase
911
{
1012
#region Fields
1113

12-
private const int MAX_LINE_LEN = 20000;
13-
1414
private static readonly Encoding[] _preambleEncodings = { Encoding.UTF8, Encoding.Unicode, Encoding.BigEndianUnicode, Encoding.UTF32 };
1515

1616
private readonly BufferedStream _stream;
@@ -35,7 +35,7 @@ protected PositionAwareStreamReaderBase(Stream stream, EncodingOptions encodingO
3535
_posIncPrecomputed = GetPosIncPrecomputed(usedEncoding);
3636

3737
_reader = new StreamReader(_stream, usedEncoding, true);
38-
38+
3939
Position = 0;
4040
}
4141

@@ -54,7 +54,7 @@ public sealed override long Position
5454
/*
5555
* 1: Sometime commented (+Encoding.GetPreamble().Length)
5656
* 2: Date 1.1 3207
57-
* 3: Error Message from Piet because of Unicode-Bugs.
57+
* 3: Error Message from Piet because of Unicode-Bugs.
5858
* No Idea, if this is OK.
5959
* 4: 27.07.09: Preamble-Length is now calculated in CT, because Encoding.GetPreamble().Length
6060
* always delivers a fixed length (does not mater what kind of data)
@@ -72,7 +72,7 @@ public sealed override long Position
7272

7373
public sealed override bool IsBufferComplete => true;
7474

75-
protected static int MaxLineLen => MAX_LINE_LEN;
75+
protected static int MaxLineLen => ConfigManager.Settings.preferences.MaxLineLength;
7676

7777
#endregion
7878

@@ -149,11 +149,11 @@ protected void MovePosition(int offset)
149149
private int DetectPreambleLengthAndEncoding(out Encoding detectedEncoding)
150150
{
151151
/*
152-
UTF-8: EF BB BF
153-
UTF-16-Big-Endian-Byteorder: FE FF
154-
UTF-16-Little-Endian-Byteorder: FF FE
155-
UTF-32-Big-Endian-Byteorder: 00 00 FE FF
156-
UTF-32-Little-Endian-Byteorder: FF FE 00 00
152+
UTF-8: EF BB BF
153+
UTF-16-Big-Endian-Byteorder: FE FF
154+
UTF-16-Little-Endian-Byteorder: FF FE
155+
UTF-32-Big-Endian-Byteorder: 00 00 FE FF
156+
UTF-32-Little-Endian-Byteorder: FF FE 00 00
157157
*/
158158

159159
byte[] readPreamble = new byte[4];
@@ -205,17 +205,17 @@ private int GetPosIncPrecomputed(Encoding usedEncoding)
205205
switch (usedEncoding)
206206
{
207207
case UTF8Encoding _:
208-
{
209-
return 0;
210-
}
208+
{
209+
return 0;
210+
}
211211
case UnicodeEncoding _:
212-
{
213-
return 2;
214-
}
212+
{
213+
return 2;
214+
}
215215
default:
216-
{
217-
return 1;
218-
}
216+
{
217+
return 1;
218+
}
219219
}
220220
}
221221

0 commit comments

Comments
 (0)