forked from zarunbal/LogExpert
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AutoColumnize throws an Exception with multiple files if no bookmarks…
… are found zarunbal#102 Update the AutoColumnizer logic to fix the bug.
- Loading branch information
miltob
committed
May 30, 2019
1 parent
87bd9ff
commit ffabd9c
Showing
28 changed files
with
424 additions
and
466 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
src/AutoColumnizer.Tests/TestData/SquareBracketColumnizerTest_01.txt
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
src/AutoColumnizer.Tests/TestData/SquareBracketColumnizerTest_02.txt
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
src/AutoColumnizer.Tests/TestData/SquareBracketColumnizerTest_03.txt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
src/AutoColumnizer.Tests/TestData/SquareBracketColumnizerTest_04.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,66 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace LogExpert | ||
{ | ||
public class AutoColumnizer : ILogLineColumnizer, IAutoColumnizer | ||
{ | ||
#region ILogLineColumnizer implementation | ||
|
||
public string Text => GetName(); | ||
|
||
public bool IsTimeshiftImplemented() | ||
{ | ||
return true; | ||
} | ||
|
||
public string GetName() | ||
{ | ||
return "Auto Columnizer"; | ||
} | ||
|
||
public string GetDescription() | ||
{ | ||
return "Automatically find the right columnizer for any file"; | ||
} | ||
|
||
public ILogLineColumnizer FindColumnizer(string fileName, IAutoLogLineColumnizerCallback logFileReader) | ||
{ | ||
if (logFileReader == null || string.IsNullOrEmpty(fileName)) | ||
{ | ||
return logFileReader.GetDefaultColumnizer(); | ||
} | ||
|
||
List<ILogLine> loglines = new List<ILogLine> | ||
{ | ||
// Sampling a few lines to select the correct columnizer | ||
logFileReader.GetLogLine(0), | ||
logFileReader.GetLogLine(1), | ||
logFileReader.GetLogLine(2), | ||
logFileReader.GetLogLine(3), | ||
logFileReader.GetLogLine(4), | ||
logFileReader.GetLogLine(5), | ||
logFileReader.GetLogLine(25), | ||
logFileReader.GetLogLine(100), | ||
logFileReader.GetLogLine(200), | ||
logFileReader.GetLogLine(400) | ||
}; | ||
|
||
var registeredColumnizer = logFileReader.GetRegisteredColumnizers(); | ||
|
||
List<Tuple<Priority, ILogLineColumnizer>> priorityListOfColumnizers = new List<Tuple<Priority, ILogLineColumnizer>>(); | ||
|
||
foreach (ILogLineColumnizer logLineColumnizer in registeredColumnizer) | ||
{ | ||
var columnizerPriority = logLineColumnizer as IColumnizerPriority; | ||
Priority priority = default(Priority); | ||
if (columnizerPriority != null) | ||
{ | ||
priority = columnizerPriority.GetPriority(fileName, loglines); | ||
} | ||
|
||
priorityListOfColumnizers.Add(new Tuple<Priority, ILogLineColumnizer>(priority, logLineColumnizer)); | ||
} | ||
|
||
ILogLineColumnizer lineColumnizer = priorityListOfColumnizers.OrderByDescending(a => a.Item1).Select(a => a.Item2).First(); | ||
|
||
return lineColumnizer; | ||
} | ||
|
||
public int GetColumnCount() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string[] GetColumnNames() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void SetTimeOffset(int msecOffset) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public int GetTimeOffset() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) | ||
{ | ||
} | ||
|
||
#endregion ILogLineColumnizer implementation | ||
} | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace LogExpert | ||
{ | ||
public class AutoColumnizer : ILogLineColumnizer | ||
{ | ||
#region ILogLineColumnizer implementation | ||
|
||
public string Text => GetName(); | ||
|
||
public bool IsTimeshiftImplemented() | ||
{ | ||
return true; | ||
} | ||
|
||
public string GetName() | ||
{ | ||
return "Auto Columnizer"; | ||
} | ||
|
||
public string GetDescription() | ||
{ | ||
return "Automatically find the right columnizer for any file"; | ||
} | ||
|
||
|
||
public int GetColumnCount() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public string[] GetColumnNames() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public IColumnizedLogLine SplitLine(ILogLineColumnizerCallback callback, ILogLine line) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void SetTimeOffset(int msecOffset) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public int GetTimeOffset() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public DateTime GetTimestamp(ILogLineColumnizerCallback callback, ILogLine line) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void PushValue(ILogLineColumnizerCallback callback, int column, string value, string oldValue) | ||
{ | ||
} | ||
|
||
#endregion ILogLineColumnizer implementation | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.