fix: Adds packet logging (#836)
### Enabling Packet Logging `[packetlogging on` and target the user. Supports command modifiers such as: `[online packetlogging on where accesslevel = player` Logs are saved in `path/<ip address>/packets.log`. It is a simple append-format log with no date splitting.
This commit is contained in:
parent
85d699fcd7
commit
2890f5c3ec
6 changed files with 186 additions and 193 deletions
|
|
@ -32,6 +32,10 @@ namespace Server.Network
|
|||
public int Position { get; private set; }
|
||||
public int Remaining => Length - Position;
|
||||
|
||||
// Only used for debugging!
|
||||
public ReadOnlySpan<byte> First => _first;
|
||||
public ReadOnlySpan<byte> Second => _second;
|
||||
|
||||
public CircularBufferReader(ref CircularBuffer<byte> buffer) : this(buffer.GetSpan(0), buffer.GetSpan(1))
|
||||
{
|
||||
}
|
||||
|
|
@ -58,12 +62,9 @@ namespace Server.Network
|
|||
|
||||
try
|
||||
{
|
||||
using var sw = new StreamWriter("Packets.log", true);
|
||||
|
||||
using var sw = new StreamWriter("unhandled-packets.log", true);
|
||||
sw.WriteLine("Client: {0}: Unhandled packet 0x{1:X2}", state, _first[0]);
|
||||
|
||||
Utility.FormatBuffer(sw, _first.ToArray(), new Memory<byte>(_second.ToArray()));
|
||||
|
||||
sw.FormatBuffer(_first, _second, Length);
|
||||
sw.WriteLine();
|
||||
sw.WriteLine();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue