From 4f289d838adca9c0851bcdf9f3166f9b754d5e20 Mon Sep 17 00:00:00 2001 From: Robin Date: Mon, 26 Dec 2016 20:32:06 +0100 Subject: [PATCH] BUG-2079: Small changes for the bug, to help to track the issue. [skip ci] --- GreenshotJiraPlugin/JiraConnector.cs | 1 + GreenshotJiraPlugin/JiraPlugin.cs | 30 +++++++++++++++++++++-- GreenshotPlugin/Core/CredentialsHelper.cs | 10 ++++---- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/GreenshotJiraPlugin/JiraConnector.cs b/GreenshotJiraPlugin/JiraConnector.cs index 16f96e027..ee9e98a2f 100644 --- a/GreenshotJiraPlugin/JiraConnector.cs +++ b/GreenshotJiraPlugin/JiraConnector.cs @@ -159,6 +159,7 @@ namespace GreenshotJiraPlugin { _loggedInTime = DateTime.Now; return; } + // Login failed, confirm this try { credentialsDialog.Confirm(false); } catch (ApplicationException e) { diff --git a/GreenshotJiraPlugin/JiraPlugin.cs b/GreenshotJiraPlugin/JiraPlugin.cs index cf888d5d8..a7240293e 100644 --- a/GreenshotJiraPlugin/JiraPlugin.cs +++ b/GreenshotJiraPlugin/JiraPlugin.cs @@ -27,13 +27,14 @@ using System.Threading.Tasks; using Dapplo.Log.Facade; using GreenshotJiraPlugin.Forms; using GreenshotPlugin.Core; +using log4net; namespace GreenshotJiraPlugin { /// /// This is the JiraPlugin base code /// public class JiraPlugin : IGreenshotPlugin { - private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(JiraPlugin)); + private static readonly ILog Log = LogManager.GetLogger(typeof(JiraPlugin)); private JiraConfiguration _config; private static JiraPlugin _instance; private JiraConnector _jiraConnector; @@ -94,7 +95,32 @@ namespace GreenshotJiraPlugin { public bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) { // Register configuration (don't need the configuration itself) _config = IniConfig.GetIniSection(); - LogSettings.RegisterDefaultLogger(); + + // Make sure the loggin is enable for the corect level. + if (Log.IsDebugEnabled) + { + LogSettings.RegisterDefaultLogger(LogLevels.Verbose); + } + else if (Log.IsInfoEnabled) + { + LogSettings.RegisterDefaultLogger(LogLevels.Info); + } + else if (Log.IsWarnEnabled) + { + LogSettings.RegisterDefaultLogger(LogLevels.Warn); + } + else if (Log.IsErrorEnabled) + { + LogSettings.RegisterDefaultLogger(LogLevels.Error); + } + else if (Log.IsErrorEnabled) + { + LogSettings.RegisterDefaultLogger(LogLevels.Error); + } + else + { + LogSettings.RegisterDefaultLogger(LogLevels.Fatal); + } // Add a SVG converter, although it doesn't fit to the Jira plugin there is currently no other way ImageHelper.StreamConverters["svg"] = (stream, s) => diff --git a/GreenshotPlugin/Core/CredentialsHelper.cs b/GreenshotPlugin/Core/CredentialsHelper.cs index bffce88e5..a031b5922 100644 --- a/GreenshotPlugin/Core/CredentialsHelper.cs +++ b/GreenshotPlugin/Core/CredentialsHelper.cs @@ -322,17 +322,17 @@ namespace GreenshotPlugin.Core { /// Confirmation action to be applied. /// True if the credentials should be persisted. - public void Confirm(bool value) { - switch (CredUi.CredUIConfirmCredentials(Target, value)) { + public void Confirm(bool value) + { + var confirmResult = CredUi.CredUIConfirmCredentials(Target, value); + switch (confirmResult) { case CredUi.ReturnCodes.NO_ERROR: break; - case CredUi.ReturnCodes.ERROR_INVALID_PARAMETER: // for some reason, this is encountered when credentials are overwritten break; - default: - throw new ApplicationException("Credential confirmation failed."); + throw new ApplicationException($"Credential confirmation failed: {confirmResult}"); } }