Merge 90de1e0fab
into 1a0a351a15
This commit is contained in:
commit
c3fb43ebcc
4 changed files with 60 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
using Ryujinx.Common.Logging.Targets;
|
||||
using Ryujinx.Common.SystemInterop;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
@ -24,6 +25,7 @@ namespace Ryujinx.Common.Logging
|
|||
public readonly struct Log
|
||||
{
|
||||
private static readonly string _homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||
private static readonly string _homeDirShort = WindowsNative.GetShortPathName(_homeDir); // empty string on non-windows platforms
|
||||
private static readonly string _homeDirRedacted = Path.Combine(Directory.GetParent(_homeDir).FullName, "[redacted]");
|
||||
|
||||
internal readonly LogLevel Level;
|
||||
|
@ -106,6 +108,10 @@ namespace Ryujinx.Common.Logging
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private static string FormatMessage(LogClass logClass, string caller, string message)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_homeDirShort))
|
||||
{
|
||||
message = message.Replace(_homeDirShort, _homeDirRedacted);
|
||||
}
|
||||
message = message.Replace(_homeDir, _homeDirRedacted);
|
||||
|
||||
return $"{logClass} {caller}: {message}";
|
||||
|
|
34
src/Ryujinx.Common/Utilities/WindowsNative.cs
Normal file
34
src/Ryujinx.Common/Utilities/WindowsNative.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
namespace Ryujinx.Common.Utilities
|
||||
{
|
||||
public static partial class WindowsNative
|
||||
{
|
||||
[SupportedOSPlatform("windows")]
|
||||
[LibraryImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16, SetLastError = true)]
|
||||
internal static partial int GetShortPathNameW(string longPath, char[] shortPath, int bufferSize);
|
||||
|
||||
private const int ShortPathBufferLength = 256;
|
||||
|
||||
public static string GetShortPathName(string longPath)
|
||||
{
|
||||
if (!OperatingSystem.IsWindows())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
char[] shortPathBuffer = new char[ShortPathBufferLength];
|
||||
int result = GetShortPathNameW(longPath, shortPathBuffer, shortPathBuffer.Length);
|
||||
if (result == 0)
|
||||
{
|
||||
int errCode = Marshal.GetLastWin32Error();
|
||||
Logging.Logger.Debug?.Print(Logging.LogClass.Application, $"GetShortPathName failed for {longPath} (0x{errCode:X08})");
|
||||
return "";
|
||||
}
|
||||
|
||||
return new string(shortPathBuffer[..result]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -338,6 +338,16 @@ namespace Ryujinx
|
|||
|
||||
private static void PrintSystemInfo()
|
||||
{
|
||||
string executablePath = Environment.ProcessPath;
|
||||
if (executablePath != null)
|
||||
{
|
||||
Logger.Notice.Print(LogClass.Application, $"Ryujinx Path: {executablePath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, "Can't determine executable path. It might have been renamed or deleted after launch.");
|
||||
}
|
||||
|
||||
Logger.Notice.Print(LogClass.Application, $"Ryujinx Version: {Version}");
|
||||
SystemInfo.Gather().Print();
|
||||
|
||||
|
|
|
@ -211,6 +211,16 @@ namespace Ryujinx.Ava
|
|||
|
||||
private static void PrintSystemInfo()
|
||||
{
|
||||
string executablePath = Environment.ProcessPath;
|
||||
if (executablePath != null)
|
||||
{
|
||||
Logger.Notice.Print(LogClass.Application, $"Ryujinx Path: {executablePath}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Warning?.Print(LogClass.Application, "Can't determine executable path. It might have been renamed or deleted after launch.");
|
||||
}
|
||||
|
||||
Logger.Notice.Print(LogClass.Application, $"Ryujinx Version: {Version}");
|
||||
SystemInfo.Gather().Print();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue