Address some comments
This commit is contained in:
parent
0a2403b3cc
commit
96e5f8fc6c
9 changed files with 39 additions and 52 deletions
|
@ -25,49 +25,49 @@ namespace Ryujinx.Configuration
|
||||||
|
|
||||||
private static void ReloadEnableDebug(object sender, ReactiveEventArgs<bool> e)
|
private static void ReloadEnableDebug(object sender, ReactiveEventArgs<bool> e)
|
||||||
{
|
{
|
||||||
Logger.SetEnable(LogLevel.Debug, e.Value);
|
Logger.SetEnable(LogLevel.Debug, e.NewValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReloadEnableStub(object sender, ReactiveEventArgs<bool> e)
|
private static void ReloadEnableStub(object sender, ReactiveEventArgs<bool> e)
|
||||||
{
|
{
|
||||||
Logger.SetEnable(LogLevel.Stub, e.Value);
|
Logger.SetEnable(LogLevel.Stub, e.NewValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReloadEnableInfo(object sender, ReactiveEventArgs<bool> e)
|
private static void ReloadEnableInfo(object sender, ReactiveEventArgs<bool> e)
|
||||||
{
|
{
|
||||||
Logger.SetEnable(LogLevel.Info, e.Value);
|
Logger.SetEnable(LogLevel.Info, e.NewValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReloadEnableWarning(object sender, ReactiveEventArgs<bool> e)
|
private static void ReloadEnableWarning(object sender, ReactiveEventArgs<bool> e)
|
||||||
{
|
{
|
||||||
Logger.SetEnable(LogLevel.Warning, e.Value);
|
Logger.SetEnable(LogLevel.Warning, e.NewValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReloadEnableError(object sender, ReactiveEventArgs<bool> e)
|
private static void ReloadEnableError(object sender, ReactiveEventArgs<bool> e)
|
||||||
{
|
{
|
||||||
Logger.SetEnable(LogLevel.Error, e.Value);
|
Logger.SetEnable(LogLevel.Error, e.NewValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReloadEnableGuest(object sender, ReactiveEventArgs<bool> e)
|
private static void ReloadEnableGuest(object sender, ReactiveEventArgs<bool> e)
|
||||||
{
|
{
|
||||||
Logger.SetEnable(LogLevel.Guest, e.Value);
|
Logger.SetEnable(LogLevel.Guest, e.NewValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReloadEnableFsAccessLog(object sender, ReactiveEventArgs<bool> e)
|
private static void ReloadEnableFsAccessLog(object sender, ReactiveEventArgs<bool> e)
|
||||||
{
|
{
|
||||||
Logger.SetEnable(LogLevel.AccessLog, e.Value);
|
Logger.SetEnable(LogLevel.AccessLog, e.NewValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ReloadFilteredClasses(object sender, ReactiveEventArgs<LogClass[]> e)
|
private static void ReloadFilteredClasses(object sender, ReactiveEventArgs<LogClass[]> e)
|
||||||
{
|
{
|
||||||
bool noFilter = e.Value.Length == 0;
|
bool noFilter = e.NewValue.Length == 0;
|
||||||
|
|
||||||
foreach (var logClass in EnumExtensions.GetValues<LogClass>())
|
foreach (var logClass in EnumExtensions.GetValues<LogClass>())
|
||||||
{
|
{
|
||||||
Logger.SetEnable(logClass, noFilter);
|
Logger.SetEnable(logClass, noFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var logClass in e.Value)
|
foreach (var logClass in e.NewValue)
|
||||||
{
|
{
|
||||||
Logger.SetEnable(logClass, true);
|
Logger.SetEnable(logClass, true);
|
||||||
}
|
}
|
||||||
|
@ -75,20 +75,17 @@ namespace Ryujinx.Configuration
|
||||||
|
|
||||||
private static void ReloadFileLogger(object sender, ReactiveEventArgs<bool> e)
|
private static void ReloadFileLogger(object sender, ReactiveEventArgs<bool> e)
|
||||||
{
|
{
|
||||||
if (e.Value != e.OldValue)
|
if (e.NewValue)
|
||||||
{
|
{
|
||||||
if (e.Value)
|
Logger.AddTarget(new AsyncLogTargetWrapper(
|
||||||
{
|
new FileLogTarget(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Ryujinx.log"), "file"),
|
||||||
Logger.AddTarget(new AsyncLogTargetWrapper(
|
1000,
|
||||||
new FileLogTarget(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Ryujinx.log"), "file"),
|
AsyncLogTargetOverflowAction.Block
|
||||||
1000,
|
));
|
||||||
AsyncLogTargetOverflowAction.Block
|
}
|
||||||
));
|
else
|
||||||
}
|
{
|
||||||
else
|
Logger.RemoveTarget("file");
|
||||||
{
|
|
||||||
Logger.RemoveTarget("file");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ namespace Ryujinx.Common.Logging
|
||||||
{
|
{
|
||||||
foreach (var target in m_LogTargets)
|
foreach (var target in m_LogTargets)
|
||||||
{
|
{
|
||||||
if (target.GetName().Equals(targetName))
|
if (target.Name.Equals(targetName))
|
||||||
{
|
{
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ namespace Ryujinx.Common.Logging
|
||||||
|
|
||||||
private readonly int _overflowTimeout;
|
private readonly int _overflowTimeout;
|
||||||
|
|
||||||
|
string ILogTarget.Name { get => _target.Name; set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
public AsyncLogTargetWrapper(ILogTarget target)
|
public AsyncLogTargetWrapper(ILogTarget target)
|
||||||
: this(target, -1, AsyncLogTargetOverflowAction.Block)
|
: this(target, -1, AsyncLogTargetOverflowAction.Block)
|
||||||
{ }
|
{ }
|
||||||
|
@ -72,10 +74,5 @@ namespace Ryujinx.Common.Logging
|
||||||
_messageQueue.CompleteAdding();
|
_messageQueue.CompleteAdding();
|
||||||
_messageThread.Join();
|
_messageThread.Join();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetName()
|
|
||||||
{
|
|
||||||
return _target.GetName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,6 +11,8 @@ namespace Ryujinx.Common.Logging
|
||||||
|
|
||||||
private readonly string _name;
|
private readonly string _name;
|
||||||
|
|
||||||
|
string ILogTarget.Name { get => _name; set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
static ConsoleLogTarget()
|
static ConsoleLogTarget()
|
||||||
{
|
{
|
||||||
_logColors = new ConcurrentDictionary<LogLevel, ConsoleColor> {
|
_logColors = new ConcurrentDictionary<LogLevel, ConsoleColor> {
|
||||||
|
@ -47,10 +49,5 @@ namespace Ryujinx.Common.Logging
|
||||||
{
|
{
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetName()
|
|
||||||
{
|
|
||||||
return _name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Logging
|
namespace Ryujinx.Common.Logging
|
||||||
|
@ -11,6 +12,8 @@ namespace Ryujinx.Common.Logging
|
||||||
private readonly ILogFormatter _formatter;
|
private readonly ILogFormatter _formatter;
|
||||||
private readonly string _name;
|
private readonly string _name;
|
||||||
|
|
||||||
|
string ILogTarget.Name { get => _name; set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
public FileLogTarget(string path, string name)
|
public FileLogTarget(string path, string name)
|
||||||
: this(path, name, FileShare.Read, FileMode.Append)
|
: this(path, name, FileShare.Read, FileMode.Append)
|
||||||
{ }
|
{ }
|
||||||
|
@ -34,10 +37,5 @@ namespace Ryujinx.Common.Logging
|
||||||
_logWriter.Flush();
|
_logWriter.Flush();
|
||||||
_logWriter.Dispose();
|
_logWriter.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetName()
|
|
||||||
{
|
|
||||||
return _name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace Ryujinx.Common.Logging
|
||||||
{
|
{
|
||||||
void Log(object sender, LogEventArgs args);
|
void Log(object sender, LogEventArgs args);
|
||||||
|
|
||||||
string GetName();
|
string Name { get; protected set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using Utf8Json;
|
using Utf8Json;
|
||||||
|
|
||||||
namespace Ryujinx.Common.Logging
|
namespace Ryujinx.Common.Logging
|
||||||
|
@ -9,6 +10,8 @@ namespace Ryujinx.Common.Logging
|
||||||
private bool _leaveOpen;
|
private bool _leaveOpen;
|
||||||
private string _name;
|
private string _name;
|
||||||
|
|
||||||
|
string ILogTarget.Name { get => _name; set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
public JsonLogTarget(Stream stream, string name)
|
public JsonLogTarget(Stream stream, string name)
|
||||||
{
|
{
|
||||||
_stream = stream;
|
_stream = stream;
|
||||||
|
@ -33,10 +36,5 @@ namespace Ryujinx.Common.Logging
|
||||||
_stream.Dispose();
|
_stream.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetName()
|
|
||||||
{
|
|
||||||
return _name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,12 @@ namespace Ryujinx.Common
|
||||||
public class ReactiveEventArgs<T>
|
public class ReactiveEventArgs<T>
|
||||||
{
|
{
|
||||||
public T OldValue { get; private set; }
|
public T OldValue { get; private set; }
|
||||||
public T Value { get; private set; }
|
public T NewValue { get; private set; }
|
||||||
|
|
||||||
public ReactiveEventArgs(T oldValue, T value)
|
public ReactiveEventArgs(T oldValue, T newValue)
|
||||||
{
|
{
|
||||||
OldValue = oldValue;
|
OldValue = oldValue;
|
||||||
Value = value;
|
NewValue = newValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Ryujinx.Configuration
|
||||||
|
|
||||||
private static void Update(object sender, ReactiveEventArgs<bool> e)
|
private static void Update(object sender, ReactiveEventArgs<bool> e)
|
||||||
{
|
{
|
||||||
if (e.OldValue != e.Value)
|
if (e.OldValue != e.NewValue)
|
||||||
{
|
{
|
||||||
// If the integration was active, disable it and unload everything
|
// If the integration was active, disable it and unload everything
|
||||||
if (e.OldValue)
|
if (e.OldValue)
|
||||||
|
@ -42,7 +42,7 @@ namespace Ryujinx.Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we need to activate it and the client isn't active, initialize it
|
// If we need to activate it and the client isn't active, initialize it
|
||||||
if (e.Value && DiscordClient == null)
|
if (e.NewValue && DiscordClient == null)
|
||||||
{
|
{
|
||||||
DiscordClient = new DiscordRpcClient("568815339807309834");
|
DiscordClient = new DiscordRpcClient("568815339807309834");
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ namespace Ryujinx.Configuration
|
||||||
DiscordPresence.State = state;
|
DiscordPresence.State = state;
|
||||||
DiscordPresence.Assets.LargeImageText = titleName;
|
DiscordPresence.Assets.LargeImageText = titleName;
|
||||||
DiscordPresence.Assets.SmallImageKey = "ryujinx";
|
DiscordPresence.Assets.SmallImageKey = "ryujinx";
|
||||||
DiscordPresence.Assets.SmallImageText = "Ryujinx is an emulator for the Nintendo Switch";
|
DiscordPresence.Assets.SmallImageText = "Ryujinx is a Nintendo Switch emulator";
|
||||||
DiscordPresence.Timestamps = new Timestamps(DateTime.UtcNow);
|
DiscordPresence.Timestamps = new Timestamps(DateTime.UtcNow);
|
||||||
|
|
||||||
DiscordClient?.SetPresence(DiscordPresence);
|
DiscordClient?.SetPresence(DiscordPresence);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue