mattymatty97 / LTC_AsyncLoggers

YEET logs in their own Thread!
GNU Lesser General Public License v2.1
3 stars 0 forks source link

[Compatabilty] add support for BepInEx GUI #3

Open CatsArmy opened 8 months ago

CatsArmy commented 8 months ago

BepInEx GUI is just another console i ported it to work outside of risk of rain 2 but it doesnt seem that it supports this mod for some reason i susspect something about the threads but im not sure

original mod isnt by me btw

mattymatty97 commented 8 months ago

from what i saw in the code there is not reason for BepInEx GUI to not work...

maybe try one of the preview releases

CatsArmy commented 8 months ago

I did I'm trying to build your mod on my PC but I'm having alot of issues with the csproj file I'm trying to make it so when you schedule a delegate thingy that before after it logs the sender and the other param it uses the same system I am using for sockets and stuff and it also passes that info there

CatsArmy commented 8 months ago

BepInExLoggerPatcher wrapLogs(object sender, LogEventArgs eventArgs) this is the function

If you wanna give it a shot yourself the socket Networking stuff should be in my git repo for Bepinex GUI in the BepInEx.GUI.Loader folder under the SendLogToClientSocket.cs

CatsArmy commented 8 months ago

I really don't think it would need to have a while true like the GUI is doing as you are doing it whenever something gets logged so if you make a static read-only int openport

And a static read-only IPaddress IP to create the socket it should work I tried to do it my self but your csproj file is really messy and confusing it feels as if it has a mind of it's own it just doesn't do what it needs to do

mattymatty97 commented 8 months ago

i mean it just adds itself to the list of listeners image so there is no reason for the GUI not working

CatsArmy commented 8 months ago

Well yeah ik but you can download it via thunderstore and see for yourself I got no idea why it doesn't work to be honest

mattymatty97 commented 8 months ago

i haven't been able to have BepInEx GUI work at all on Lethal Company sincerally 😅

CatsArmy commented 8 months ago

Really huh any errors?

mattymatty97 commented 8 months ago

nothing... simply wont start

CatsArmy commented 8 months ago

Like the game won't start?

CatsArmy commented 8 months ago

Like the game won't start?

If so that's weird

mattymatty97 commented 8 months ago

image found the issue seems GUI is targeting a wrong version of BepInEx

mattymatty97 commented 8 months ago

image

mattymatty97 commented 8 months ago

this seems to be working fine with Async?

CatsArmy commented 8 months ago

image

Nope trying logging something when you do something like jump it won't show up in the GUI but it will in the log file

CatsArmy commented 8 months ago

I believe that the logs you can see are before it all gets patched by async logger

CatsArmy commented 8 months ago

Did putting the exe In patchers\CatsArmy-BepInEx_GUI fix the GUI not opening?

mattymatty97 commented 8 months ago

mmk than this is the issue: [14:00:56.9946058] [Error :BepInEx.GUI.Loader] Error while trying to send log to socket: System.Net.Sockets.SocketException (0x80004005): An established connection was aborted by the software in your host machine.

CatsArmy commented 8 months ago

Yep that explains it that's why I think you should also have the same methods I used to get the port and IP to then send the socket by your self

mattymatty97 commented 8 months ago

but that's something i have no control over... you run the socket thing in a separate thread and enqueue things in a Queue i'm not touching anything related to networking 🤔 and no i'm not adding the socket stuff here... we/i need to figure out why me creating other threads is killing your socket

CatsArmy commented 8 months ago

but that's something i have no control over... you run the socket thing in a separate thread and enqueue things in a Queue i'm not touching anything related to networking 🤔 and no i'm not adding the socket stuff here... we/i need to figure out why me creating other threads is killing your socket

eh fair enough i guess my suggestionis just a temp fix and not fixing the root cause hmm maybe it needs to be like a copy ctor for the thread i got no idea man i dont do async/threading too

mattymatty97 commented 8 months ago

seems to be caused by this somehow https://github.com/mattymatty97/LTC_AsyncLoggers/blob/experimental/AsyncLoggers/src/Patches/BepInExLogEventArgsPatch.cs

CatsArmy commented 8 months ago

really huh

mattymatty97 commented 8 months ago

if you disable the Timestamps in the config it works fine

CatsArmy commented 8 months ago

really huh ill test that

CatsArmy commented 8 months ago

huh it does work why does it do that that makes no logical sence what so ever what

mattymatty97 commented 8 months ago

i belive it's an issue with the https://github.com/CatsArmy/BepInEx.GUI/blob/main/BepInEx.GUI.Loader/src/LogPacket.cs doing some weird stuff to convert the LogEventArgs that i modify

CatsArmy commented 8 months ago

i belive it's an issue with the CatsArmy/BepInEx.GUI@main/BepInEx.GUI.Loader/src/LogPacket.cs doing some weird stuff to convert the LogEventArgs that i modify

well shit not i have to figure out the werid ass class no one understands shi

welp ill try and see whats going on

mattymatty97 commented 8 months ago

i'm sorry 😂 at least we know where the issue is

CatsArmy commented 8 months ago

i'm sorry 😂 at least we know where the issue is

yeah lol

mattymatty97 commented 8 months ago

i was thinking this might also be an error on the receiving side of the GUI, as they have to do some parsing and i alter the format they might be trying to match

CatsArmy commented 8 months ago

No I don't think the GUI side of things is the issues here. I think I'm somehow getting the return value before you patch perhaps and then it has an incorrect size for the string which breaks the packet tho I'm not sure

mattymatty97 commented 7 months ago

have you figured out what's happening?

CatsArmy commented 7 months ago

have you figured out what's happening?

Not sure yet haven't had the time to test and code a fix yet feel free to try and create a PR if you want to. I'm just busy next week I will have a bit more free time

CatsArmy commented 7 months ago

have you figured out what's happening?

Tho I don't think the issue is with the networking part of it still

xiaoxiao921 commented 7 months ago

i belive it's an issue with the https://github.com/CatsArmy/BepInEx.GUI/blob/main/BepInEx.GUI.Loader/src/LogPacket.cs doing some weird stuff to convert the LogEventArgs that i modify

If you modify the packet structure then you obviously have to fix the serializer + deserializer, can you link the modified packet structure when using timestamps?

mattymatty97 commented 7 months ago

i'm not touching the packet as i do nlt reference anything about BepInEx GUI

but i do edit the output of LogEventArgs.ToString()

https://github.com/mattymatty97/LTC_AsyncLoggers/blob/preloader/AsyncLoggers%2Fsrc%2FPatches%2FBepInExLogEventArgsPatch.cs

CatsArmy commented 7 months ago

Here are some new error logs that might help:

BepInEx.GUI.Loader.SendLogToClientSocket.SendPacketsToClientUntilConnectionIsClosed (System.Net.Sockets.Socket socket) (at ./SendLogToClientSocket.cs:96)
BepInEx.GUI.Loader.SendLogToClientSocket.<.ctor>b__10_0 () (at ./SendLogToClientSocket.cs:55)
System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <787acc3c9a4c471ba7d971300105af24>:0)
System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <787acc3c9a4c471ba7d971300105af24>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <787acc3c9a4c471ba7d971300105af24>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <787acc3c9a4c471ba7d971300105af24>:0)
System.Threading.ThreadHelper.ThreadStart () (at <787acc3c9a4c471ba7d971300105af24>:0)

UnityEngine.Logger:LogException(Exception, Object) AsyncLoggers.Wrappers.Unity.<>cDisplayClass4_0:b__0() (at ./src/Wrappers/Unity/AsyncLoggerWrapper.cs:36) AsyncLoggers.Wrappers.Unity.<>cDisplayClass28_0:b__0() (at ./src/Wrappers/Unity/AsyncLoggerWrapper.cs:136) AsyncLoggers.Wrappers.JobWrapper:LogWorker() (at ./src/Wrappers/JobWrapper.cs:84) AsyncLoggers.Wrappers.LogJob:Execute() (at ./src/Wrappers/JobWrapper.cs:68) Unity.Jobs.JobStruct`1:Execute(LogJob&, IntPtr, IntPtr, JobRanges&, Int32)

Edit so it also seems to happen in content warning and the same lines are showing up:

[13:30:56.3281373] [Error  : Unity Log] ArgumentException: An item with the same key has already been added. Key: AnalogTVNoise
Stack trace:
bool System.Collections.Generic.Dictionary<Type, UnityEngine.Rendering.VolumeComponent>.TryInsert(Type key, VolumeComponent value, InsertionBehavior behavior)
void System.Collections.Generic.Dictionary<Type, UnityEngine.Rendering.VolumeComponent>.Add(Type key, VolumeComponent value)
void UnityEngine.Rendering.VolumeStack.Reload(List<VolumeComponent> componentDefaultStates)
VolumeStack UnityEngine.Rendering.VolumeManager.CreateStack()
new UnityEngine.Rendering.VolumeManager()
static UnityEngine.Rendering.VolumeManager()+<.cctor>b__46_0() => { }
void System.Lazy<UnityEngine.Rendering.VolumeManager>.ViaFactory(LazyThreadSafetyMode mode)
void LazyHelper.ThrowException()
VolumeManager System.Lazy<UnityEngine.Rendering.VolumeManager>.CreateValue()
VolumeManager System.Lazy<UnityEngine.Rendering.VolumeManager>.get_Value()
VolumeManager UnityEngine.Rendering.VolumeManager.get_instance()
List<ValueTuple<string, Type>> UnityEngine.Rendering.VolumeManager.GetSupportedVolumeComponents(Type currentPipelineType)
List<ValueTuple<string, Type>> UnityEngine.Rendering.VolumeDebugSettings<UnityEngine.Rendering.Universal.UniversalAdditionalCameraData>.get_volumeComponentsPathAndType()
EnumField UnityEngine.Rendering.DebugDisplaySettingsVolume+WidgetFactory.CreateComponentSelector(SettingsPanel panel, Action<Field<int>, int> refresh)
new UnityEngine.Rendering.DebugDisplaySettingsVolume+SettingsPanel(DebugDisplaySettingsVolume data)
IDebugDisplaySettingsPanelDisposable UnityEngine.Rendering.DebugDisplaySettingsVolume.CreatePanel()
void UnityEngine.Rendering.DebugDisplaySettingsUI.RegisterDebug(IDebugDisplaySettings settings)+<RegisterDebug>b__0(IDebugDisplaySettingsData data) => { }
void UnityEngine.Rendering.DebugDisplaySettings<UnityEngine.Rendering.Universal.UniversalRenderPipelineDebugDisplaySettings>.ForEach(Action<IDebugDisplaySettingsData> onExecute)
void UnityEngine.Rendering.DebugDisplaySettingsUI.RegisterDebug(IDebugDisplaySettings settings)
new UnityEngine.Rendering.Universal.UniversalRenderPipeline(UniversalRenderPipelineAsset asset)
RenderPipeline UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset.CreatePipeline()
RenderPipeline UnityEngine.Rendering.RenderPipelineAsset.InternalCreatePipeline()
UnityEngine.Logger:LogException(Exception, Object)

When Config is: Unity: {enabled, wrapper(Logger), scheduler(Job) }

AsyncLoggers.Wrappers.Unity.<>cDisplayClass4_0:b__0() (at ./src/Wrappers/Unity/AsyncLoggerWrapper.cs:36) AsyncLoggers.Wrappers.Unity.<>cDisplayClass28_0:b__0() (at ./src/Wrappers/Unity/AsyncLoggerWrapper.cs:136) AsyncLoggers.Wrappers.JobWrapper:LogWorker() (at ./src/Wrappers/JobWrapper.cs:84) AsyncLoggers.Wrappers.LogJob:Execute() (at ./src/Wrappers/JobWrapper.cs:68) Unity.Jobs.JobStruct`1:Execute(LogJob&, IntPtr, IntPtr, JobRanges&, Int32)

When Config is: Unity: {enabled, wrapper(Logger), scheduler(Thread) }

AsyncLoggers.Wrappers.Unity.<>cDisplayClass4_0:b__0() (at ./src/Wrappers/Unity/AsyncLoggerWrapper.cs:36) AsyncLoggers.Wrappers.Unity.<>cDisplayClass28_0:b__0() (at ./src/Wrappers/Unity/AsyncLoggerWrapper.cs:136) AsyncLoggers.Wrappers.ThreadWrapper:LogWorker() (at ./src/Wrappers/ThreadWrapper.cs:45) System.Threading.ThreadHelper:ThreadStart()

mattymatty97 commented 3 months ago

V2 ( now in Experimental release ) should now be compatible with the BepInEx GUI, do you mind testing?

CatsArmy commented 3 months ago

Wait what? I spent so long trying to fix that with another bug too that I eventually gave up from the lack of free time I had at the time sure I'll test it

mattymatty97 commented 3 months ago

i recoded the entire program ( yes i did a full rewrite ) to use different logic, especially for the TimeStamps so now only the Listeners that request it will have the TimeStamps prepended.