Log
Provides debug-only logging that writes to a log file. The file will be located in the current directory, which usually is the directory where your solution file is located.
internal static class LogExamples
Section titled “Examples”The following example writes messages to the log file during a generator run.
using Hertzole.SourceGen;
public static class GeneratorDiagnostics{ public static void Report() { Log.Info("Starting generation."); Log.Warning("No types were found to generate."); Log.Error("Failed to generate the output.");
// Clears the log file. Log.ClearLogs(); }}Remarks
Section titled “Remarks”All calls to this class are compiled out in release builds.
Methods
Section titled “Methods”ClearLogs()
Section titled “ClearLogs()”Clears the log file.
public static void ClearLogs();Error(object)
Section titled “Error(object)”Logs an error message with an ‘ERROR’ prefix.
public static void Error(object message);message
Section titled “message”The message to log.
Info(object)
Section titled “Info(object)”Logs an info message with an ‘INFO’ prefix.
public static void Info(object message);message
Section titled “message”The message to log.
Warning(object)
Section titled “Warning(object)”Logs a warning message with a ‘WARNING’ prefix.
public static void Warning(object message);message
Section titled “message”The message to log.