Skip to content

Commit e1940ef

Browse files
committed
🩹 minor cleanup
1 parent 1159267 commit e1940ef

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

Console/Program.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
using EliteAPI;
2+
using EliteAPI.Utils;
3+
4+
Log.AddListener(log =>
5+
{
6+
if (log.Level < Log.LogLevel.Info)
7+
return;
8+
9+
ConsoleColor color = log.Level switch
10+
{
11+
Log.LogLevel.Debug => ConsoleColor.Gray,
12+
Log.LogLevel.Info => ConsoleColor.Blue,
13+
Log.LogLevel.Warning => ConsoleColor.Yellow,
14+
Log.LogLevel.Error => ConsoleColor.Red
15+
};
16+
17+
var previousColor = Console.ForegroundColor;
18+
Console.ForegroundColor = color;
19+
Console.WriteLine(log.Message);
20+
Console.ForegroundColor = previousColor;
21+
});
222

323
var api = new EliteDangerousApi();
424

EliteAPI/EliteDangerousApi.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public class EliteDangerousApi
3030

3131
public EliteDangerousApi()
3232
{
33-
var journalDirectory = JournalUtils.GetJournalsDirectory();
3433
string[] statusFiles = [
3534
"Cargo.json",
3635
"Market.json",
@@ -43,10 +42,10 @@ public EliteDangerousApi()
4342
];
4443

4544
_statusWatchers = statusFiles
46-
.Select(fileName => FileWatcher.Create(journalDirectory, fileName, FileWatchMode.EntireFile))
45+
.Select(fileName => FileWatcher.Create(JournalUtils.GetJournalsDirectory(), fileName, FileWatchMode.EntireFile))
4746
.ToList();
4847

49-
_journalWatcher = FileWatcher.Create(journalDirectory, "Journal.*.log", FileWatchMode.LineByLine);
48+
_journalWatcher = FileWatcher.Create(JournalUtils.GetJournalsDirectory(), "Journal.*.log", FileWatchMode.LineByLine);
5049
}
5150

5251
public void Start()
@@ -66,6 +65,7 @@ public void Start()
6665

6766
_statusWatchers.ForEach(w => w.StartWatching());
6867
_journalWatcher.StartWatching();
68+
6969
}
7070

7171
/// <summary>
@@ -224,4 +224,3 @@ internal void Invoke(string json, IEvent? @event)
224224
}
225225
}
226226
}
227-

EliteAPI/Watcher/FileWatcher.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,8 @@ public string StartWatching()
9191
if (_directory != null && _filePattern != null)
9292
{
9393
if (_directoryWatcher != null)
94-
{
9594
_directoryWatcher.EnableRaisingEvents = true;
96-
}
95+
9796
return initialContent;
9897
}
9998

0 commit comments

Comments
 (0)