Add a basic log issue reporter
This commit is contained in:
1 parent
47bd3286d5
commit
d9a98fcd14
10 files changed
+2107
-13
No files matched your search
+2
-1
@@ -28,6 +28,7 @@ using Vocaluxe.Base;
|
|||||||
using Vocaluxe.Base.Fonts;
|
using Vocaluxe.Base.Fonts;
|
||||||
using Vocaluxe.Base.Server;
|
using Vocaluxe.Base.Server;
|
||||||
using Vocaluxe.Base.ThemeSystem;
|
using Vocaluxe.Base.ThemeSystem;
|
||||||
|
using Vocaluxe.Reporting;
|
||||||
using VocaluxeLib.Log;
|
using VocaluxeLib.Log;
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("VocaluxeTests")]
|
[assembly: InternalsVisibleTo("VocaluxeTests")]
|
||||||
@@ -97,7 +98,7 @@ namespace Vocaluxe
|
|||||||
Directory.CreateDirectory(CSettings.DataFolder);
|
Directory.CreateDirectory(CSettings.DataFolder);
|
||||||
|
|
||||||
// Init Log
|
// Init Log
|
||||||
CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.GetFullVersionText());
|
CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.GetFullVersionText(), CReporter.ShowReporterFunc);
|
||||||
|
|
||||||
if (!CProgrammHelper.CheckRequirements())
|
if (!CProgrammHelper.CheckRequirements())
|
||||||
return;
|
return;
|
||||||
|
|||||||
Generated
+186
@@ -0,0 +1,186 @@
|
|||||||
|
namespace Vocaluxe.Reporting
|
||||||
|
{
|
||||||
|
partial class CReporter
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CReporter));
|
||||||
|
this.Title = new System.Windows.Forms.Label();
|
||||||
|
this.Message = new System.Windows.Forms.TextBox();
|
||||||
|
this.Log = new System.Windows.Forms.TextBox();
|
||||||
|
this.GistOnly = new System.Windows.Forms.RadioButton();
|
||||||
|
this.GistAndIssue = new System.Windows.Forms.RadioButton();
|
||||||
|
this.NoUpload = new System.Windows.Forms.RadioButton();
|
||||||
|
this.Submit = new System.Windows.Forms.Button();
|
||||||
|
this.Url = new System.Windows.Forms.TextBox();
|
||||||
|
this.SubmitedMessage = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// Title
|
||||||
|
//
|
||||||
|
this.Title.AutoSize = true;
|
||||||
|
this.Title.Enabled = false;
|
||||||
|
this.Title.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.Title.Location = new System.Drawing.Point(9, 8);
|
||||||
|
this.Title.Name = "Title";
|
||||||
|
this.Title.Size = new System.Drawing.Size(110, 20);
|
||||||
|
this.Title.TabIndex = 0;
|
||||||
|
this.Title.Text = "We are sorry";
|
||||||
|
//
|
||||||
|
// Message
|
||||||
|
//
|
||||||
|
this.Message.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||||
|
this.Message.Enabled = false;
|
||||||
|
this.Message.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.Message.Location = new System.Drawing.Point(13, 31);
|
||||||
|
this.Message.Multiline = true;
|
||||||
|
this.Message.Name = "Message";
|
||||||
|
this.Message.ReadOnly = true;
|
||||||
|
this.Message.Size = new System.Drawing.Size(625, 63);
|
||||||
|
this.Message.TabIndex = 0;
|
||||||
|
this.Message.TabStop = false;
|
||||||
|
this.Message.Text = "that Vocaluxe run into an error and crashed.\r\nTo help us fix the problem please s" +
|
||||||
|
"end us a report.\r\nEdit the following log before submitting to remove possibly se" +
|
||||||
|
"nsitive information.";
|
||||||
|
//
|
||||||
|
// Log
|
||||||
|
//
|
||||||
|
this.Log.AcceptsReturn = true;
|
||||||
|
this.Log.AcceptsTab = true;
|
||||||
|
this.Log.Location = new System.Drawing.Point(13, 100);
|
||||||
|
this.Log.Multiline = true;
|
||||||
|
this.Log.Name = "Log";
|
||||||
|
this.Log.Size = new System.Drawing.Size(625, 189);
|
||||||
|
this.Log.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// GistOnly
|
||||||
|
//
|
||||||
|
this.GistOnly.AutoSize = true;
|
||||||
|
this.GistOnly.Checked = true;
|
||||||
|
this.GistOnly.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.GistOnly.Location = new System.Drawing.Point(12, 295);
|
||||||
|
this.GistOnly.Name = "GistOnly";
|
||||||
|
this.GistOnly.Size = new System.Drawing.Size(385, 24);
|
||||||
|
this.GistOnly.TabIndex = 2;
|
||||||
|
this.GistOnly.TabStop = true;
|
||||||
|
this.GistOnly.Text = "Upload and get a link to your report (publicly visible)";
|
||||||
|
this.GistOnly.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// GistAndIssue
|
||||||
|
//
|
||||||
|
this.GistAndIssue.AutoSize = true;
|
||||||
|
this.GistAndIssue.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.GistAndIssue.Location = new System.Drawing.Point(12, 325);
|
||||||
|
this.GistAndIssue.Name = "GistAndIssue";
|
||||||
|
this.GistAndIssue.Size = new System.Drawing.Size(519, 24);
|
||||||
|
this.GistAndIssue.TabIndex = 3;
|
||||||
|
this.GistAndIssue.TabStop = true;
|
||||||
|
this.GistAndIssue.Text = "Upload and open an issue (publicly visible + requires a github account)";
|
||||||
|
this.GistAndIssue.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// NoUpload
|
||||||
|
//
|
||||||
|
this.NoUpload.AutoSize = true;
|
||||||
|
this.NoUpload.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.NoUpload.Location = new System.Drawing.Point(12, 355);
|
||||||
|
this.NoUpload.Name = "NoUpload";
|
||||||
|
this.NoUpload.Size = new System.Drawing.Size(493, 24);
|
||||||
|
this.NoUpload.TabIndex = 4;
|
||||||
|
this.NoUpload.TabStop = true;
|
||||||
|
this.NoUpload.Text = "Don\'t upload anything (you can still copy the error message above)";
|
||||||
|
this.NoUpload.UseVisualStyleBackColor = true;
|
||||||
|
this.NoUpload.CheckedChanged += new System.EventHandler(this.NoUpload_CheckedChanged);
|
||||||
|
//
|
||||||
|
// Submit
|
||||||
|
//
|
||||||
|
this.Submit.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.Submit.Location = new System.Drawing.Point(537, 306);
|
||||||
|
this.Submit.Name = "Submit";
|
||||||
|
this.Submit.Size = new System.Drawing.Size(101, 73);
|
||||||
|
this.Submit.TabIndex = 5;
|
||||||
|
this.Submit.Text = "Submit";
|
||||||
|
this.Submit.UseVisualStyleBackColor = true;
|
||||||
|
this.Submit.Click += new System.EventHandler(this.Submit_Click);
|
||||||
|
//
|
||||||
|
// Url
|
||||||
|
//
|
||||||
|
this.Url.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.Url.Location = new System.Drawing.Point(12, 327);
|
||||||
|
this.Url.Name = "Url";
|
||||||
|
this.Url.ReadOnly = true;
|
||||||
|
this.Url.Size = new System.Drawing.Size(519, 22);
|
||||||
|
this.Url.TabIndex = 6;
|
||||||
|
this.Url.Text = "https://gist.github.com/lukeIam/cc81f7ef3545ef2baf0ca9a28ffe4bd8";
|
||||||
|
this.Url.Visible = false;
|
||||||
|
//
|
||||||
|
// SubmitedMessage
|
||||||
|
//
|
||||||
|
this.SubmitedMessage.AutoSize = true;
|
||||||
|
this.SubmitedMessage.Enabled = false;
|
||||||
|
this.SubmitedMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||||
|
this.SubmitedMessage.Location = new System.Drawing.Point(9, 299);
|
||||||
|
this.SubmitedMessage.Name = "SubmitedMessage";
|
||||||
|
this.SubmitedMessage.Size = new System.Drawing.Size(189, 20);
|
||||||
|
this.SubmitedMessage.TabIndex = 8;
|
||||||
|
this.SubmitedMessage.Text = "The link to your report:";
|
||||||
|
this.SubmitedMessage.Visible = false;
|
||||||
|
//
|
||||||
|
// CReporter
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(650, 387);
|
||||||
|
this.Controls.Add(this.SubmitedMessage);
|
||||||
|
this.Controls.Add(this.Url);
|
||||||
|
this.Controls.Add(this.Submit);
|
||||||
|
this.Controls.Add(this.NoUpload);
|
||||||
|
this.Controls.Add(this.GistAndIssue);
|
||||||
|
this.Controls.Add(this.GistOnly);
|
||||||
|
this.Controls.Add(this.Log);
|
||||||
|
this.Controls.Add(this.Message);
|
||||||
|
this.Controls.Add(this.Title);
|
||||||
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
this.Name = "CReporter";
|
||||||
|
this.Text = "Vocaluxe Issue Reporter";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label Title;
|
||||||
|
private System.Windows.Forms.TextBox Message;
|
||||||
|
private System.Windows.Forms.TextBox Log;
|
||||||
|
private System.Windows.Forms.RadioButton GistOnly;
|
||||||
|
private System.Windows.Forms.RadioButton GistAndIssue;
|
||||||
|
private System.Windows.Forms.RadioButton NoUpload;
|
||||||
|
private System.Windows.Forms.Button Submit;
|
||||||
|
private System.Windows.Forms.TextBox Url;
|
||||||
|
private System.Windows.Forms.Label SubmitedMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,258 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using VocaluxeLib.Log;
|
||||||
|
|
||||||
|
namespace Vocaluxe.Reporting
|
||||||
|
{
|
||||||
|
public partial class CReporter : Form
|
||||||
|
{
|
||||||
|
private string _TitleText = "We are sorry";
|
||||||
|
private string _MessageCrashText = "that Vocaluxe run into an error and crashed.\r\nTo help us fix the problem please send us a report.\r\nEdit the following log before submitting to remove possibly sensitive information.";
|
||||||
|
private string _MessageNoCrashText = "that you experienced an error.\r\nTo help us fix the problem please send us a report.\r\nEdit the following log before submitting to remove possibly sensitive information.";
|
||||||
|
private string _NoUploadText = "Don\'t upload anything (you can still copy the error message above)";
|
||||||
|
private string _GistAndIssueText = "Upload and open an issue (publicly visible + requires a github account)";
|
||||||
|
private string _GistOnlyText = "Upload and get a link to your report (publicly visible)";
|
||||||
|
private string _SubmitStep0Text = "Submit";
|
||||||
|
private string _SubmitStep1Text = "Uploading";
|
||||||
|
private string _SubmitStep2CrashText = "Exit";
|
||||||
|
private string _SubmitStep2NoCrashText = "Continue";
|
||||||
|
private string _SubmitedMessageText = "The link to your report:";
|
||||||
|
private string _LogUploadErrorText = "Error uploading the log.";
|
||||||
|
|
||||||
|
|
||||||
|
private string _IssueTemplate = "Describe your issue here.\n\n### Steps to reproduce\nTell us how to reproduce this issue.\n\n### Vocaluxe version and logfile\n{0}\n{1}";
|
||||||
|
|
||||||
|
private int _Step = 0;
|
||||||
|
private readonly bool _Crash;
|
||||||
|
private readonly string _VocaluxeVersionTag;
|
||||||
|
private readonly bool _ShowContinue;
|
||||||
|
|
||||||
|
private static readonly HttpClient _Client = new HttpClient();
|
||||||
|
private static readonly Regex _GetGistUrlRegex = new Regex("\"raw_url\": *\"([^\"]+)\"");
|
||||||
|
|
||||||
|
|
||||||
|
public static ShowReporterDelegate ShowReporterFunc
|
||||||
|
{
|
||||||
|
get { return _ShowReporter; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void _ShowReporter(bool crash, bool showContinue, string vocaluxeVersionTag, string log)
|
||||||
|
{
|
||||||
|
using (var reporter = new CReporter(crash, showContinue, vocaluxeVersionTag, log))
|
||||||
|
{
|
||||||
|
reporter.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the log file reporter.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="crash">True if we are submitting a crash, false otherwise (e.g. error).</param>
|
||||||
|
/// <param name="showContinue">True if the reporter show show a continue message, false if it should show an exit message.</param>
|
||||||
|
/// <param name="vocaluxeVersionTag">The full version tag of this instance (like it is diplayed in the main menu).</param>
|
||||||
|
/// <param name="log">The log to submit.</param>
|
||||||
|
public CReporter(bool crash, bool showContinue, string vocaluxeVersionTag, string log)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_Crash = crash;
|
||||||
|
_ShowContinue = showContinue;
|
||||||
|
_VocaluxeVersionTag = vocaluxeVersionTag;
|
||||||
|
_Init(log);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initilaize the gui.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="log">The Log to submit.</param>
|
||||||
|
private void _Init(string log)
|
||||||
|
{
|
||||||
|
_Client.DefaultRequestHeaders.Add("accept", "application/json");
|
||||||
|
_Client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)");
|
||||||
|
|
||||||
|
this.Title.Text = _TitleText;
|
||||||
|
this.Message.Text = _Crash ? _MessageCrashText : _MessageNoCrashText;
|
||||||
|
this.NoUpload.Text = _NoUploadText;
|
||||||
|
this.GistAndIssue.Text = _GistAndIssueText;
|
||||||
|
this.GistOnly.Text = _GistOnlyText;
|
||||||
|
this.Submit.Text = _SubmitStep0Text;
|
||||||
|
this.SubmitedMessage.Text = _SubmitedMessageText;
|
||||||
|
this.Log.Text = log.Replace("\n","\r\n");
|
||||||
|
this.Log.SelectionStart = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void Submit_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
switch (_Step)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
if (this.NoUpload.Checked)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_Step = 1;
|
||||||
|
this.Submit.Text = _SubmitStep1Text;
|
||||||
|
this.Submit.Enabled = false;
|
||||||
|
this.NoUpload.Visible = false;
|
||||||
|
this.GistAndIssue.Visible = false;
|
||||||
|
this.GistOnly.Visible = false;
|
||||||
|
this.Log.Enabled = false;
|
||||||
|
|
||||||
|
string url;
|
||||||
|
if (this.GistOnly.Checked)
|
||||||
|
{
|
||||||
|
await Task.Run(() => _StartGistUpload(this.Log.Text));
|
||||||
|
}
|
||||||
|
else if (this.GistAndIssue.Checked)
|
||||||
|
{
|
||||||
|
await Task.Run(() => _StartIssueUpload(this.Log.Text));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_Step = 0;
|
||||||
|
this.Submit.Text = _SubmitStep0Text;
|
||||||
|
this.Submit.Enabled = true;
|
||||||
|
this.NoUpload.Visible = true;
|
||||||
|
this.GistAndIssue.Visible = true;
|
||||||
|
this.GistOnly.Visible = true;
|
||||||
|
this.Log.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
this.Close();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NoUpload_CheckedChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.Submit.Text = this.NoUpload.Checked ? (_ShowContinue ? _SubmitStep2CrashText : _SubmitStep2NoCrashText) : _SubmitStep0Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the gui after the upload finished.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url">Url to show, if null or empty an error message is shown.</param>
|
||||||
|
private void _UploadFinished(string url)
|
||||||
|
{
|
||||||
|
if (this.InvokeRequired)
|
||||||
|
{
|
||||||
|
this.Invoke(new MethodInvoker(() => { _UploadFinished(url); }));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_Step = 2;
|
||||||
|
this.Submit.Text = _ShowContinue ? _SubmitStep2CrashText : _SubmitStep2NoCrashText;
|
||||||
|
this.Submit.Enabled = true;
|
||||||
|
this.SubmitedMessage.Visible = true;
|
||||||
|
this.Url.Text = string.IsNullOrWhiteSpace(url)?_LogUploadErrorText:url;
|
||||||
|
this.Url.Visible = true;
|
||||||
|
this.Url.SelectAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Upload a log to gist and updates the gui.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="log">The log to upload.</param>
|
||||||
|
private async void _StartGistUpload(string log)
|
||||||
|
{
|
||||||
|
// Upload log to github gist and show the link
|
||||||
|
_UploadFinished(await _UploadLogToGist(log));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Upload a log to gist, opens an issue template on github and updates the gui.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="log">The log to upload.</param>
|
||||||
|
private async void _StartIssueUpload(string log)
|
||||||
|
{
|
||||||
|
// Upload log to github gist
|
||||||
|
string gistUrl = await _UploadLogToGist(log);
|
||||||
|
|
||||||
|
// Build issue body
|
||||||
|
string template = string.Format(_IssueTemplate, _VocaluxeVersionTag, gistUrl);
|
||||||
|
|
||||||
|
// Build url for github issue template
|
||||||
|
string issueUrl = $"https://github.com/Vocaluxe/Vocaluxe/issues/new?title=Give%20me%20a%20meaningful%20title&body={ Uri.EscapeDataString(template) }";
|
||||||
|
|
||||||
|
// Start the browser with the issue template url
|
||||||
|
System.Diagnostics.Process.Start(issueUrl);
|
||||||
|
|
||||||
|
// Show the link
|
||||||
|
_UploadFinished(issueUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Uploads a log to a new anonymous gist.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="log">The log that should be uploaded.</param>
|
||||||
|
/// <returns>The link to the uploaded file.</returns>
|
||||||
|
private async Task<string> _UploadLogToGist(string log)
|
||||||
|
{
|
||||||
|
string json = JsonConvert.SerializeObject(new CGistCreateData()
|
||||||
|
{
|
||||||
|
Description = $"An { (_Crash ? "crash" : "error") } log submission for { _VocaluxeVersionTag }",
|
||||||
|
Public = false,
|
||||||
|
Files = new Dictionary<string, CGistFileData>()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
"Vocaluxe.log",
|
||||||
|
new CGistFileData()
|
||||||
|
{
|
||||||
|
Content = log
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
string responseString = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = await _Client.PostAsync("https://api.github.com/gists", content);
|
||||||
|
|
||||||
|
responseString = await response.Content.ReadAsStringAsync();
|
||||||
|
}
|
||||||
|
catch (HttpRequestException e)
|
||||||
|
{
|
||||||
|
CLog.Error(e, "Couldn't upload log", show:true, propertyValues:CLog.Params(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
return _GetGistUrlRegex.Match(responseString)?.Groups[1]?.Value??"";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper class for gist creation.
|
||||||
|
/// </summary>
|
||||||
|
private class CGistCreateData
|
||||||
|
{
|
||||||
|
[JsonProperty("description")]
|
||||||
|
public string Description { get; set; }
|
||||||
|
[JsonProperty("public")]
|
||||||
|
public bool Public { get; set; }
|
||||||
|
[JsonProperty("files")]
|
||||||
|
public Dictionary<string, CGistFileData> Files { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper class for gist creation.
|
||||||
|
/// </summary>
|
||||||
|
private class CGistFileData
|
||||||
|
{
|
||||||
|
[JsonProperty("content")]
|
||||||
|
public string Content { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -159,6 +159,10 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
|
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Serilog.2.6.0\lib\net46\Serilog.dll</HintPath>
|
<HintPath>..\packages\Serilog.2.6.0\lib\net46\Serilog.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
@@ -186,6 +190,7 @@
|
|||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
<Reference Include="System.Runtime.Serialization" />
|
||||||
<Reference Include="System.ServiceModel" />
|
<Reference Include="System.ServiceModel" />
|
||||||
<Reference Include="System.ServiceModel.Web" />
|
<Reference Include="System.ServiceModel.Web" />
|
||||||
@@ -282,6 +287,12 @@
|
|||||||
<Compile Include="Lib\Video\Acinerella\CDecoderThread.cs" />
|
<Compile Include="Lib\Video\Acinerella\CDecoderThread.cs" />
|
||||||
<Compile Include="Lib\Video\Acinerella\CFramebuffer.cs" />
|
<Compile Include="Lib\Video\Acinerella\CFramebuffer.cs" />
|
||||||
<Compile Include="Lib\Sound\Record\CDelayTest.cs" />
|
<Compile Include="Lib\Sound\Record\CDelayTest.cs" />
|
||||||
|
<Compile Include="Reporting\Reporter.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Reporting\Reporter.Designer.cs">
|
||||||
|
<DependentUpon>Reporter.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Screens\CPopupScreenServerQR.cs" />
|
<Compile Include="Screens\CPopupScreenServerQR.cs" />
|
||||||
<Compile Include="Screens\CScreenOptionsVideoAdjustments.cs" />
|
<Compile Include="Screens\CScreenOptionsVideoAdjustments.cs" />
|
||||||
<Compile Include="SongQueue\CSongQueue.cs" />
|
<Compile Include="SongQueue\CSongQueue.cs" />
|
||||||
@@ -512,6 +523,11 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<WCFMetadata Include="Service References\" />
|
<WCFMetadata Include="Service References\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Reporting\Reporter.resx">
|
||||||
|
<DependentUpon>Reporter.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">xcopy /E /D /Y "$(ProjectDir)\Website" "$(SolutionDir)\PhoneGap"</PostBuildEvent>
|
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">xcopy /E /D /Y "$(ProjectDir)\Website" "$(SolutionDir)\PhoneGap"</PostBuildEvent>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
|
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net471" />
|
||||||
<package id="Serilog" version="2.6.0" targetFramework="net471" />
|
<package id="Serilog" version="2.6.0" targetFramework="net471" />
|
||||||
<package id="Serilog.Enrichers.Thread" version="3.0.0" targetFramework="net471" />
|
<package id="Serilog.Enrichers.Thread" version="3.0.0" targetFramework="net471" />
|
||||||
<package id="Serilog.Formatting.Compact" version="1.0.0" targetFramework="net471" />
|
<package id="Serilog.Formatting.Compact" version="1.0.0" targetFramework="net471" />
|
||||||
|
|||||||
+21
-11
@@ -18,20 +18,27 @@ namespace VocaluxeLib.Log
|
|||||||
private static ILogger _SongLog = new SilentLogger();
|
private static ILogger _SongLog = new SilentLogger();
|
||||||
private static string _LogFolder;
|
private static string _LogFolder;
|
||||||
private static string _CrashMarkerFilePath;
|
private static string _CrashMarkerFilePath;
|
||||||
|
private static ShowReporterDelegate _ShowReporterFunc;
|
||||||
|
private static string _CurrentVersion;
|
||||||
|
|
||||||
private const string _MainLogTemplate = "[{TimeStampFromStart}] [{Level}] {Message}{NewLine}{Properties}{NewLine}{Exception}";
|
private const string _MainLogTemplate = "[{TimeStampFromStart}] [{Level}] {Message}{NewLine}{Properties}{NewLine}{Exception}";
|
||||||
private const string _SongLogTemplate = "{Message}{NewLine}Additional info:{Properties}{NewLine}{Exception}";
|
private const string _SongLogTemplate = "{Message}{NewLine}Additional info:{Properties}{NewLine}{Exception}";
|
||||||
|
|
||||||
public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog, string fileNameCrashMarker, string currentVersion)
|
public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog, string fileNameCrashMarker, string currentVersion, ShowReporterDelegate showReporterFunc)
|
||||||
{
|
{
|
||||||
_LogFolder = logFolder;
|
_LogFolder = logFolder;
|
||||||
_CrashMarkerFilePath = Path.Combine(_LogFolder, fileNameCrashMarker);
|
_ShowReporterFunc = showReporterFunc;
|
||||||
|
_CurrentVersion = currentVersion;
|
||||||
|
|
||||||
|
_CrashMarkerFilePath = Path.Combine(_LogFolder, fileNameCrashMarker);
|
||||||
|
|
||||||
// Creates the log directory if it does not exist
|
// Creates the log directory if it does not exist
|
||||||
if (!Directory.Exists(_LogFolder))
|
if (!Directory.Exists(_LogFolder))
|
||||||
Directory.CreateDirectory(_LogFolder);
|
Directory.CreateDirectory(_LogFolder);
|
||||||
|
|
||||||
|
var mainLogFilePath = Path.Combine(_LogFolder, fileNameMainLog);
|
||||||
|
var songLogFilePath = Path.Combine(_LogFolder, fileNameSongInfoLog);
|
||||||
|
|
||||||
// Check if crash marker file
|
// Check if crash marker file
|
||||||
if (File.Exists(_CrashMarkerFilePath))
|
if (File.Exists(_CrashMarkerFilePath))
|
||||||
{
|
{
|
||||||
@@ -45,17 +52,18 @@ namespace VocaluxeLib.Log
|
|||||||
// Delete the old marker
|
// Delete the old marker
|
||||||
File.Delete(_CrashMarkerFilePath);
|
File.Delete(_CrashMarkerFilePath);
|
||||||
|
|
||||||
if (currentVersion == versionTag)
|
if (_CurrentVersion == versionTag && File.Exists(mainLogFilePath))
|
||||||
{
|
{
|
||||||
// TODO: Load log + Crashreport
|
string logContent = File.ReadAllText(mainLogFilePath, Encoding.UTF8);
|
||||||
|
_ShowReporterFunc(crash:true, allowContinue:true, vocaluxeVersionTag:versionTag, log:logContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write new marker
|
// Write new marker
|
||||||
File.WriteAllText(_CrashMarkerFilePath, currentVersion, Encoding.UTF8);
|
File.WriteAllText(_CrashMarkerFilePath, _CurrentVersion, Encoding.UTF8);
|
||||||
|
|
||||||
LogFileRoller.RollLogs(Path.Combine(_LogFolder, fileNameMainLog), 2);
|
LogFileRoller.RollLogs(mainLogFilePath, 2);
|
||||||
LogFileRoller.RollLogs(Path.Combine(_LogFolder, fileNameSongInfoLog), 2);
|
LogFileRoller.RollLogs(songLogFilePath, 2);
|
||||||
|
|
||||||
_MainLog = new LoggerConfiguration()
|
_MainLog = new LoggerConfiguration()
|
||||||
.Enrich.WithThreadId()
|
.Enrich.WithThreadId()
|
||||||
@@ -63,14 +71,14 @@ namespace VocaluxeLib.Log
|
|||||||
.Enrich.WithTimeStampFromStart()
|
.Enrich.WithTimeStampFromStart()
|
||||||
.WriteTo.TextWriter(_MainLogStringWriter, outputTemplate: _MainLogTemplate)
|
.WriteTo.TextWriter(_MainLogStringWriter, outputTemplate: _MainLogTemplate)
|
||||||
// Json can be activated by adding "new CompactJsonFormatter()" as first argument
|
// Json can be activated by adding "new CompactJsonFormatter()" as first argument
|
||||||
.WriteTo.File(Path.Combine(_LogFolder, fileNameMainLog), flushToDiskInterval: TimeSpan.FromSeconds(30), outputTemplate: _MainLogTemplate)
|
.WriteTo.File(mainLogFilePath, flushToDiskInterval: TimeSpan.FromSeconds(30), outputTemplate: _MainLogTemplate)
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
.WriteTo.Console(outputTemplate: _MainLogTemplate)
|
.WriteTo.Console(outputTemplate: _MainLogTemplate)
|
||||||
#endif
|
#endif
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
|
|
||||||
_SongLog = new LoggerConfiguration()
|
_SongLog = new LoggerConfiguration()
|
||||||
.WriteTo.File(Path.Combine(_LogFolder, fileNameSongInfoLog), flushToDiskInterval: TimeSpan.FromSeconds(60), outputTemplate: _SongLogTemplate)
|
.WriteTo.File(songLogFilePath, flushToDiskInterval: TimeSpan.FromSeconds(60), outputTemplate: _SongLogTemplate)
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
.WriteTo.Console(outputTemplate: "[SongInfo] " + _SongLogTemplate)
|
.WriteTo.Console(outputTemplate: "[SongInfo] " + _SongLogTemplate)
|
||||||
#endif
|
#endif
|
||||||
@@ -102,8 +110,10 @@ namespace VocaluxeLib.Log
|
|||||||
|
|
||||||
private static void _ShowLogAssistent(string messageTemplate, object[] propertyValues, string callerMethodeName = "", string callerFilePath = "", int callerLineNumer = -1)
|
private static void _ShowLogAssistent(string messageTemplate, object[] propertyValues, string callerMethodeName = "", string callerFilePath = "", int callerLineNumer = -1)
|
||||||
{
|
{
|
||||||
//Todo: Logsend assistent
|
// Flush the _MainLogStringWriter to get the latest entries to _MainLogStringBuilder
|
||||||
//MessageBox.Show(messageTemplate, "Vocaluxe", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
_MainLogStringWriter.Flush();
|
||||||
|
// Show the Reporter
|
||||||
|
_ShowReporterFunc(crash: true, allowContinue: true, vocaluxeVersionTag: _CurrentVersion, log: _MainLogStringBuilder.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
namespace VocaluxeLib.Log
|
||||||
|
{
|
||||||
|
public delegate void ShowReporterDelegate(bool crash, bool allowContinue, string vocaluxeVersionTag, string log);
|
||||||
|
}
|
||||||
@@ -112,6 +112,7 @@
|
|||||||
<Compile Include="CEncoding.cs" />
|
<Compile Include="CEncoding.cs" />
|
||||||
<Compile Include="CFading.cs" />
|
<Compile Include="CFading.cs" />
|
||||||
<Compile Include="CFont.cs" />
|
<Compile Include="CFont.cs" />
|
||||||
|
<Compile Include="Log\ShowReporterDelegate.cs" />
|
||||||
<Compile Include="Log\CLog.cs" />
|
<Compile Include="Log\CLog.cs" />
|
||||||
<Compile Include="CVideoStream.cs" />
|
<Compile Include="CVideoStream.cs" />
|
||||||
<Compile Include="Extensions.cs" />
|
<Compile Include="Extensions.cs" />
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Vocaluxe.Base;
|
using Vocaluxe.Base;
|
||||||
|
using Vocaluxe.Reporting;
|
||||||
using VocaluxeLib;
|
using VocaluxeLib;
|
||||||
using VocaluxeLib.Log;
|
using VocaluxeLib.Log;
|
||||||
using VocaluxeLib.PartyModes.Challenge;
|
using VocaluxeLib.PartyModes.Challenge;
|
||||||
@@ -47,7 +48,7 @@ namespace VocaluxeTests
|
|||||||
public void TestRoundGeneration()
|
public void TestRoundGeneration()
|
||||||
{
|
{
|
||||||
CBase.Game = new CBGame();
|
CBase.Game = new CBGame();
|
||||||
CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.GetFullVersionText());
|
CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.GetFullVersionText(), CReporter.ShowReporterFunc);
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
for (int numPlayer = 1; numPlayer <= 20; numPlayer++)
|
for (int numPlayer = 1; numPlayer <= 20; numPlayer++)
|
||||||
|
|||||||
Reference in new issue
Block a user