コード例 #1
0
        static internal void ReportUnhandledException(Exception e, string titleLine)
        {
            string        tempPath = Path.Combine(Path.GetTempPath(), "gmcreatorerror.txt");
            StringBuilder sb       = new StringBuilder(2048);

            sb.AppendLine(titleLine);
            sb.AppendLine("[email protected] attaching a screen cap of this message or");
            sb.AppendFormat("the file at \"{0}\"", tempPath);
            sb.AppendLine();
            sb.AppendLine("Exception Message:");
            sb.AppendLine(e.Message);
            sb.AppendLine();
            sb.AppendLine("Stack Trace:");
            sb.AppendLine(e.StackTrace);
            string message = sb.ToString();

            DebugLogger.Log("Program", "Caught top level exception:\n" + message);
            using (StreamWriter sw = new StreamWriter(tempPath, false, Encoding.UTF8))
            {
                sw.WriteLine(message);
                sw.WriteLine("Debug Log:");
                sw.WriteLine(DebugLogger.GetContents());
            }
            MessageBox.Show(message, "GMCreator", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
コード例 #2
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!CloseCurrentFile())
     {
         e.Cancel = true;
     }
     else
     {
         Rectangle winBounds;
         if (WindowState == FormWindowState.Normal)
         {
             winBounds = Bounds;
         }
         else
         {
             winBounds = RestoreBounds;
         }
         Globals.Save(Application.StartupPath, winBounds);
         if (DebugLogger.DoDebugActions())
         {
             string debugFile = Globals.MakeDebugSaveName(true, "log.txt");
             System.IO.File.WriteAllText(debugFile, DebugLogger.GetContents());
         }
     }
 }
コード例 #3
0
        private void MainForm_KeyUp(object sender, KeyEventArgs e)
        {
            Keys ctrlShift = Keys.Control | Keys.Shift;

            if ((e.KeyCode == Keys.F9) && ((e.Modifiers & ctrlShift) == ctrlShift))
            {
                string fileName = GetSaveFileName(this, "Save Log", "Log files (*.log, *.txt)|*.log,*.txt", null);
                if (String.IsNullOrEmpty(fileName))
                {
                    return;
                }
                System.IO.File.WriteAllText(fileName, DebugLogger.GetContents());
            }
        }
コード例 #4
0
 private void toggleLoggingToolStripMenuItem_Click(object sender, EventArgs e)
 {
     // turning it off
     if (DebugLogger.DoDebugActions())
     {
         string debugFile = Globals.MakeDebugSaveName(true, "log.txt");
         System.IO.File.WriteAllText(debugFile, DebugLogger.GetContents());
     }
     // turning it on
     else
     {
         string dir = Path.Combine(Application.StartupPath, "logged");
         Globals.RestartLoggingDir(dir);
     }
     DebugLogger.ToggleDebugActions();
 }
コード例 #5
0
        void SaveDebugLog(object sender, EventArgs e)
        {
            string debugFile = System.IO.Path.Combine(Application.StartupPath, "log.txt");

            System.IO.File.WriteAllText(debugFile, DebugLogger.GetContents());
        }