Table of Contents

Class LogService

Namespace
VpnHood.Net.Toolkit.Logging
Assembly
VpnHood.Net.Toolkit.dll

Provides the process's log file and applies the user's log settings, for an app or for a VPN service in a process of its own.

public class LogService : IDisposable
Inheritance
LogService
Implements
Inherited Members
Extension Methods

Remarks

The file joins the process's log at the first Start(LogServiceOptions, bool) that opens it; each start, such as a connect's, opens it again, starting afresh unless told to keep what it has, and Stop() closes it. The settings go to VhLogger's level and redaction, which every sink is behind, before the file opens.

Constructors

LogService(string)

Provides the process's log file and applies the user's log settings, for an app or for a VPN service in a process of its own.

public LogService(string logFilePath)

Parameters

logFilePath string

The log file's path.

Remarks

The file joins the process's log at the first Start(LogServiceOptions, bool) that opens it; each start, such as a connect's, opens it again, starting afresh unless told to keep what it has, and Stop() closes it. The settings go to VhLogger's level and redaction, which every sink is behind, before the file opens.

Properties

Exists

Gets a value indicating whether the log file exists.

public bool Exists { get; }

Property Value

bool

LogFilePath

Gets the log file's path.

public string LogFilePath { get; }

Property Value

string

Methods

Dispose()

Closes the log file, as Stop() does. Calling it again does nothing.

public void Dispose()

GetLogEventNames(string)

Gets the event names a debug command names.

public static IEnumerable<string> GetLogEventNames(string debugCommand)

Parameters

debugCommand string

The debug command, whose /log: parts name events, separated by commas.

Returns

IEnumerable<string>

The names, each once, * first.

GetLogEventNames(string[], string)

Joins event names with those a debug command names.

public static IEnumerable<string> GetLogEventNames(string[] currentNames, string debugCommand)

Parameters

currentNames string[]

The names so far.

debugCommand string

The debug command, whose /log: parts name events, separated by commas.

Returns

IEnumerable<string>

The names, each once, * among them.

Exceptions

ArgumentNullException

currentNames is null.

Start(LogServiceOptions, bool)

Applies the options to the process's log, and opens the log file or closes it. With the options off, it does nothing.

public void Start(LogServiceOptions options, bool deleteOldReport = true)

Parameters

options LogServiceOptions

The options.

deleteOldReport bool

true to start the file afresh; false to keep what it has, so a log opened before a connect is not the end of the last session's.

Exceptions

ObjectDisposedException

The service is disposed.

IOException

The file cannot be opened.

UnauthorizedAccessException

The process may not write the file.

ArgumentException

The file's path is not valid.

Stop()

Closes the log file; the log's level and redaction stay. Calling it on a closed file does nothing.

public void Stop()