mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* feat: more stream selection with next troubleshooting * feat: improve next logging * feat: log next troubleshooting speedpull/2975/head
9 changed files with 108 additions and 35 deletions
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
using System.Text.RegularExpressions; |
||||
using Microsoft.Extensions.Logging; |
||||
|
||||
namespace ErsatzTV.Application.Streaming; |
||||
|
||||
public partial class NextLogger |
||||
{ |
||||
[GeneratedRegex( |
||||
@"^\[\S+ (?<level>TRACE|DEBUG|INFO|WARN|ERROR) (?<target>[^\]]+)\] (?<msg>.*)$", |
||||
RegexOptions.Singleline)] |
||||
private static partial Regex NextLogLine(); |
||||
|
||||
public static void LogNextLine(string line, ILogger logger) |
||||
{ |
||||
Match match = NextLogLine().Match(line); |
||||
if (!match.Success) |
||||
{ |
||||
logger.LogDebug("{Line:l}", line); |
||||
return; |
||||
} |
||||
|
||||
LogLevel level = match.Groups["level"].Value switch |
||||
{ |
||||
"ERROR" => LogLevel.Error, |
||||
"WARN" => LogLevel.Warning, |
||||
"INFO" => LogLevel.Information, |
||||
"TRACE" => LogLevel.Trace, |
||||
_ => LogLevel.Debug |
||||
}; |
||||
|
||||
logger.Log(level, "[{Target:l}] {Line:l}", match.Groups["target"].Value, match.Groups["msg"].Value); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue