add performance logging on demand, fix minion issues
This commit is contained in:
@@ -748,7 +748,7 @@ public class CompactUi : WindowMediatorSubscriberBase, IDisposable
|
||||
|
||||
_serverManager.Save();
|
||||
|
||||
_ = _apiController.CreateConnections(true);
|
||||
_ = _apiController.CreateConnections(forceGetToken: true);
|
||||
}
|
||||
|
||||
_uiShared.DrawCombo("Secret Key##addCharacterSecretKey", keys, (f) => f.Value.FriendlyName, (f) => secretKeyIdx = f.Key);
|
||||
|
||||
@@ -15,6 +15,7 @@ using MareSynchronos.MareConfiguration;
|
||||
using MareSynchronos.Mediator;
|
||||
using MareSynchronos.MareConfiguration.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MareSynchronos.Utils;
|
||||
|
||||
namespace MareSynchronos.UI;
|
||||
|
||||
@@ -26,6 +27,7 @@ public class SettingsUi : WindowMediatorSubscriberBase, IDisposable
|
||||
private readonly MareCharaFileManager _mareCharaFileManager;
|
||||
private readonly PairManager _pairManager;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly PerformanceCollector _performanceCollector;
|
||||
private readonly UiShared _uiShared;
|
||||
public CharacterData? LastCreatedCharacterData { private get; set; }
|
||||
|
||||
@@ -37,7 +39,8 @@ public class SettingsUi : WindowMediatorSubscriberBase, IDisposable
|
||||
public SettingsUi(ILogger<SettingsUi> logger, WindowSystem windowSystem,
|
||||
UiShared uiShared, MareConfigService configService,
|
||||
MareCharaFileManager mareCharaFileManager, PairManager pairManager,
|
||||
ServerConfigurationManager serverConfigurationManager, MareMediator mediator) : base(logger, mediator, "Mare Synchronos Settings")
|
||||
ServerConfigurationManager serverConfigurationManager,
|
||||
MareMediator mediator, PerformanceCollector performanceCollector) : base(logger, mediator, "Mare Synchronos Settings")
|
||||
{
|
||||
_logger.LogTrace("Creating " + nameof(SettingsUi));
|
||||
|
||||
@@ -52,6 +55,7 @@ public class SettingsUi : WindowMediatorSubscriberBase, IDisposable
|
||||
_mareCharaFileManager = mareCharaFileManager;
|
||||
_pairManager = pairManager;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
_performanceCollector = performanceCollector;
|
||||
_uiShared = uiShared;
|
||||
|
||||
Mediator.Subscribe<OpenSettingsUiMessage>(this, (_) => Toggle());
|
||||
@@ -545,7 +549,6 @@ public class SettingsUi : WindowMediatorSubscriberBase, IDisposable
|
||||
|
||||
private bool _deleteFilesPopupModalShown = false;
|
||||
private bool _deleteAccountPopupModalShown = false;
|
||||
|
||||
private void DrawDebug()
|
||||
{
|
||||
_lastTab = "Debug";
|
||||
@@ -565,11 +568,31 @@ public class SettingsUi : WindowMediatorSubscriberBase, IDisposable
|
||||
}
|
||||
UiShared.AttachToolTip("Use this when reporting mods being rejected from the server.");
|
||||
|
||||
_uiShared.DrawCombo<LogLevel>("Log Level", Enum.GetValues<LogLevel>(), (l) => l.ToString(), (l) =>
|
||||
_uiShared.DrawCombo("Log Level", Enum.GetValues<LogLevel>(), (l) => l.ToString(), (l) =>
|
||||
{
|
||||
_configService.Current.LogLevel = l;
|
||||
_configService.Save();
|
||||
}, _configService.Current.LogLevel);
|
||||
|
||||
bool logPerformance = _configService.Current.LogPerformance;
|
||||
if (ImGui.Checkbox("Log Performance Counters", ref logPerformance))
|
||||
{
|
||||
_configService.Current.LogPerformance = logPerformance;
|
||||
_configService.Save();
|
||||
}
|
||||
UiShared.DrawHelpText("Enabling this can incur a (slight) performance impact. Enabling this for extended periods of time is not recommended.");
|
||||
|
||||
if (!logPerformance) ImGui.BeginDisabled();
|
||||
if (UiShared.IconTextButton(FontAwesomeIcon.StickyNote, "Print Performance Stats to /xllog"))
|
||||
{
|
||||
_performanceCollector.PrintPerformanceStats();
|
||||
}
|
||||
ImGui.SameLine();
|
||||
if (UiShared.IconTextButton(FontAwesomeIcon.StickyNote, "Print Performance Stats (last 60s) to /xllog"))
|
||||
{
|
||||
_performanceCollector.PrintPerformanceStats(60);
|
||||
}
|
||||
if (!logPerformance) ImGui.EndDisabled();
|
||||
}
|
||||
|
||||
private void DrawBlockedTransfers()
|
||||
@@ -725,7 +748,7 @@ public class SettingsUi : WindowMediatorSubscriberBase, IDisposable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogCritical("Error saving data", ex);
|
||||
_logger.LogCritical(ex, "Error saving data");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -41,7 +41,7 @@ public partial class UiShared : MediatorSubscriberBase
|
||||
public string PlayerName => _dalamudUtil.PlayerName;
|
||||
public uint WorldId => _dalamudUtil.WorldId;
|
||||
public Dictionary<ushort, string> WorldData => _dalamudUtil.WorldData.Value;
|
||||
private Dictionary<string, object> _selectedComboItems = new(StringComparer.Ordinal);
|
||||
private readonly Dictionary<string, object> _selectedComboItems = new(StringComparer.Ordinal);
|
||||
public bool HasValidPenumbraModPath => !(_ipcManager.PenumbraModDirectory ?? string.Empty).IsNullOrEmpty() && Directory.Exists(_ipcManager.PenumbraModDirectory);
|
||||
public bool EditTrackerPosition { get; set; }
|
||||
public ImFontPtr UidFont { get; private set; }
|
||||
@@ -114,7 +114,8 @@ public partial class UiShared : MediatorSubscriberBase
|
||||
{
|
||||
selectedItem = initialSelectedItem;
|
||||
_selectedComboItems[comboName] = selectedItem!;
|
||||
onSelected?.Invoke(initialSelectedItem);
|
||||
if (!EqualityComparer<T>.Default.Equals(initialSelectedItem, default))
|
||||
onSelected?.Invoke(initialSelectedItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -155,13 +156,12 @@ public partial class UiShared : MediatorSubscriberBase
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning($"Font failed to load. {fontFile}");
|
||||
_logger.LogWarning(ex.ToString());
|
||||
_logger.LogWarning(ex, "Font failed to load. {fontFile}", fontFile);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogDebug($"Font doesn't exist. {fontFile}");
|
||||
_logger.LogDebug("Font doesn't exist. {fontFile}", fontFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,7 +522,7 @@ public partial class UiShared : MediatorSubscriberBase
|
||||
_isPenumbraDirectory = string.Equals(path.ToLowerInvariant(), _ipcManager.PenumbraModDirectory?.ToLowerInvariant(), StringComparison.Ordinal);
|
||||
_isDirectoryWritable = IsDirectoryWritable(path);
|
||||
_cacheDirectoryHasOtherFilesThanCache = Directory.GetFiles(path, "*", SearchOption.AllDirectories).Any(f => new FileInfo(f).Name.Length != 40);
|
||||
_cacheDirectoryIsValidPath = Regex.IsMatch(path, @"^(?:[a-zA-Z]:\\[\w\s\-\\]+?|\/(?:[\w\s\-\/])+?)$", RegexOptions.ECMAScript);
|
||||
_cacheDirectoryIsValidPath = PathRegex().IsMatch(path);
|
||||
|
||||
if (!string.IsNullOrEmpty(path)
|
||||
&& Directory.Exists(path)
|
||||
@@ -586,8 +586,8 @@ public partial class UiShared : MediatorSubscriberBase
|
||||
{
|
||||
if (throwIfFails)
|
||||
throw;
|
||||
else
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -663,7 +663,7 @@ public partial class UiShared : MediatorSubscriberBase
|
||||
var note = entry.GetNote();
|
||||
if (note.IsNullOrEmpty()) continue;
|
||||
|
||||
sb.AppendLine(entry.UserData.UID + ":\"" + entry.GetNote() + "\"");
|
||||
sb.Append(entry.UserData.UID).Append(":\"").Append(entry.GetNote()).AppendLine("\"");
|
||||
}
|
||||
sb.AppendLine(_notesEnd);
|
||||
|
||||
@@ -675,12 +675,12 @@ public partial class UiShared : MediatorSubscriberBase
|
||||
var splitNotes = notes.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries).ToList();
|
||||
var splitNotesStart = splitNotes.FirstOrDefault();
|
||||
var splitNotesEnd = splitNotes.LastOrDefault();
|
||||
if (!string.Equals(splitNotesStart, _notesStart) || !string.Equals(splitNotesEnd, _notesEnd))
|
||||
if (!string.Equals(splitNotesStart, _notesStart, StringComparison.Ordinal) || !string.Equals(splitNotesEnd, _notesEnd, StringComparison.Ordinal))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
splitNotes.RemoveAll(n => string.Equals(n, _notesStart) || string.Equals(n, _notesEnd));
|
||||
splitNotes.RemoveAll(n => string.Equals(n, _notesStart, StringComparison.Ordinal) || string.Equals(n, _notesEnd, StringComparison.Ordinal));
|
||||
|
||||
foreach (var note in splitNotes)
|
||||
{
|
||||
@@ -694,7 +694,7 @@ public partial class UiShared : MediatorSubscriberBase
|
||||
}
|
||||
catch
|
||||
{
|
||||
_logger.LogWarning("Could not parse " + note);
|
||||
_logger.LogWarning("Could not parse {note}", note);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -708,4 +708,7 @@ public partial class UiShared : MediatorSubscriberBase
|
||||
base.Dispose();
|
||||
_pluginInterface.UiBuilder.BuildFonts -= BuildFont;
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"^(?:[a-zA-Z]:\\[\w\s\-\\]+?|\/(?:[\w\s\-\/])+?)$", RegexOptions.ECMAScript)]
|
||||
private static partial Regex PathRegex();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user