Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
241 changes: 241 additions & 0 deletions Cargo.lock

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

26 changes: 22 additions & 4 deletions Source/Hurl.BrowserSelector/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Hurl.BrowserSelector.State;
using Hurl.BrowserSelector.Helpers;
using Hurl.BrowserSelector.Helpers;
using Hurl.BrowserSelector.State;
using Hurl.BrowserSelector.Windows;
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Pipes;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Windows;
Expand Down Expand Up @@ -54,6 +54,13 @@ private void Dispatcher_UnhandledException(object sender, System.Windows.Threadi

protected override void OnStartup(StartupEventArgs e)
{
var x = new StringBuilder();
foreach (var arg in e.Args)
{
x.Append(arg);
x.Append(" ");
}
writeLogToFile($"Received startup args: {x.ToString()}");
_singleInstanceMutex = new Mutex(true, MUTEX_NAME, out var isOwned);
_singleInstanceWaitHandle = new EventWaitHandle(false, EventResetMode.AutoReset, EVENT_NAME);

Expand Down Expand Up @@ -121,6 +128,16 @@ public void OnInstanceInvoked(string[] args)
});
}


private void writeLogToFile(string message)
{
var timeOfLog = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
string logFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Hurl", "log.txt");
Directory.CreateDirectory(Path.GetDirectoryName(logFilePath) ?? string.Empty);
File.AppendAllText(logFilePath, $"{timeOfLog}: {message}\n");
}


public void PipeServer()
{
var isFirstTimeLaunching = true;
Expand All @@ -144,6 +161,7 @@ public void PipeServer()

using StreamReader sr = new(_pipeserver);
string args = sr.ReadToEnd();
writeLogToFile($"Received args: {args}");
string[] argsArray = JsonSerializer.Deserialize<string[]>(args) ?? [];
OnInstanceInvoked(argsArray);
}
Expand All @@ -153,7 +171,7 @@ public void PipeServer()
}
catch (Exception e)
{
Debug.WriteLine($"Error in PipeServer: {e.Message}");
writeLogToFile($"Error in PipeServer: {e.Message}");
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Source/Launcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ winresource = "0.1"

[dependencies]
byteorder = "1"
chrono = { version = "0.4", features = ["now"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "net"] }
Expand Down
Loading