Changeset 1609
- Timestamp:
- 1/19/2010 5:28:50 AM (3 years ago)
- File:
-
- 1 edited
-
branches/eraser6/BlackBox/Eraser.Util/BlackBox.cs (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/BlackBox/Eraser.Util/BlackBox.cs
r1608 r1609 268 268 269 269 //Generate a unique identifier for this report. 270 string crashName = DateTime.Now.ToString(CrashReportName, CultureInfo.InvariantCulture); 270 string crashName = DateTime.Now.ToUniversalTime().ToString( 271 CrashReportName, CultureInfo.InvariantCulture); 271 272 string currentCrashReport = Path.Combine(CrashReportsPath, crashName); 272 273 Directory.CreateDirectory(currentCrashReport); 273 274 274 //Then write a user-readable summary 275 WriteDebugLog(currentCrashReport, e); 276 277 //Take a screenshot 278 WriteScreenshot(currentCrashReport); 279 280 //Write a memory dump to the folder 281 WriteMemoryDump(currentCrashReport, e); 275 //Store the steps which we have completed. 276 int currentStep = 0; 277 278 try 279 { 280 //First, write a user-readable summary 281 WriteDebugLog(currentCrashReport, e); 282 ++currentStep; 283 284 //Take a screenshot 285 WriteScreenshot(currentCrashReport); 286 ++currentStep; 287 288 //Write a memory dump to the folder 289 WriteMemoryDump(currentCrashReport, e); 290 ++currentStep; 291 } 292 catch 293 { 294 //If an exception was caught while creating the report, we should just 295 //abort as that may cause a cascade. However, we need to remove the 296 //report folder if the crash report is empty. 297 if (currentStep == 0) 298 Directory.Delete(currentCrashReport); 299 } 282 300 } 283 301 … … 292 310 if (dirInfo.Exists) 293 311 foreach (DirectoryInfo subDir in dirInfo.GetDirectories()) 294 result.Add(new BlackBoxReport(Path.Combine(CrashReportsPath, subDir.Name))); 312 try 313 { 314 result.Add(new BlackBoxReport(Path.Combine(CrashReportsPath, subDir.Name))); 315 } 316 catch (InvalidDataException) 317 { 318 //Do nothing: invalid reports are automatically deleted. 319 } 295 320 296 321 return result.ToArray(); … … 374 399 //trace do we can check against the server to see if the crash is a new one 375 400 using (StreamWriter stackTraceLog = new StreamWriter( 376 Path.Combine(dumpFolder, StackTraceFileName)))401 Path.Combine(dumpFolder, BlackBoxReport.StackTraceFileName))) 377 402 { 378 403 Exception currentException = exception; … … 459 484 /// </summary> 460 485 internal static readonly string ScreenshotFileName = "Screenshot.png"; 461 462 /// <summary>463 /// The file name of the stack trace.464 /// </summary>465 internal static readonly string StackTraceFileName = "Stack Trace.log";466 486 } 467 487 … … 480 500 Path = path; 481 501 502 string stackTracePath = System.IO.Path.Combine(Path, StackTraceFileName); 503 if (!System.IO.File.Exists(stackTracePath)) 504 { 505 Delete(); 506 throw new InvalidDataException("The BlackBox report is corrupt."); 507 } 508 482 509 string[] stackTrace = null; 483 using (StreamReader reader = new StreamReader( 484 System.IO.Path.Combine(Path, BlackBox.StackTraceFileName))) 485 { 510 using (StreamReader reader = new StreamReader(stackTracePath)) 486 511 stackTrace = reader.ReadToEnd().Split(new char[] { '\n' }); 487 }488 512 489 513 //Parse the lines in the file. … … 543 567 { 544 568 return DateTime.ParseExact(Name, BlackBox.CrashReportName, 545 CultureInfo.InvariantCulture) ;569 CultureInfo.InvariantCulture).ToLocalTime(); 546 570 } 547 571 } … … 640 664 641 665 /// <summary> 666 /// The file name of the stack trace. 667 /// </summary> 668 internal static readonly string StackTraceFileName = "Stack Trace.log"; 669 670 /// <summary> 642 671 /// The list of files internal to the report. 643 672 /// </summary> 644 673 private static readonly List<string> InternalFiles = new List<string>( 645 674 new string[] { 646 BlackBox.StackTraceFileName,647 "Status.txt"675 StackTraceFileName, 676 StatusFileName 648 677 } 649 678 );
Note: See TracChangeset
for help on using the changeset viewer.
