Skip to content
Closed
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
5 changes: 4 additions & 1 deletion VRCFaceTracking.Core/Library/UnifiedLibManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using VRCFaceTracking.Core.Models;
using VRCFaceTracking.Core.Sandboxing;
using VRCFaceTracking.Core.Sandboxing.IPC;
using OperatingSystem = System.OperatingSystem;

namespace VRCFaceTracking.Core.Library;

Expand Down Expand Up @@ -57,7 +58,9 @@ public UnifiedLibManager(ILoggerFactory factory, IDispatcherService dispatcherSe
_moduleDataService = moduleDataService;

LoadedModulesMetadata = new ObservableCollection<ModuleMetadataInternal>();
_sandboxProcessPath = Path.GetFullPath("VRCFaceTracking.ModuleProcess.exe");
_sandboxProcessPath = Path.GetFullPath(OperatingSystem.IsWindows() ?
"VRCFaceTracking.ModuleProcess.exe" :
"VRCFaceTracking.ModuleProcess");
if ( !File.Exists(_sandboxProcessPath) )
{
// @TODO: Better error handling
Expand Down
3 changes: 1 addition & 2 deletions VRCFaceTracking.ModuleProcess/ModuleProcessMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using VRCFaceTracking.Core.Params.Expressions;
using VRCFaceTracking.Core.Sandboxing;
using VRCFaceTracking.Core.Sandboxing.IPC;
using Windows.System;

namespace VRCFaceTracking.ModuleProcess;

Expand Down Expand Up @@ -96,7 +95,7 @@ static int VrcftMain(string modulePath, int serverPortNumber)
// .AddSentry(o =>
// o.Dsn =
// "https://444b0799dd2b670efa85d866c8c12134@o4506152235237376.ingest.us.sentry.io/4506152246575104")
.AddProvider(new ProxyLoggerProvider(DispatcherQueue.GetForCurrentThread()))
.AddProvider(new ProxyLoggerProvider(SynchronizationContext.Current))
)
.BuildServiceProvider();

Expand Down
7 changes: 3 additions & 4 deletions VRCFaceTracking.ModuleProcess/ProxyLogger.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.ObjectModel;
using Microsoft.Extensions.Logging;
using Windows.System;

namespace VRCFaceTracking.ModuleProcess;

Expand All @@ -11,12 +10,12 @@ public class ProxyLogger : ILogger
private readonly string _categoryName;
// public static readonly ObservableCollection<string> AllLogs = new();
public static OnLog OnLog;
private static DispatcherQueue? _dispatcher;
private static SynchronizationContext? _syncContext;

public ProxyLogger(string categoryName, DispatcherQueue? queue)
public ProxyLogger(string categoryName, SynchronizationContext? syncContext = null)
{
_categoryName = categoryName;
_dispatcher = queue;
_syncContext = syncContext ?? SynchronizationContext.Current;
}

public IDisposable BeginScope<TState>(TState state) where TState : notnull => default!;
Expand Down
20 changes: 6 additions & 14 deletions VRCFaceTracking.ModuleProcess/ProxyLoggerProvider.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
using System.Collections.Concurrent;
using System.Threading;
using Microsoft.Extensions.Logging;
using Windows.System;

namespace VRCFaceTracking.ModuleProcess;
public class ProxyLoggerProvider : ILoggerProvider
{
private readonly ConcurrentDictionary<string, ProxyLogger> _loggers =
new(StringComparer.OrdinalIgnoreCase);

private readonly DispatcherQueue _dispatcher;

public ProxyLoggerProvider(DispatcherQueue dispatcher)
public class ProxyLoggerProvider(SynchronizationContext? syncContext = null) : ILoggerProvider
{
public ILogger CreateLogger(string categoryName)
{
_dispatcher = dispatcher;
return new ProxyLogger(categoryName, syncContext);
}

public ILogger CreateLogger(string categoryName) =>
_loggers.GetOrAdd(categoryName, name => new ProxyLogger(name, _dispatcher));

public void Dispose() => _loggers.Clear();
public void Dispose() { }
}
Loading