Table of Contents

Class LogWait

Namespace
Valheim.Testing.Game
Assembly
Valheim.Testing.Game.dll
public sealed class LogWait
Inheritance
object
LogWait

Constructors

LogWait(string, long?)

public LogWait(string path, long? offset = null)

Parameters

path string
offset long?

Byte offset to read from. By default the file's current end, or its start if it does not exist yet.

Fields

DefaultSafetyInterval

public static readonly TimeSpan DefaultSafetyInterval

Field Value

TimeSpan

Properties

LastLine

The most recent complete line read from the file, matched or not.

public string? LastLine { get; }

Property Value

string

LogPath

public string LogPath { get; }

Property Value

string

Offset

public long Offset { get; }

Property Value

long

SafetyInterval

Re-read interval when no watcher event arrives. System.Threading.Timeout.InfiniteTimeSpan relies on events alone.

public TimeSpan SafetyInterval { get; init; }

Property Value

TimeSpan

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

HasOutput()

Reads what was appended (as Refresh() does) and returns whether anything was written to the file after this wait opened it; a replaced file counts. False means this log's writer wrote nothing, for example a game that exited before BepInEx started.

public bool HasOutput()

Returns

bool

Literal(string)

public static Regex Literal(string text)

Parameters

text string

Returns

Regex

Refresh()

Reads what was appended since the last read without matching it (it stays queued for the next wait) and returns the last line seen, including a line still being written. For reports, for example after the writer exited.

public string? Refresh()

Returns

string

WaitAsync(string, TimeSpan, IReadOnlyList<string>?, CancellationToken)

Waits for a line containing text (ordinal); a line containing any failure text ends it at once.

public Task<LogLine> WaitAsync(string text, TimeSpan timeout, IReadOnlyList<string>? failures = null, CancellationToken cancellation = default)

Parameters

text string
timeout TimeSpan
failures IReadOnlyList<string>
cancellation CancellationToken

Returns

Task<LogLine>

WaitAsync(Regex, TimeSpan, IReadOnlyList<Regex>?, CancellationToken)

Waits for a complete line matching success. A line matching any of failures (checked first) ends the wait at once with WaitFailedException, which carries that line and the lines just before it; expiry throws WaitTimeoutException.

public Task<LogLine> WaitAsync(Regex success, TimeSpan timeout, IReadOnlyList<Regex>? failures = null, CancellationToken cancellation = default)

Parameters

success Regex
timeout TimeSpan
failures IReadOnlyList<Regex>
cancellation CancellationToken

Returns

Task<LogLine>