Changeset 1401 for branches/eraser6/BlackBox
- Timestamp:
- 12/22/2009 3:38:20 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
r1396 r1401 320 320 { 321 321 //Open a file stream 322 using (FileStream stream = new FileStream(Path.Combine(dumpFolder, "Memory.dmp"),322 using (FileStream stream = new FileStream(Path.Combine(dumpFolder, MemoryDumpFileName), 323 323 FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) 324 324 { … … 344 344 private void WriteDebugLog(string dumpFolder, Exception exception) 345 345 { 346 using (FileStream file = new FileStream(Path.Combine(dumpFolder, "Debug.log"),346 using (FileStream file = new FileStream(Path.Combine(dumpFolder, DebugLogFileName), 347 347 FileMode.OpenOrCreate, FileAccess.Write, FileShare.None)) 348 348 using (StreamWriter stream = new StreamWriter(file)) … … 369 369 stream.WriteLine(separator); 370 370 371 Exception currentException = exception; 372 for (uint i = 1; currentException != null; ++i) 371 //Open a stream to the Stack Trace Log file. We want to separate the stack 372 //trace do we can check against the server to see if the crash is a new one 373 using (StreamWriter stackTraceLog = new StreamWriter( 374 Path.Combine(dumpFolder, StackTraceFileName))) 373 375 { 374 stream.WriteLine(string.Format("Exception {0}:", i)); 375 stream.WriteLine(string.Format(lineFormat, "Message", currentException.Message)); 376 stream.WriteLine(string.Format(lineFormat, "Exception Type", 377 currentException.GetType().Name)); 378 379 //Parse the stack trace 380 string[] stackTrace = currentException.StackTrace.Split(new char[] { '\n' }); 381 for (uint j = 0; j < stackTrace.Length; ++j) 382 stream.WriteLine(string.Format(lineFormat, 383 string.Format("Stack Trace [{0}]", j), stackTrace[j].Trim())); 384 385 uint k = 0; 386 foreach (System.Collections.DictionaryEntry value in currentException.Data) 387 stream.WriteLine(string.Format(lineFormat, string.Format("Data[{0}]", ++k), 388 string.Format("{0} {1}", value.Key.ToString(), value.Value.ToString()))); 389 390 //End the exception and get the inner exception. 391 stream.WriteLine(); 392 currentException = exception.InnerException; 376 Exception currentException = exception; 377 for (uint i = 1; currentException != null; ++i) 378 { 379 stream.WriteLine(string.Format("Exception {0}:", i)); 380 stackTraceLog.WriteLine(string.Format("Exception {0}:", i)); 381 stream.WriteLine(string.Format(lineFormat, "Message", currentException.Message)); 382 stream.WriteLine(string.Format(lineFormat, "Exception Type", 383 currentException.GetType().Name)); 384 385 //Parse the stack trace 386 string[] stackTrace = currentException.StackTrace.Split(new char[] { '\n' }); 387 for (uint j = 0; j < stackTrace.Length; ++j) 388 { 389 string stackFrame = string.Format(lineFormat, 390 string.Format("Stack Trace [{0}]", j), stackTrace[j].Trim()); 391 stream.WriteLine(stackFrame); 392 stackTraceLog.WriteLine(stackFrame); 393 } 394 395 uint k = 0; 396 foreach (System.Collections.DictionaryEntry value in currentException.Data) 397 stream.WriteLine(string.Format(lineFormat, string.Format("Data[{0}]", ++k), 398 string.Format("{0} {1}", value.Key.ToString(), value.Value.ToString()))); 399 400 //End the exception and get the inner exception. 401 stream.WriteLine(); 402 currentException = exception.InnerException; 403 } 393 404 } 394 405 } … … 412 423 413 424 //Save the bitmap to disk 414 screenShot.Save(Path.Combine(dumpFolder, "Screenshot.png"), ImageFormat.Png);425 screenShot.Save(Path.Combine(dumpFolder, ScreenshotFileName), ImageFormat.Png); 415 426 } 416 427 … … 441 452 /// </summary> 442 453 internal static readonly string ScreenshotFileName = "Screenshot.png"; 454 455 /// <summary> 456 /// The file name of the stack trace. 457 /// </summary> 458 internal static readonly string StackTraceFileName = "Stack Trace.log"; 443 459 } 444 460 … … 478 494 List<FileInfo> result = new List<FileInfo>(); 479 495 DirectoryInfo directory = new DirectoryInfo(Path); 480 result.AddRange(directory.GetFiles()); 496 foreach (FileInfo file in directory.GetFiles()) 497 if (file.Name != BlackBox.StackTraceFileName) 498 result.Add(file); 499 481 500 return result.AsReadOnly(); 482 501 } … … 492 511 return new FileStream(System.IO.Path.Combine(Path, BlackBox.DebugLogFileName), 493 512 FileMode.Open, FileAccess.Read); 513 } 514 } 515 516 /// <summary> 517 /// Gets the stack trace for this crash report. 518 /// </summary> 519 public string StackTrace 520 { 521 get 522 { 523 return new StreamReader(System.IO.Path.Combine(Path, BlackBox.StackTraceFileName)). 524 ReadToEnd(); 494 525 } 495 526 }
Note: See TracChangeset
for help on using the changeset viewer.
