WorkloadLoggingFilter
Namespace: Hex1b
Assembly: Hex1b.dll
A workload filter that logs all data flowing through the workload pipeline to a file.
public sealed class WorkloadLoggingFilter : IHex1bTerminalWorkloadFilter, IAsyncDisposable, IDisposableInheritance
Object → WorkloadLoggingFilter
Implements
Constructors
WorkloadLoggingFilter(string, bool)
Creates a new workload logging filter.
Parameters:
filePath(String): Path to the log file.includeHexDump(Boolean): Whether to include hex dumps of raw data.
public WorkloadLoggingFilter(string filePath, bool includeHexDump = true)Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
Returns: ValueTask
A task that represents the asynchronous dispose operation.
public ValueTask DisposeAsync()OnFrameCompleteAsync(TimeSpan, CancellationToken)
Called when the workload output channel is drained (no more data immediately available).
Parameters:
elapsed(TimeSpan): Time elapsed since session start.ct(CancellationToken): Cancellation token.
Returns: ValueTask
public ValueTask OnFrameCompleteAsync(TimeSpan elapsed, CancellationToken ct = default)OnInputAsync(IReadOnlyList<AnsiToken>, TimeSpan, CancellationToken)
Called when input is being sent to the workload.
Parameters:
tokens(IReadOnlyList<AnsiToken>): The parsed ANSI tokens from the input.elapsed(TimeSpan): Time elapsed since session start.ct(CancellationToken): Cancellation token.
Returns: ValueTask
public ValueTask OnInputAsync(IReadOnlyList<AnsiToken> tokens, TimeSpan elapsed, CancellationToken ct = default)OnOutputAsync(IReadOnlyList<AnsiToken>, TimeSpan, CancellationToken)
Called when output data is read from the workload.
Parameters:
tokens(IReadOnlyList<AnsiToken>): The parsed ANSI tokens from the workload output.elapsed(TimeSpan): Time elapsed since session start.ct(CancellationToken): Cancellation token.
Returns: ValueTask
public ValueTask OnOutputAsync(IReadOnlyList<AnsiToken> tokens, TimeSpan elapsed, CancellationToken ct = default)OnResizeAsync(int, int, TimeSpan, CancellationToken)
Called when the terminal is resized.
Parameters:
width(Int32): New width in columns.height(Int32): New height in rows.elapsed(TimeSpan): Time elapsed since session start.ct(CancellationToken): Cancellation token.
Returns: ValueTask
public ValueTask OnResizeAsync(int width, int height, TimeSpan elapsed, CancellationToken ct = default)OnSessionEndAsync(TimeSpan, CancellationToken)
Called when the terminal session ends.
Parameters:
elapsed(TimeSpan): Total duration of the session.ct(CancellationToken): Cancellation token.
Returns: ValueTask
public ValueTask OnSessionEndAsync(TimeSpan elapsed, CancellationToken ct = default)OnSessionStartAsync(int, int, DateTimeOffset, CancellationToken)
Called when the terminal session starts.
Parameters:
width(Int32): Initial terminal width.height(Int32): Initial terminal height.timestamp(DateTimeOffset): When the session started.ct(CancellationToken): Cancellation token.
Returns: ValueTask
public ValueTask OnSessionStartAsync(int width, int height, DateTimeOffset timestamp, CancellationToken ct = default)Remarks
This filter is useful for debugging terminal issues by capturing: Output FROM the workload with timestampsInput TO the workload with timestampsResize eventsFrame completion signals
The log format includes elapsed time since session start and a hex dump of the raw bytes for detailed analysis.
Examples
var terminal = Hex1bTerminal.CreateBuilder()
.WithWorkloadLogging("/tmp/terminal.log")
.WithProcess("bash")
.Build();