Ignore:
Timestamp:
3/1/2010 12:29:44 PM (2 years ago)
Author:
lowjoel
Message:

Add the current working directory, Operating system (including Vista/7 edition and service pack), CPU count and running processes to the debug report.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.Util/BlackBox.cs

    r1842 r1874  
    4040using System.Net; 
    4141using System.Xml; 
     42using System.ComponentModel; 
    4243 
    4344namespace Eraser.Util 
     
    189190                //Application information 
    190191                string separator = new string('-', 76); 
    191                 string lineFormat = "{0,15}: {1}"; 
     192                string lineFormat = "{0,17}: {1}"; 
    192193                stream.WriteLine("Application Information"); 
    193194                stream.WriteLine(separator); 
     
    202203                stream.WriteLine(string.Format(lineFormat, "Command Line", 
    203204                    commandLine.ToString().Trim())); 
     205                stream.WriteLine(string.Format(lineFormat, "Current Directory", 
     206                    Environment.CurrentDirectory)); 
     207 
     208                //System Information 
     209                stream.WriteLine(); 
     210                stream.WriteLine("System Information"); 
     211                stream.WriteLine(separator); 
     212                stream.WriteLine(string.Format(lineFormat, "Operating System", 
     213                    string.Format("{0} {2} {3}{1}", 
     214                        Environment.OSVersion.VersionString, 
     215                        string.IsNullOrEmpty(Environment.OSVersion.ServicePack) ? 
     216                            string.Empty : 
     217                            string.Format("(Service Pack {2})", Environment.OSVersion.ServicePack), 
     218                        SystemInfo.WindowsEdition == WindowsEditions.Undefined ? 
     219                            "" : SystemInfo.WindowsEdition.ToString(), 
     220                        SystemInfo.ProcessorArchitecture))); 
     221                stream.WriteLine(string.Format(lineFormat, "Processor Count", 
     222                    Environment.ProcessorCount)); 
     223                 
     224                //Running processes 
     225                stream.WriteLine(); 
     226                stream.WriteLine("Running Processes"); 
     227                stream.WriteLine(separator); 
     228                { 
     229                    int i = 0; 
     230                    foreach (Process process in Process.GetProcesses()) 
     231                    { 
     232                        try 
     233                        { 
     234                            ProcessModule mainModule = process.MainModule; 
     235                            stream.WriteLine(string.Format(lineFormat, 
     236                                string.Format("Process[{0}]", ++i), 
     237                                string.Format("{0} [{1}.{2}.{3}.{4}{5}]", mainModule.FileName, 
     238                                    mainModule.FileVersionInfo.FileMajorPart, 
     239                                    mainModule.FileVersionInfo.FileMinorPart, 
     240                                    mainModule.FileVersionInfo.FileBuildPart, 
     241                                    mainModule.FileVersionInfo.FilePrivatePart, 
     242                                    string.IsNullOrEmpty(mainModule.FileVersionInfo.FileVersion) ? 
     243                                        string.Empty : 
     244                                        string.Format(" <{0}>", 
     245                                            mainModule.FileVersionInfo.FileVersion)))); 
     246                        } 
     247                        catch (Win32Exception) 
     248                        { 
     249                        } 
     250                    } 
     251                } 
    204252 
    205253                //Exception Information 
Note: See TracChangeset for help on using the changeset viewer.