/// <summary> /// Function to close the logger. /// </summary> public static void Close() { if ((_logFile == null) || (_logFile.IsClosed)) { return; } _logFile.Close(); _logFile = null; }
/// <summary> /// Initializes the <see cref="Gorgon"/> class. /// </summary> static Gorgon() { PlugIns = new GorgonPlugInFactory(); Log = new GorgonLogFile(LogFile, "Tape_Worm"); // Re-open the log if it's closed. if (Log.IsClosed) { try { Log.Open(); } #if DEBUG catch (Exception ex) { // Only note this in DEBUG mode. GorgonDialogs.ErrorBox(ApplicationForm, ex); } #else // ReSharper disable EmptyGeneralCatchClause catch { // We don't care if logging works or not in release mode. } // ReSharper restore EmptyGeneralCatchClause #endif } GorgonException.Log = Log; Log.Print("Initializing...", LoggingLevel.All); Log.Print("Architecture: {0}", LoggingLevel.Verbose, GorgonComputerInfo.PlatformArchitecture); Log.Print("Processor count: {0}", LoggingLevel.Verbose, GorgonComputerInfo.ProcessorCount); Log.Print("Installed Memory: {0}", LoggingLevel.Verbose, GorgonComputerInfo.TotalPhysicalRAM.FormatMemory()); Log.Print("Available Memory: {0}", LoggingLevel.Verbose, GorgonComputerInfo.AvailablePhysicalRAM.FormatMemory()); Log.Print("Operating System: {0} ({1})", LoggingLevel.Verbose, GorgonComputerInfo.OperatingSystemVersionText, GorgonComputerInfo.OperatingSystemArchitecture); // Default to using 10 milliseconds of sleep time when the application is not focused. UnfocusedSleepTime = 10; // Initializing application timing. GorgonTiming.Reset(); }
/// <summary> /// Function to handle an exception with this instance of the logger. /// </summary> /// <param name="ex">Exception to catch.</param> /// <param name="handler">Exception handler to call.</param> public static Exception CatchException(Exception ex, GorgonExceptionHandler handler = null) { if ((_logFile == null) || (_logFile.IsClosed)) { return(ex); } GorgonLogFile oldLogger = GorgonException.Log; try { GorgonException.Log = _logFile; return(GorgonException.Catch(ex, handler)); } finally { GorgonException.Log = oldLogger; } }
/// <summary> /// Function to open the log file for writing. /// </summary> public static void Open() { _logFile = new GorgonLogFile("Gorgon.Editor", "Tape_Worm"); try { _logFile.Open(); } #if DEBUG catch (Exception ex) { // If we can't open the log file in debug mode, let us know about it. GorgonDialogs.ErrorBox(null, ex); } #else catch { // Purposely left empty. We don't care about the log file in release mode. } #endif }