Open AgrYpn1a opened 2 years ago
Hello @rtojagic, thanks for using EmbedIO!
Your logger is not working because its LogLevel
property is greater than any log level. Don't get fooled by the LogLevel
enum having a [Flags]
attribute, it's a long-standing bug in Swan.Lite
.
On a side note, if you don't need to dispose your logger just make Dispose
an empty method. Trowing an exception could (and probably will) disrupt Logger
's shutdown procedure.
public class ServerLogger : Swan.Logging.ILogger
{
public Swan.Logging.LogLevel LogLevel => Swan.Logging.LogLevel.Trace;
public void Dispose()
{
}
public void Log(Swan.Logging.LogMessageReceivedEventArgs logEvent)
{
Debug.Log("<color=yellow>Called logger</color>");
ImGuiLogger.Instance.Log("Calling log from custom logger.");
ImGuiLogger.Instance.Log(logEvent.Message);
}
}
Regarding the SSL connection error, if your program runs under Windows you probably need to register your certificate with the OS security subsystem. EmbedIO can do it for you:
string url = "https://127.0.0.1:6060/";
string certPath = $"File://{Application.streamingAssetsPath}/cert.pfx";
var cert = new X509Certificate2(new X509Certificate(certPath));
_server = new WebServer(o =>
o.WithUrlPrefix(url)
.WithMode(HttpListenerMode.EmbedIO)
.WithCertificate(cert)
.WithAutoRegisterCertificate() // <-- Add this
).WithLocalSessionManager()
.WithWebApi("/THLinkAPI", (m) => m.WithController<THLinkApiController>());
Swan.Logging.Logger.RegisterLogger<ServerLogger>();
@rdeago Hey thanks a lot for the fast reply! :) I've set the log level to Trace and I can see logs now which is awesome.
Btw, now when I add the WithAutoRegisterCertificate
I am getting a nullptr exception, do you know why that could happen?
And, btw, certificate is already installed:
If I omit the WithAutoRegisterCertificate
, and test from Insomnia I would get the SSL Connect error
, with timeline details as follows. I do not see any logs, so I believe it's not even reaching that part of the server app.
I tried implementing a custom logger:
and then I tried to register it
But I am not able to see any outputs.
Log
method is never called. Am I missing something?Using this from Unity 2020 on .NET 2.0 standard.
BTW, it's on running on Unitys Mono, and I am having SSL connection error which I am trying to debug, is why I need custom logger, cause I can't see any logs from Unity. If possibly I did something wrong here with setting up SSL you can help me correct that, then I wouldn't care about logs further unless I have another issue at some point.