Logger

public static class Logger
General utility class for various runtime diagnostics.

Fields

HideSensitiveInformationFromLog

#
[EditorBrowsable(EditorBrowsableState.Never)] public static bool HideSensitiveInformationFromLog
Gets or sets whether personal information (such as UserName or MachineName ought to be included in the log. This flag must be set SUUUPER early on because the first thing the Logger does it dump a bunch of system info into the current log stream. At present, this value is not assigned at all, given that https://www.mcneel.com/privacy allows us to write all this data. The problem arises only when the user decides to share the log files, at which point it will be much harder to remove any specific entry.

Properties

Count

#
public static int Count { get; }
Gets the number of recorded messages in the current log.

Density

#
public static Density Density { get; set; }
Gets or sets the logging density.

Methods

Add

#
public static void Add(Exception exception, string context)
Log an exception message.
exception (Exception)Exception to log.
context (string)Exception context description.

Add

#
public static void Add(Exception exception)
Log an exception message.
exception (Exception)Exception to log.

Add

#
public static void Add(Level level, string message)
Log a message. This method is threadsafe.
level (Level)Message type.
message (string)Message to log.

Clear

#
public static void Clear()
Attempt to clear the current log file.

DeleteOldLogFiles

#
public static int DeleteOldLogFiles()
Delete all log files older than one day.
Number of log files deleted.

DeleteOldLogFiles

#
public static int DeleteOldLogFiles(TimeSpan retirementAge)
Delete all log files older than the retirement age.
retirementAge (TimeSpan)Age at which a log file is considered ripe for deletion.
Number of log files deleted.

Diagnostics

#
public static Entry[] Diagnostics()
Read all entries from the current log file.
Array of entries.

Diagnostics

#
public static Entry[] Diagnostics(byte[] bytes)
Read all parseable entries from an existing log file.
bytes (byte[])Log byte array.
Array of entries.

Diagnostics

#
public static Entry[] Diagnostics(string logFile)
Read all parseable entries from an existing log file.
logFile (string)Log file.
Array of entries.

DumpDiagnosticsToFile

#
public static bool DumpDiagnosticsToFile(string file, IEnumerable<Entry> entries)
Write a set of diagnostic messages to an HTML file. This method will not throw.
file (string)File path.
entries (IEnumerable<Entry>)Entries to include.
True if file was written or updated, false if otherwise.

LogCurrentState

#
public static void LogCurrentState()
Write a bunch of information to the log describing the current state of the computer.

MeasureSpan

#
public static TimeSpanMetric MeasureSpan(string name)
Begin a new timespan measure. You *must* dispose this metric in order to include the measures interval in the log.
name (string)Name of metric.
Dispoable object for timespan measurement.

MeasureSpan

#
public static TimeSpanMetric MeasureSpan(TimeSpan threshold, string name)
Begin a new timespan measure. You *must* dispose this metric in order to include the measures interval in the log.
threshold (TimeSpan)Reporting threshold.
name (string)Name of metric.
Dispoable object for timespan measurement.

ShowDiagnosticsInBrowser

#
public static string ShowDiagnosticsInBrowser(IEnumerable<Entry> entries)
Show the provided logged entries in a window, and save them as an HTML file on the desktop, or in the temp folder if the desktop cannot be written to.
entries (IEnumerable<Entry>)Entries to include.
The path to the html file if it could be saved, otherwise null. The window is shown regardless.