Skip to content

Commit 4b1fbec

Browse files
committed
Add timestamps and tags to logs
1 parent 6a1e895 commit 4b1fbec

39 files changed

+276
-169
lines changed

azure-pipelines.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ steps:
129129
command: 'restore'
130130
projects: 'sharp/*.csproj'
131131

132+
- task: PowerShell@2
133+
condition: succeeded()
134+
displayName: 'Build: dotnet: inject version number'
135+
continueOnError: true
136+
inputs:
137+
targetType: 'inline'
138+
script: |
139+
(Get-Content -Path 'sharp/Program.cs') -Replace 'SECRET DEV VERSION', "${env:BUILD_BUILDNUMBER}-azure-${env:BUILD_BUILDID}-$(($env:BUILD_SOURCEVERSION).Substring(0, 5))" | Set-Content -Path 'sharp/Program.cs'
140+
Get-Content -Path 'sharp/Program.cs'
141+
132142
- task: DotNetCoreCLI@2
133143
displayName: 'Build: dotnet: build sharp'
134144
inputs:

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ and only contains the latest changes.
33
Its purpose is to be shown in Olympus when updating.
44

55
#changelog#
6-
Use API mirror to update mods if enabled
6+
Added timestamps and tags to logs

sharp/AhornHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Olympus {
99
public static class AhornHelper {
10+
private static readonly Logger log = new Logger(nameof(AhornHelper));
1011

1112
private const string PrefixGlobal = @"
1213
@eval(Base, ttyhascolor(term_type = nothing) = false)
@@ -211,7 +212,7 @@ public static string GetJuliaOutput(string script, out string err, bool? localDe
211212
process.WaitForExit();
212213
err = process.StandardError.ReadToEnd().Trim();
213214
if (!string.IsNullOrEmpty(err))
214-
Console.Error.WriteLine(err);
215+
log.Error(err);
215216
return process.StandardOutput.ReadToEnd().Trim();
216217
}
217218
} finally {

sharp/CmdAhornInstallJulia.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Olympus {
1010
public class CmdAhornInstallJulia : Cmd<bool, IEnumerator> {
11+
private static readonly Logger log = new Logger(nameof(CmdAhornInstallJulia));
1112

1213
public static readonly string Version = "1.6.0";
1314
public static readonly string VersionBeta = "1.6.0";
@@ -212,8 +213,7 @@ setlocal EnableDelayedExpansion
212213
throw new Exception("hdiutil detach encountered a fatal error:\n" + process.StandardError.ReadToEnd());
213214
}
214215
} catch (Exception e) {
215-
Console.Error.WriteLine("Error unmounting Julia dmg in installer finally clause");
216-
Console.Error.WriteLine(e);
216+
log.Error("Error unmounting Julia dmg in installer finally clause: " + e);
217217
}
218218
}
219219

sharp/CmdGetLoennLatestVersion.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Olympus {
77
public class CmdGetLoennLatestVersion : Cmd<bool, Tuple<string, string>> {
8+
private static readonly Logger log = new Logger(nameof(CmdGetLoennLatestVersion));
89

910
public override bool Taskable => true;
1011

@@ -18,7 +19,7 @@ public override Tuple<string, string> Run(bool apiMirror) {
1819
return new Tuple<string, string>((string) latestVersion["tag_name"], GetDownloadLink((JArray) latestVersion["assets"]));
1920
}
2021
} catch (Exception ex) {
21-
Console.Error.WriteLine("Error while checking Loenn version: " + ex);
22+
log.Warning("Error while checking Loenn version: " + ex);
2223
return new Tuple<string, string>("unknown", "");
2324
}
2425
}
@@ -32,7 +33,7 @@ private static string GetDownloadLink(JArray assets) {
3233
} else if (PlatformHelper.Is(Platform.MacOS)) {
3334
wantedSuffix = "-macos.app.zip";
3435
} else {
35-
Console.Error.WriteLine($"Unsupported platform: {PlatformHelper.Current}");
36+
log.Warning($"Unsupported platform: {PlatformHelper.Current}");
3637
return "";
3738
}
3839

@@ -43,7 +44,7 @@ private static string GetDownloadLink(JArray assets) {
4344
}
4445
}
4546

46-
Console.Error.WriteLine("Loenn artifact not found");
47+
log.Warning("Loenn artifact not found");
4748
return "";
4849
}
4950
}

sharp/CmdGetModIdToNameMap.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
namespace Olympus {
99
public class CmdGetModIdToNameMap : Cmd<string, bool, bool> {
10+
private static readonly Logger log = new Logger(nameof(CmdGetModIdToNameMap));
11+
1012
public override bool Taskable => true;
1113

1214
private static string cacheLocation;
@@ -15,7 +17,7 @@ public class CmdGetModIdToNameMap : Cmd<string, bool, bool> {
1517
public override bool Run(string cacheLocation, bool apiMirror) {
1618
CmdGetModIdToNameMap.cacheLocation = cacheLocation;
1719
CmdGetModIdToNameMap.apiMirror = apiMirror;
18-
Console.Error.WriteLine($"[CmdGetIdToNameMap] Cache location set to: {cacheLocation}");
20+
log.Debug($"Cache location set to: {cacheLocation}");
1921
GetModIDsToNamesMap(ignoreCache: true);
2022
return true;
2123
}
@@ -26,7 +28,7 @@ internal static Dictionary<string, string> GetModIDsToNamesMap(bool ignoreCache
2628
Dictionary<string, string> map;
2729

2830
if (!ignoreCache && File.Exists(cacheLocation)) {
29-
Console.Error.WriteLine($"[CmdGetIdToNameMap] Loading mod IDs from {cacheLocation}");
31+
log.Debug($"Loading mod IDs from {cacheLocation}");
3032
map = tryRun(() => {
3133
lock (locker)
3234
using (Stream inputStream = new FileStream(cacheLocation, FileMode.Open)) {
@@ -36,7 +38,7 @@ internal static Dictionary<string, string> GetModIDsToNamesMap(bool ignoreCache
3638
if (map.Count > 0) return map;
3739
}
3840

39-
Console.Error.WriteLine($"[CmdGetIdToNameMap] Loading mod IDs from the Internet");
41+
log.Debug($"[CmdGetIdToNameMap] Loading mod IDs from the Internet (apiMirror = {apiMirror})");
4042
map = tryRun(() => {
4143
using (HttpClient wc = new HttpClientWithCompressionSupport())
4244
using (Stream inputStream = wc.GetAsync(
@@ -53,8 +55,7 @@ private static Dictionary<string, string> tryRun(Func<Dictionary<string, string>
5355
try {
5456
return function();
5557
} catch (Exception e) {
56-
Console.Error.WriteLine("Error loading mod IDs to names list");
57-
Console.Error.WriteLine(e);
58+
log.Warning("Error loading mod IDs to names list: " + e);
5859
return new Dictionary<string, string>();
5960
}
6061
}

sharp/CmdInstallEverest.MiniInstaller.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace Olympus {
1111
public partial class CmdInstallEverest : Cmd<string, string, string, string, IEnumerator> {
12+
private static readonly Logger log = new Logger(nameof(CmdInstallEverest));
13+
1214
public static bool CheckNativeMiniInstaller(ZipArchive zip, string prefix = "")
1315
=> zip.GetEntry($"{prefix}MiniInstaller.exe") == null;
1416

@@ -36,7 +38,7 @@ public static IEnumerator Install(string root, bool isNative) {
3638
bridge.IsDone = true;
3739
bridge.WriteLine("MiniInstaller died a brutal death");
3840

39-
Console.Error.WriteLine(e);
41+
log.Error(e.ToString());
4042
}
4143
}) {
4244
Name = "MiniInstaller"
@@ -156,7 +158,7 @@ class MiniInstallerBridge : MarshalByRefObject, IDisposable {
156158

157159
public void Write(string value) => Console.Error.Write(value);
158160
public void WriteLine(string value) {
159-
Console.Error.WriteLine(value);
161+
log.Debug(value);
160162
LastLogLine = value;
161163
LogEvent?.Set();
162164
}

sharp/CmdInstallOlympus.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Olympus {
1212
public class CmdInstallOlympus : Cmd<string, IEnumerator> {
13+
private static readonly Logger log = new Logger(nameof(CmdInstallOlympus));
1314

1415
public override IEnumerator Run(string id) {
1516
yield return Status("Updating Olympus", false, "", false);
@@ -73,7 +74,7 @@ public static IEnumerator Unwrap(ZipArchive wrap, string wrapName) {
7374
yield return Status("Unpacking olympus.love", false, "download", false);
7475
string to = Path.Combine(Program.RootDirectory, "olympus.new.love");
7576
string toParent = Path.GetDirectoryName(to);
76-
Console.Error.WriteLine($"{name} -> {to}");
77+
log.Debug($"{name} -> {to}");
7778

7879
if (!Directory.Exists(toParent))
7980
Directory.CreateDirectory(toParent);

sharp/CmdLaunch.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Olympus {
66
public class CmdLaunch : Cmd<string, string, bool, string> {
7+
private static readonly Logger log = new Logger(nameof(CmdLaunch));
78

89
public override bool Taskable => true;
910

@@ -30,7 +31,7 @@ public override string Run(string root, string args, bool force) {
3031
}
3132

3233
if (!File.Exists(game.StartInfo.FileName)) {
33-
Console.Error.WriteLine($"Can't start Celeste: {game.StartInfo.FileName} not found!");
34+
log.Error($"Can't start Celeste: {game.StartInfo.FileName} not found!");
3435
return "missing";
3536
}
3637

@@ -43,10 +44,10 @@ public override string Run(string root, string args, bool force) {
4344
try {
4445
File.WriteAllText(Path.Combine(root, "nextLaunchIsVanilla.txt"), "This file was created by Olympus and will be deleted automatically.");
4546
args = "";
46-
Console.Error.WriteLine("nextLaunchIsVanilla.txt created");
47+
log.Debug("nextLaunchIsVanilla.txt created");
4748
}
4849
catch (Exception e) {
49-
Console.Error.WriteLine($"Failed to create nextLaunchIsVanilla.txt: {e}");
50+
log.Error($"Failed to create nextLaunchIsVanilla.txt: {e}");
5051
}
5152
}
5253
}
@@ -75,7 +76,7 @@ public override string Run(string root, string args, bool force) {
7576
game.StartInfo.FileName = Path.Combine(Program.RootDirectory, "flatpak-wrapper");
7677
}
7778

78-
Console.Error.WriteLine($"Starting Celeste process: {game.StartInfo.FileName} {(string.IsNullOrEmpty(args) ? "(without args)" : args)}");
79+
log.Info($"Starting Celeste process: {game.StartInfo.FileName} {(string.IsNullOrEmpty(args) ? "(without args)" : args)}");
7980

8081
#if !WIN32
8182
if (!isFlatpak) {

sharp/CmdLaunchLoenn.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Olympus {
77
public class CmdLaunchLoenn : Cmd<string, string> {
8+
private static readonly Logger log = new Logger(nameof(CmdLaunchLoenn));
89

910
public override bool Taskable => true;
1011

@@ -28,7 +29,7 @@ public override string Run(string root) {
2829
}
2930

3031

31-
Console.Error.WriteLine($"Starting Loenn process: {loenn.StartInfo.FileName} {loenn.StartInfo.Arguments} (in {root})");
32+
log.Info($"Starting Loenn process: {loenn.StartInfo.FileName} {loenn.StartInfo.Arguments} (in {root})");
3233

3334
loenn.HandleLaunchWrapper("LOENN");
3435

0 commit comments

Comments
 (0)