Table of Contents

Class Log

Namespace
NanoByte.Common
Assembly
NanoByte.Common.dll

A simple logging system. Writes to an in-memory buffer and a plain text file. Allows additional handlers to be registered (e.g., for console or GUI output).

public static class Log
Inheritance
object
Log

Methods

Debug(Exception)

Writes information to help developers diagnose problems to the log.

public static void Debug(Exception exception)

Parameters

exception Exception

Debug(string, Exception?)

Writes information to help developers diagnose problems to the log.

public static void Debug(string message, Exception? exception = null)

Parameters

message string
exception Exception

Error(Exception)

Writes a critical error that should be attended to to the log.

public static void Error(Exception exception)

Parameters

exception Exception

Error(string, Exception?)

Writes a critical error that should be attended to to the log.

public static void Error(string message, Exception? exception = null)

Parameters

message string
exception Exception

GetBuffer()

Returns the log lines collected in the in-memory buffer.

public static string GetBuffer()

Returns

string

Info(Exception)

Writes nice-to-know information to the log.

public static void Info(Exception exception)

Parameters

exception Exception

Info(string, Exception?)

Writes nice-to-know information to the log.

public static void Info(string message, Exception? exception = null)

Parameters

message string
exception Exception

ReadLastErrorFrom(string, int?)

Tries to read the last error log line written by another process.

public static string? ReadLastErrorFrom(string appName, int? processId = null)

Parameters

appName string

The name of the app to get a log line for.

processId int?

The process ID to get a log line for. Leave null to get for any process ID.

Returns

string

Warn(Exception)

Writes a warning that doesn't have to be acted upon immediately to the log.

public static void Warn(Exception exception)

Parameters

exception Exception

Warn(string, Exception?)

Writes a warning that doesn't have to be acted upon immediately to the log.

public static void Warn(string message, Exception? exception = null)

Parameters

message string
exception Exception

Events

Handler

Invoked when a new entry is added to the log. Only the newest (last) registered handler is invoked. System.Console output is used as a fallback if no handlers are registered.

public static event LogEntryEventHandler? Handler

Event Type

LogEntryEventHandler