Class ConsoleLineClassifier
- Namespace
- McServerLauncher.Services
- Assembly
- McServerLauncher.dll
What a console line is about: its severity, and whether it is chat, a player event, or the app.
public static class ConsoleLineClassifier
- Inheritance
-
ConsoleLineClassifier
- Inherited Members
Remarks
The order matters, and it runs from what is certain to what is inferred. The source is certain — the app knows when it is the one talking, and the operating system knows what came out of standard error. Only the server's standard output has to be read, and only then is a mistake possible.
This is why the app's own messages are tagged where they are raised instead of being recognised
here: their text is localized, prefixes and all — [Launcher], [Error] and
[Players] live inside the resx values and are translated with them. A classifier keyed on
those markers would work in Spanish and quietly stop working in German.
Methods
Classify(string, ConsoleSource, ConsoleLineKind?, IReadOnlySet<string>?)
What a line is about, given where it came from and what came before it.
public static ConsoleLineKind Classify(string text, ConsoleSource source, ConsoleLineKind? previous = null, IReadOnlySet<string>? online = null)
Parameters
textstringThe line, as the server wrote it.
sourceConsoleSourceWhich stream it arrived on.
previousConsoleLineKind?What the last line on standard output was. A line with no log prefix of its own is the next line of that entry — a list, a multi-line warning, an exception message — and it belongs to the same entry rather than being judged on its own.
onlineIReadOnlySet<string>Who is connected right now, when the caller knows. Only needed to tell a player's
/say([Alice] …) from a plugin logging under its own name ([LuckPerms] …); without it those stay ordinary output. See ChatOf(string, IReadOnlySet<string>).
Returns
NameBefore(string, string)
Extracts the player name right before a marker, from a real log entry only.
public static string? NameBefore(string line, string marker)
Parameters
Returns
Remarks
The name must be the only text between the log prefix and the marker, and a valid
Minecraft name. That is what stops <Bob> Alice joined the game — Bob typing the
sentence in chat — from counting as Alice joining.
"Between the log prefix and the marker" is measured from the first ]: , which
is where the server's own prefix ends. It used to be the last ": " before the marker,
which a player controls: <Bob> x: Bob left the game took Bob off the player list,
and with nobody left on it the idle timer stopped a server people were playing on.
Lives here rather than in the view model that used to own it, because two things now need it and both were carrying their own copy of the same regex: the player list, and this. Fixing a misread name in one of them and not the other is exactly the kind of drift that is invisible until somebody's name stops working.