Open MonzUn opened 2 years ago
We now have ClientLogEventTrigger.OnLogWritten
but it's only for the main log and it doesn't allow handling of the various log levels. I've done some ugly handling of this on my end but it would be preferable if we could track any log writing.
public void ConvertServerLogEvent(string logEventText)
{
string strippedEventText = MessageUtils.StripTags(logEventText);
Logger.LogLevel eventLevel = Logger.LogLevel.Silent;
string[] parts = strippedEventText.Split( ':', 2);
if (parts.Length == 0)
{
Logger.Warning($"Ignored non delimited log event: \"{strippedEventText}\"");
return;
}
if (parts[0].ContainsCaseInsensitive("Log"))
eventLevel = Logger.LogLevel.Information;
else if (parts[0].ContainsCaseInsensitive("Error"))
eventLevel = Logger.LogLevel.Error;
else if (parts[0].ContainsCaseInsensitive("Warning"))
eventLevel = Logger.LogLevel.Warning;
else if (parts[0].ContainsCaseInsensitive("Debug"))
eventLevel = Logger.LogLevel.Debug;
FireEvent(DLEventType.ServerLogWritten, eventLevel, parts[1].Trim());
}
Is your feature request related to a problem? Please describe. I want to propagate ingame logs to Discord, but the only existing way that I know of is to subscribe to ClientLogEventTrigger::OnLogWritten. This gives me only the main server log messages (no admin command log etc) and gives me formatting that I need to strip from the message.
Describe the solution you'd like If ILogWriter itself could have a callback so that any log could be fetched as long as we could fetch the ILogWriter object, that would be amazing ^^
Describe alternatives you've considered If the above is not possible, then a log callback that only sends the raw message (and maybe log category?) would also be helpful :)