Hiding certain console messages/log output?Solved
I want to hook messages like this
ip:port/steamid/Name Rejecting connection - Steam Auth Timeout

I'd like to hook this message but it doesn't show up with OnPlayerDisconnected, OnServerMessage, or OnPlayerKicked.
There are no hooks for those, they are sent through Unity methods and extensions to them. As of right now, there's no way to hide those that I am aware of via a plugin.
5df88518bef43.png Wulf
There are no hooks for those, they are sent through Unity methods and extensions to them. As of right now, there's no way to hide those that I am aware of via a plugin.
I am interested in hooking the messages, not hiding them. Would that be easier to do?
Being as there is no hook for those, you wouldn't be able to unless you added those yourself to the areas where they are located.
Can you teach me how to do that or point to an example?
Open Assembly-CSharp.dll in a .NET decompiler and search for "Application", should be a few hits. I don't think that is what you are looking for though.
Figured it out, was quite easy. I didn't expect the application object to be static, I thought there was an instance of it somewhere.
        void Loaded()
        {
            UnityEngine.Application.logMessageReceived += Application_logMessageReceived;
        }

        void Unload()
        {
            UnityEngine.Application.logMessageReceived -= Application_logMessageReceived;
        }

        private void Application_logMessageReceived(string condition, string stackTrace, UnityEngine.LogType type)
        {
        }​
And you got that working? Surprised if so, as the plugin I made for that I could not get to work. We used to have a filter in Oxide for its console, but haven't for awhile since we disabled the custom console.
That adds a log handler, it doesn't override Facepunch's log handler.

If you want to block them you need to remove Facepunch's log handler by doing UnityEngine.Application.logMessageReceived -= Facepunch.Output.LogHandler 

and then inserting your own.

// Facepunch.Output
using UnityEngine;

public static void Install()
{
    if (!installed)
    {
        UnityEngine.Application.logMessageReceived += LogHandler;
        installed = true;
    }
}

// Facepunch.Output
using Facepunch.Math;
using UnityEngine;

internal static void LogHandler(string log, string stacktrace, LogType type)
{
    if (Output.OnMessage != null && !log.StartsWith("Kinematic body only supports Speculative Continuous collision detection") && !log.StartsWith("Skipped frame because GfxDevice") && !log.StartsWith("Your current multi-scene setup has inconsistent Lighting") && !log.Contains("HandleD3DDeviceLost") && !log.Contains("ResetD3DDevice") && !log.Contains("dev->Reset") && !log.Contains("D3Dwindow device not lost anymore") && !log.Contains("D3D device reset") && !log.Contains("group < 0xfff") && !log.Contains("Mesh can not have more than 65000 vert") && !log.Contains("Trying to add (Layout Rebuilder for)") && !log.Contains("Coroutine continue failure") && !log.Contains("No texture data available to upload") && !log.Contains("Trying to reload asset from disk that is not") && !log.Contains("Unable to find shaders used for the terrain engine.") && !log.Contains("Canvas element contains more than 65535 vertices") && !log.Contains("RectTransform.set_anchorMin") && !log.Contains("FMOD failed to initialize the output device") && !log.Contains("Cannot create FMOD::Sound") && !log.Contains("invalid utf-16 sequence") && !log.Contains("missing surrogate tail") && !log.Contains("Failed to create agent because it is not close enough to the Nav") && !log.Contains("user-provided triangle mesh descriptor is invalid") && !log.Contains("Releasing render texture that is set as"))
    {
        Output.OnMessage(log, stacktrace, type);
        HistoryOutput.Add(new Entry
        {
            Message = log,
            Stacktrace = stacktrace,
            Type = type.ToString(),
            Time = Epoch.Current
        });
        while (HistoryOutput.Count > 65536)
        {
            HistoryOutput.RemoveAt(0);
        }
    }
}​
What is broken about the code button? It's been working fine for over a year.
It eats all the spaces.



That's a matter for the line endings used in the code. What did you edit and copy the code from?
I copy and pasted it from Visual Studio 2019.
Windows or Linux line endings?

        private void HandleLog(string message, string stackTrace, LogType logType)
        {
            if (!string.IsNullOrEmpty(message) && Filter.Any(message.Contains))
            {
                LogWarning("Filtered");
            }
        }​
Pasted fine above.
Locked automatically