- Improved debugging for login
- Add warning when in Verbose logging mode - Settings: don't try to re-save settings which haven't changed - Remove unused logging config
This commit is contained in:
parent
bfd494cf93
commit
0ce4faaf29
@ -30,9 +30,9 @@ namespace AaxDecrypter
|
|||||||
bool Step1_CreateDir();
|
bool Step1_CreateDir();
|
||||||
bool Step2_GetMetadata();
|
bool Step2_GetMetadata();
|
||||||
bool Step3_DownloadAndCombine();
|
bool Step3_DownloadAndCombine();
|
||||||
bool Step5_CreateCue();
|
bool Step4_CreateCue();
|
||||||
bool Step6_CreateNfo();
|
bool Step5_CreateNfo();
|
||||||
bool Step7_Cleanup();
|
bool Step6_Cleanup();
|
||||||
}
|
}
|
||||||
public class AaxcDownloadConverter : IAdvancedAaxcToM4bConverter
|
public class AaxcDownloadConverter : IAdvancedAaxcToM4bConverter
|
||||||
{
|
{
|
||||||
@ -81,9 +81,9 @@ namespace AaxDecrypter
|
|||||||
["Step 1: Create Dir"] = Step1_CreateDir,
|
["Step 1: Create Dir"] = Step1_CreateDir,
|
||||||
["Step 2: Get Aaxc Metadata"] = Step2_GetMetadata,
|
["Step 2: Get Aaxc Metadata"] = Step2_GetMetadata,
|
||||||
["Step 3: Download Decrypted Audiobook"] = Step3_DownloadAndCombine,
|
["Step 3: Download Decrypted Audiobook"] = Step3_DownloadAndCombine,
|
||||||
["Step 5: Create Cue"] = Step5_CreateCue,
|
["Step 4: Create Cue"] = Step4_CreateCue,
|
||||||
["Step 6: Create Nfo"] = Step6_CreateNfo,
|
["Step 5: Create Nfo"] = Step5_CreateNfo,
|
||||||
["Step 7: Cleanup"] = Step7_Cleanup,
|
["Step 6: Cleanup"] = Step6_Cleanup,
|
||||||
};
|
};
|
||||||
|
|
||||||
downloadLicense = dlLic;
|
downloadLicense = dlLic;
|
||||||
@ -216,7 +216,7 @@ namespace AaxDecrypter
|
|||||||
DecryptProgressUpdate?.Invoke(this, (int)progressPercent);
|
DecryptProgressUpdate?.Invoke(this, (int)progressPercent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Step5_CreateCue()
|
public bool Step4_CreateCue()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -224,12 +224,12 @@ namespace AaxDecrypter
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Serilog.Log.Logger.Error(ex, $"{nameof(Step5_CreateCue)}. FAILED");
|
Serilog.Log.Logger.Error(ex, $"{nameof(Step4_CreateCue)}. FAILED");
|
||||||
}
|
}
|
||||||
return !isCanceled;
|
return !isCanceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Step6_CreateNfo()
|
public bool Step5_CreateNfo()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -237,12 +237,12 @@ namespace AaxDecrypter
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Serilog.Log.Logger.Error(ex, $"{nameof(Step6_CreateNfo)}. FAILED");
|
Serilog.Log.Logger.Error(ex, $"{nameof(Step5_CreateNfo)}. FAILED");
|
||||||
}
|
}
|
||||||
return !isCanceled;
|
return !isCanceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Step7_Cleanup()
|
public bool Step6_Cleanup()
|
||||||
{
|
{
|
||||||
FileExt.SafeDelete(jsonDownloadState);
|
FileExt.SafeDelete(jsonDownloadState);
|
||||||
FileExt.SafeDelete(tempFile);
|
FileExt.SafeDelete(tempFile);
|
||||||
|
|||||||
@ -35,7 +35,7 @@ namespace ApplicationServices
|
|||||||
}
|
}
|
||||||
catch (AudibleApi.Authentication.LoginFailedException lfEx)
|
catch (AudibleApi.Authentication.LoginFailedException lfEx)
|
||||||
{
|
{
|
||||||
lfEx.MoveResponseBodyFile(FileManager.Configuration.Instance.LibationFiles);
|
lfEx.SaveFiles(FileManager.Configuration.Instance.LibationFiles);
|
||||||
|
|
||||||
// nuget Serilog.Exceptions would automatically log custom properties
|
// nuget Serilog.Exceptions would automatically log custom properties
|
||||||
// However, it comes with a scary warning when used with EntityFrameworkCore which I'm not yet ready to implement:
|
// However, it comes with a scary warning when used with EntityFrameworkCore which I'm not yet ready to implement:
|
||||||
@ -46,7 +46,7 @@ namespace ApplicationServices
|
|||||||
ResponseStatusCodeNumber = (int)lfEx.ResponseStatusCode,
|
ResponseStatusCodeNumber = (int)lfEx.ResponseStatusCode,
|
||||||
ResponseStatusCodeDesc = lfEx.ResponseStatusCode,
|
ResponseStatusCodeDesc = lfEx.ResponseStatusCode,
|
||||||
lfEx.ResponseInputFields,
|
lfEx.ResponseInputFields,
|
||||||
lfEx.ResponseBodyFilePath
|
lfEx.ResponseBodyFilePaths
|
||||||
});
|
});
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,8 +100,13 @@ namespace FileManager
|
|||||||
lock (locker)
|
lock (locker)
|
||||||
{
|
{
|
||||||
var jObject = readFile();
|
var jObject = readFile();
|
||||||
|
var startContents = JsonConvert.SerializeObject(jObject, Formatting.Indented);
|
||||||
|
|
||||||
jObject[propertyName] = newValue;
|
jObject[propertyName] = newValue;
|
||||||
File.WriteAllText(Filepath, JsonConvert.SerializeObject(jObject, Formatting.Indented));
|
var endContents = JsonConvert.SerializeObject(jObject, Formatting.Indented);
|
||||||
|
|
||||||
|
if (startContents != endContents)
|
||||||
|
File.WriteAllText(Filepath, endContents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,12 +117,15 @@ namespace FileManager
|
|||||||
{
|
{
|
||||||
var jObject = readFile();
|
var jObject = readFile();
|
||||||
var token = jObject.SelectToken(jsonPath);
|
var token = jObject.SelectToken(jsonPath);
|
||||||
var debug_oldValue = (string)token[propertyName];
|
var oldValue = (string)token[propertyName];
|
||||||
|
|
||||||
|
if (oldValue != newValue)
|
||||||
|
{
|
||||||
token[propertyName] = newValue;
|
token[propertyName] = newValue;
|
||||||
File.WriteAllText(Filepath, JsonConvert.SerializeObject(jObject, Formatting.Indented));
|
File.WriteAllText(Filepath, JsonConvert.SerializeObject(jObject, Formatting.Indented));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private JObject readFile()
|
private JObject readFile()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>5.1.8.2</Version>
|
<Version>5.1.9.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -4,6 +4,7 @@ using System.Linq;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using AudibleApi;
|
using AudibleApi;
|
||||||
using AudibleApi.Authorization;
|
using AudibleApi.Authorization;
|
||||||
|
using Dinah.Core.Logging;
|
||||||
using FileManager;
|
using FileManager;
|
||||||
using InternalUtilities;
|
using InternalUtilities;
|
||||||
using LibationWinForms;
|
using LibationWinForms;
|
||||||
@ -12,6 +13,7 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
using Serilog.Events;
|
||||||
|
|
||||||
namespace LibationLauncher
|
namespace LibationLauncher
|
||||||
{
|
{
|
||||||
@ -31,7 +33,6 @@ namespace LibationLauncher
|
|||||||
migrate_to_v4_0_0();
|
migrate_to_v4_0_0();
|
||||||
migrate_to_v5_0_0();
|
migrate_to_v5_0_0();
|
||||||
|
|
||||||
ensureLoggingConfig();
|
|
||||||
ensureSerilogConfig();
|
ensureSerilogConfig();
|
||||||
configureLogging();
|
configureLogging();
|
||||||
checkForUpdate();
|
checkForUpdate();
|
||||||
@ -155,7 +156,7 @@ namespace LibationLauncher
|
|||||||
// identity has likely been updated above. re-get contents
|
// identity has likely been updated above. re-get contents
|
||||||
var legacyContents = File.ReadAllText(AccountsSettingsFileLegacy30);
|
var legacyContents = File.ReadAllText(AccountsSettingsFileLegacy30);
|
||||||
|
|
||||||
var identity = AudibleApi.Authorization.Identity.FromJson(legacyContents);
|
var identity = Identity.FromJson(legacyContents);
|
||||||
|
|
||||||
if (!identity.IsValid)
|
if (!identity.IsValid)
|
||||||
return null;
|
return null;
|
||||||
@ -257,28 +258,6 @@ namespace LibationLauncher
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private static string defaultLoggingLevel { get; } = "Information";
|
|
||||||
private static void ensureLoggingConfig()
|
|
||||||
{
|
|
||||||
var config = Configuration.Instance;
|
|
||||||
|
|
||||||
if (config.GetObject("Logging") != null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// "Logging": {
|
|
||||||
// "LogLevel": {
|
|
||||||
// "Default": "Debug"
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
var loggingObj = new JObject
|
|
||||||
{
|
|
||||||
{
|
|
||||||
"LogLevel", new JObject { { "Default", defaultLoggingLevel } }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
config.SetObject("Logging", loggingObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ensureSerilogConfig()
|
private static void ensureSerilogConfig()
|
||||||
{
|
{
|
||||||
var config = Configuration.Instance;
|
var config = Configuration.Instance;
|
||||||
@ -286,13 +265,6 @@ namespace LibationLauncher
|
|||||||
if (config.GetObject("Serilog") != null)
|
if (config.GetObject("Serilog") != null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// default. for reference. output example:
|
|
||||||
// 2019-11-26 08:48:40.224 -05:00 [DBG] Begin Libation
|
|
||||||
var default_outputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}";
|
|
||||||
// with class and method info. output example:
|
|
||||||
// 2019-11-26 08:48:40.224 -05:00 [DBG] (at LibationWinForms.Program.init()) Begin Libation
|
|
||||||
var code_outputTemplate = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] (at {Caller}) {Message:lj}{NewLine}{Exception}";
|
|
||||||
|
|
||||||
// "Serilog": {
|
// "Serilog": {
|
||||||
// "MinimumLevel": "Information"
|
// "MinimumLevel": "Information"
|
||||||
// "WriteTo": [
|
// "WriteTo": [
|
||||||
@ -312,7 +284,7 @@ namespace LibationLauncher
|
|||||||
// }
|
// }
|
||||||
var serilogObj = new JObject
|
var serilogObj = new JObject
|
||||||
{
|
{
|
||||||
{ "MinimumLevel", defaultLoggingLevel },
|
{ "MinimumLevel", "Information" },
|
||||||
{ "WriteTo", new JArray
|
{ "WriteTo", new JArray
|
||||||
{
|
{
|
||||||
new JObject { {"Name", "Console" } },
|
new JObject { {"Name", "Console" } },
|
||||||
@ -325,7 +297,12 @@ namespace LibationLauncher
|
|||||||
// for this sink to work, a path must be provided. we override this below
|
// for this sink to work, a path must be provided. we override this below
|
||||||
{ "path", Path.Combine(Configuration.Instance.LibationFiles, "_Log.log") },
|
{ "path", Path.Combine(Configuration.Instance.LibationFiles, "_Log.log") },
|
||||||
{ "rollingInterval", "Month" },
|
{ "rollingInterval", "Month" },
|
||||||
{ "outputTemplate", code_outputTemplate }
|
// Serilog template formatting examples
|
||||||
|
// - default: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
|
||||||
|
// output example: 2019-11-26 08:48:40.224 -05:00 [DBG] Begin Libation
|
||||||
|
// - with class and method info: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] (at {Caller}) {Message:lj}{NewLine}{Exception}";
|
||||||
|
// output example: 2019-11-26 08:48:40.224 -05:00 [DBG] (at LibationWinForms.Program.init()) Begin Libation
|
||||||
|
{ "outputTemplate", "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] (at {Caller}) {Message:lj}{NewLine}{Exception}" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -439,12 +416,12 @@ namespace LibationLauncher
|
|||||||
{
|
{
|
||||||
Version = BuildVersion.ToString(),
|
Version = BuildVersion.ToString(),
|
||||||
|
|
||||||
LogLevel_Verbose_Enabled = Serilog.Log.Logger.IsEnabled(Serilog.Events.LogEventLevel.Verbose),
|
LogLevel_Verbose_Enabled = Log.Logger.IsVerboseEnabled(),
|
||||||
LogLevel_Debug_Enabled = Serilog.Log.Logger.IsEnabled(Serilog.Events.LogEventLevel.Debug),
|
LogLevel_Debug_Enabled = Log.Logger.IsDebugEnabled(),
|
||||||
LogLevel_Information_Enabled = Serilog.Log.Logger.IsEnabled(Serilog.Events.LogEventLevel.Information),
|
LogLevel_Information_Enabled = Log.Logger.IsInformationEnabled(),
|
||||||
LogLevel_Warning_Enabled = Serilog.Log.Logger.IsEnabled(Serilog.Events.LogEventLevel.Warning),
|
LogLevel_Warning_Enabled = Log.Logger.IsWarningEnabled(),
|
||||||
LogLevel_Error_Enabled = Serilog.Log.Logger.IsEnabled(Serilog.Events.LogEventLevel.Error),
|
LogLevel_Error_Enabled = Log.Logger.IsErrorEnabled(),
|
||||||
LogLevel_Fatal_Enabled = Serilog.Log.Logger.IsEnabled(Serilog.Events.LogEventLevel.Fatal),
|
LogLevel_Fatal_Enabled = Log.Logger.IsFatalEnabled(),
|
||||||
|
|
||||||
config.LibationFiles,
|
config.LibationFiles,
|
||||||
AudibleFileStorage.BooksDirectory,
|
AudibleFileStorage.BooksDirectory,
|
||||||
@ -460,6 +437,20 @@ namespace LibationLauncher
|
|||||||
DecryptInProgressDir = AudibleFileStorage.DecryptInProgress,
|
DecryptInProgressDir = AudibleFileStorage.DecryptInProgress,
|
||||||
DecryptInProgressFiles = Directory.EnumerateFiles(AudibleFileStorage.DecryptInProgress).Count(),
|
DecryptInProgressFiles = Directory.EnumerateFiles(AudibleFileStorage.DecryptInProgress).Count(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// when turning on debug (and especially Verbose) to share logs, some privacy settings may not be obscured
|
||||||
|
if (Log.Logger.IsVerboseEnabled())
|
||||||
|
MessageBox.Show(@"
|
||||||
|
Warning: verbose logging is enabled.
|
||||||
|
|
||||||
|
This should be used for debugging only. It creates many
|
||||||
|
more logs and debug files, neither of which are as
|
||||||
|
strictly anonomous.
|
||||||
|
|
||||||
|
When you are finished debugging, it's highly recommended
|
||||||
|
to set your debug MinimumLevel to Information and restart
|
||||||
|
Libation.
|
||||||
|
".Trim(), "Verbose logging enabled", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Version BuildVersion => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
private static Version BuildVersion => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user