Skip to content
This repository has been archived by the owner on Mar 20, 2022. It is now read-only.

implemented a simple log viewer #100

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions EliteLogAgent/EliteLogAgent.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@
<Compile Include="ContainerBootstrapper.cs" />
<Compile Include="Deployment\DataPathManager.cs" />
<Compile Include="FileSettingsStorage.cs" />
<Compile Include="LogViewer\LogViewer.cs" />
<Compile Include="LogViewer\LogViewer.Designer.cs" />
<Compile Include="Settings\GeneralSettingsControl.cs">
<SubType>UserControl</SubType>
</Compile>
Expand All @@ -157,6 +159,7 @@
<EmbeddedResource Include="AboutForm.resx">
<DependentUpon>AboutForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="LogViewer\LogViewer.resx" />
<EmbeddedResource Include="Settings\GeneralSettingsControl.resx">
<DependentUpon>GeneralSettingsControl.cs</DependentUpon>
</EmbeddedResource>
Expand Down
66 changes: 66 additions & 0 deletions EliteLogAgent/LogViewer/LogViewer.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions EliteLogAgent/LogViewer/LogViewer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using DW.ELA.Utility.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NLog;
using NLog.Targets;

namespace EliteLogAgent.LogViewer
{
public partial class LogViewer : Form
{
private readonly string logDirectory;

public LogViewer(string pathManagerLogDirectory)
{
logDirectory = pathManagerLogDirectory;
InitializeComponent();
}

private void LogViewer_Load(object sender, EventArgs e)
{
foreach (string file in Directory.GetFiles(logDirectory))
{
foreach (string line in File.ReadAllLines(file))
{
try
{
var entry = Serialize.FromJson<Dictionary<string,string>>(line);
listBox1.Items.Add($"[{entry["level"]}][{entry["time"]}] - {entry["message"]}");
}
catch
{
// ignored
}
}
}
}
}
}
Loading