Skip to content

Commit

Permalink
convert filters to lambdas, does not work yet .. very very slow and g…
Browse files Browse the repository at this point in the history
…rows slower with time. Feels like a memory leak.
  • Loading branch information
CptMoore committed Jan 21, 2025
1 parent fe03011 commit ea29623
Show file tree
Hide file tree
Showing 8 changed files with 666 additions and 131 deletions.
7 changes: 4 additions & 3 deletions ModTek/Features/Logging/AppenderFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ModTek.Features.Logging;

internal class AppenderFile : IDisposable
{
private readonly Filters _filters;
private readonly Filters.FilterDelegate _filters;
private readonly Formatter _formatter;
private readonly LogStream _writer;

Expand All @@ -18,7 +18,7 @@ internal class AppenderFile : IDisposable

internal AppenderFile(string path, AppenderSettings settings)
{
_filters = new Filters(settings);
_filters = Filters.Compile(settings);
_formatter = new Formatter(settings);

FileUtils.CreateParentOfPath(path);
Expand Down Expand Up @@ -63,7 +63,8 @@ internal void Append(ref MTLoggerMessageDto messageDto)

{
var measurement = MTStopwatch.GetTimestamp();
var included = _filters.IsIncluded(ref messageDto);
//var included = _filters(ref messageDto);
var included = Filters.HardcodedFilter(ref messageDto);
FiltersStopWatch.EndMeasurement(measurement);
if (!included)
{
Expand Down
63 changes: 61 additions & 2 deletions ModTek/Features/Logging/AppenderSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,67 @@ internal class AppenderSettings

[JsonProperty]
internal readonly string PrefixesToIgnore_Description = $"Ignore any lines starting with any of the listed prefixes, internally will be converted to {nameof(Excludes)}.";
[JsonProperty]
internal string[] PrefixesToIgnore;

[JsonProperty] internal string[] PrefixesToIgnore =
[
"Unity [ERROR] Desired shader compiler platform",
"Unity [LOG] Look rotation viewing vector is zero",
"Unity [ERROR] Material doesn't have a color property",
"Unity [WARNING] Parent of RectTransform is being set with parent property",
"Unity [WARNING] The referenced script",
"Unity [WARNING] Rejecting unit",
"Unity [WARNING] Parent of RectTransform is being set with parent property",
"Unity [WARNING] No DefaultCombatLeaderCastDefId specified for faction [Player1sMercUnit]",
"Unity [WARNING] No DefaultCombatLeaderCastDefId specified for faction [Player2sMercUnit]",
"Unity [ERROR] Bones do not match bindpose.",
"Unity [ERROR] ================== ERROR! Found missing transforms",
"Unity [WARNING] ERROR! Couldn't auto-setup",
"Unity [WARNING] Could not retrieve member",
"MapExport [ERROR] Out of bounds",
"CombatLog.Hit [LOG] ???????? DIRECTION:",
"Unity [WARNING] BoxColliders does not support negative scale or size",
"AudioEvents [DEBUG] Audio Engine",
"MechEngineer [LOG] Auto fixing chassisDef",
"AudioEvents [DEBUG] OnApplicationFocus",
"NetworkRandomValues [DEBUG] Seed",
"NetworkRandomCallstacks [DEBUG] Seed",
"UserSettings [DEBUG] Using existing cloud settings from save manager",
"BattleTech.Services [DEBUG] [BattleTechParadoxAPI]",
"Network.Client [LOG] Connection",
"GameInfo [LOG] DEVELOPMENT FLAG NOT SET",
"MechEngineer [LOG] settings loaded",
"GameInfo [LOG] ProductName: BATTLETECH",
"GameInfo [LOG] RELEASE FLAG SET",
"DebugBridge",
"CustomComponents [LOG] [CC]SimpleCustom",
"LoginManager [LOG] Successfully authenticated with OPS. Moving onto ComStar connection proper.",
"Data.AssetBundleManager [LOG] Trying to load AssetBundle:",
"UserSettings [LOG] [LOG] User settings saved",
"MechLab [WARNING] GetWeaponPrefabName failed to find a prefab name for unit",
"Analytics [WARNING] Analytics Event requested with invalid IP",
"Analytics [WARNING] Request next called but no servers have been found",
"Analytics [WARNING] Request next called but reporting is disabled",
"UI [WARNING] Singleton UIManagerFader",
"CombatLog.Initialization [WARNING] Turret",
"MechEngineer [WARNING] Unsupported weapon category for 667",
"MechEngineer [WARNING] Unsupported weapon category for 666",
"CustomComponents [DEBUG] [CC]Mech validation for NULL return",
"CustomComponents [DEBUG] [CC]-- CustomComponents.Flags",
"CustomComponents [DEBUG] [CC]-- CustomComponents.AutoLinked",
"CustomComponents.UnitType [DEBUG]",
"Data.DataManager [WARNING] LoadRequest for",
"LewdableTanks [DEBUG] Fixing cost of",
"CombatLog.Initialization [ERROR] Error instantiating VFX",
"PilotDef [WARNING] PilotDef already did Init From Save!",
"Achievements [LOG]",
"DataLoader [DEBUG] Loading:",
"Save.Core.SaveSystem [DEBUG]",
"Unity [ERROR] Generating SIM GAME UID while still loading!",
"Unity [WARNING] HBS Tooltip on UI Element",
"HarmonyX [TRACE]",
"HarmonyX [LOG]",
"Unity [ERROR] RenderTexture.Create failed: format unsupported for random writes"
];

[JsonProperty]
internal const string AbsoluteTimeEnabled_Description = "Adds the clock time.";
Expand Down
6 changes: 3 additions & 3 deletions ModTek/Features/Logging/AppenderUnityConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ internal class AppenderUnityConsole
{
// appender part

private readonly Filters _filters;
private readonly Filters.FilterDelegate _filters;
private readonly Formatter _formatter;
private readonly ILogger _debugUnityLogger;
private readonly FastBuffer _buffer = new();

internal AppenderUnityConsole(AppenderSettings settings)
{
_filters = new Filters(settings);
_filters = Filters.Compile(settings);
_formatter = new Formatter(settings);
_debugUnityLogger = Debug.unityLogger;
}
Expand All @@ -35,7 +35,7 @@ internal void Append(ref MTLoggerMessageDto messageDto)
return;
}

if (!_filters.IsIncluded(ref messageDto))
if (!_filters(ref messageDto))
{
return;
}
Expand Down
86 changes: 0 additions & 86 deletions ModTek/Features/Logging/Filter.cs

This file was deleted.

Loading

0 comments on commit ea29623

Please sign in to comment.