Address some comments

This commit is contained in:
Thog 2019-12-05 03:25:29 +01:00
parent 0a2403b3cc
commit 96e5f8fc6c
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
9 changed files with 39 additions and 52 deletions

View file

@ -25,49 +25,49 @@ namespace Ryujinx.Configuration
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)
{
Logger.SetEnable(LogLevel.Stub, e.Value);
Logger.SetEnable(LogLevel.Stub, e.NewValue);
}
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)
{
Logger.SetEnable(LogLevel.Warning, e.Value);
Logger.SetEnable(LogLevel.Warning, e.NewValue);
}
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)
{
Logger.SetEnable(LogLevel.Guest, e.Value);
Logger.SetEnable(LogLevel.Guest, e.NewValue);
}
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)
{
bool noFilter = e.Value.Length == 0;
bool noFilter = e.NewValue.Length == 0;
foreach (var logClass in EnumExtensions.GetValues<LogClass>())
{
Logger.SetEnable(logClass, noFilter);
}
foreach (var logClass in e.Value)
foreach (var logClass in e.NewValue)
{
Logger.SetEnable(logClass, true);
}
@ -75,20 +75,17 @@ namespace Ryujinx.Configuration
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"),
1000,
AsyncLogTargetOverflowAction.Block
));
}
else
{
Logger.RemoveTarget("file");
}
Logger.AddTarget(new AsyncLogTargetWrapper(
new FileLogTarget(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Ryujinx.log"), "file"),
1000,
AsyncLogTargetOverflowAction.Block
));
}
else
{
Logger.RemoveTarget("file");
}
}

View file

@ -54,7 +54,7 @@ namespace Ryujinx.Common.Logging
{
foreach (var target in m_LogTargets)
{
if (target.GetName().Equals(targetName))
if (target.Name.Equals(targetName))
{
return target;
}

View file

@ -27,6 +27,8 @@ namespace Ryujinx.Common.Logging
private readonly int _overflowTimeout;
string ILogTarget.Name { get => _target.Name; set => throw new NotImplementedException(); }
public AsyncLogTargetWrapper(ILogTarget target)
: this(target, -1, AsyncLogTargetOverflowAction.Block)
{ }
@ -72,10 +74,5 @@ namespace Ryujinx.Common.Logging
_messageQueue.CompleteAdding();
_messageThread.Join();
}
public string GetName()
{
return _target.GetName();
}
}
}

View file

@ -11,6 +11,8 @@ namespace Ryujinx.Common.Logging
private readonly string _name;
string ILogTarget.Name { get => _name; set => throw new NotImplementedException(); }
static ConsoleLogTarget()
{
_logColors = new ConcurrentDictionary<LogLevel, ConsoleColor> {
@ -47,10 +49,5 @@ namespace Ryujinx.Common.Logging
{
Console.ResetColor();
}
public string GetName()
{
return _name;
}
}
}

View file

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Text;
namespace Ryujinx.Common.Logging
@ -11,6 +12,8 @@ namespace Ryujinx.Common.Logging
private readonly ILogFormatter _formatter;
private readonly string _name;
string ILogTarget.Name { get => _name; set => throw new NotImplementedException(); }
public FileLogTarget(string path, string name)
: this(path, name, FileShare.Read, FileMode.Append)
{ }
@ -34,10 +37,5 @@ namespace Ryujinx.Common.Logging
_logWriter.Flush();
_logWriter.Dispose();
}
public string GetName()
{
return _name;
}
}
}

View file

@ -6,6 +6,6 @@ namespace Ryujinx.Common.Logging
{
void Log(object sender, LogEventArgs args);
string GetName();
string Name { get; protected set; }
}
}

View file

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using Utf8Json;
namespace Ryujinx.Common.Logging
@ -9,6 +10,8 @@ namespace Ryujinx.Common.Logging
private bool _leaveOpen;
private string _name;
string ILogTarget.Name { get => _name; set => throw new NotImplementedException(); }
public JsonLogTarget(Stream stream, string name)
{
_stream = stream;
@ -33,10 +36,5 @@ namespace Ryujinx.Common.Logging
_stream.Dispose();
}
}
public string GetName()
{
return _name;
}
}
}

View file

@ -46,12 +46,12 @@ namespace Ryujinx.Common
public class ReactiveEventArgs<T>
{
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;
Value = value;
NewValue = newValue;
}
}
}

View file

@ -31,7 +31,7 @@ namespace Ryujinx.Configuration
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 (e.OldValue)
@ -42,7 +42,7 @@ namespace Ryujinx.Configuration
}
// 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");
@ -81,7 +81,7 @@ namespace Ryujinx.Configuration
DiscordPresence.State = state;
DiscordPresence.Assets.LargeImageText = titleName;
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);
DiscordClient?.SetPresence(DiscordPresence);