mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-16 18:46:36 +00:00
Redact usernames from logs (#6255)
* Redact usernames from logs * Changed internal vars to private and applied naming rules * Use Directory.GetParent() instead of DirectoryInfo * Update src/Ryujinx.Common/Logging/Logger.cs --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
parent
d56bab1e24
commit
6c90d50c8e
@ -3,6 +3,7 @@ using Ryujinx.Common.SystemInterop;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
@ -22,6 +23,9 @@ namespace Ryujinx.Common.Logging
|
|||||||
|
|
||||||
public readonly struct Log
|
public readonly struct Log
|
||||||
{
|
{
|
||||||
|
private static readonly string _homeDir = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
|
||||||
|
private static readonly string _homeDirRedacted = Path.Combine(Directory.GetParent(_homeDir).FullName, "[redacted]");
|
||||||
|
|
||||||
internal readonly LogLevel Level;
|
internal readonly LogLevel Level;
|
||||||
|
|
||||||
internal Log(LogLevel level)
|
internal Log(LogLevel level)
|
||||||
@ -100,7 +104,12 @@ namespace Ryujinx.Common.Logging
|
|||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private static string FormatMessage(LogClass logClass, string caller, string message) => $"{logClass} {caller}: {message}";
|
private static string FormatMessage(LogClass logClass, string caller, string message)
|
||||||
|
{
|
||||||
|
message = message.Replace(_homeDir, _homeDirRedacted);
|
||||||
|
|
||||||
|
return $"{logClass} {caller}: {message}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Log? Debug { get; private set; }
|
public static Log? Debug { get; private set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user