Skip to content

Commit

Permalink
AutoColumnize throws an Exception with multiple files if no bookmarks…
Browse files Browse the repository at this point in the history
… 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
Show file tree
Hide file tree
Showing 28 changed files with 424 additions and 466 deletions.
94 changes: 0 additions & 94 deletions src/AutoColumnizer.Tests/AutoColumnizer.Tests.csproj

This file was deleted.

75 changes: 0 additions & 75 deletions src/AutoColumnizer.Tests/AutoColumnizerTest.cs

This file was deleted.

20 changes: 0 additions & 20 deletions src/AutoColumnizer.Tests/Properties/AssemblyInfo.cs

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

172 changes: 65 additions & 107 deletions src/AutoColumnizer/AutoColumnizer.cs
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
}
}
1 change: 0 additions & 1 deletion src/ColumnizerLib/ColumnizerLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
</Compile>
<Compile Include="Column.cs" />
<Compile Include="ColumnizedLogLine.cs" />
<Compile Include="IAutoColumnizer.cs" />
<Compile Include="IAutoLogLineColumnizerCallback.cs" />
<Compile Include="IColumn.cs" />
<Compile Include="IColumnizerConfigurator.cs" />
Expand Down
Loading

0 comments on commit ffabd9c

Please sign in to comment.