예제 #1
0
        private async static void OnDebugMessage(object sender, EventArgs e)
        {
            DebugMessage debug = new DebugMessage(logger.GetLog(), proxy.GetLog());

            if (Control.ModifierKeys == Keys.Shift)
            {
                var dialog = new SaveFileDialog()
                {
                    Filter   = "Log Files (*.log)|*.log",
                    FileName = string.Format("usbhelperlauncher_{0:yyyy-MM-dd_HH-mm-ss}.log", DateTime.Now)
                };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    File.WriteAllText(dialog.FileName, await debug.Build());
                }
                return;
            }
            Clipboard.SetText(await debug.PublishAsync());
            MessageBox.Show("Debug message created and published, the link has been stored in your clipboard.\nProvide this link when reporting an issue.", "Debug message", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
예제 #2
0
        public static async Task GenerateDebugLog()
        {
            DebugMessage debug = new DebugMessage(Logger.GetLog(), Proxy.GetLog());

            async Task toFile()
            {
                var dialog = new SaveFileDialog()
                {
                    Filter   = "Log Files (*.log)|*.log",
                    FileName = string.Format("usbhelperlauncher_{0:yyyy-MM-dd_HH-mm-ss}.log", DateTime.Now)
                };

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    File.WriteAllText(dialog.FileName, await debug.Build());
                }
            }

            if (Control.ModifierKeys == Keys.Shift)
            {
                await toFile();

                return;
            }

            try
            {
                var url = await debug.PublishAsync(timeout : TimeSpan.FromSeconds(5));

                Dispatcher.Invoke(new Action(() => Clipboard.SetText(url)));
                MessageBox.Show("Debug message created and published, the link has been stored in your clipboard.\nProvide this link when reporting an issue.", "Debug message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex) when(ex is HttpRequestException || ex is JsonReaderException || ex is TaskCanceledException)
            {
                Logger.WriteLine("Could not submit log to Hastebin: {0}", ex);
                await toFile();
            }
        }