improved logging: at startup, config changes, library counts
better starting instructions to liberate library
This commit is contained in:
parent
d9e0f1aedf
commit
c7c1b4505b
@ -64,7 +64,34 @@ namespace FileManager
|
||||
// set cache
|
||||
stringCache[propertyName] = newValue;
|
||||
|
||||
// set in file
|
||||
writeFile(propertyName, newValue);
|
||||
}
|
||||
|
||||
public void Set(string propertyName, object newValue)
|
||||
{
|
||||
// set cache
|
||||
objectCache[propertyName] = newValue;
|
||||
|
||||
var parsedNewValue = JToken.Parse(JsonConvert.SerializeObject(newValue));
|
||||
writeFile(propertyName, parsedNewValue);
|
||||
}
|
||||
|
||||
private void writeFile(string propertyName, JToken newValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
var str = newValue?.ToString();
|
||||
var formattedValue
|
||||
= str is null ? "[null]"
|
||||
: string.IsNullOrEmpty(str) ? "[empty]"
|
||||
: string.IsNullOrWhiteSpace(str) ? $"[whitespace. Length={str.Length}]"
|
||||
: str.Length > 100 ? $"[Length={str.Length}] {str[0..50]}...{str[^50..^0]}"
|
||||
: str;
|
||||
Serilog.Log.Logger.Information($"Config changed. {propertyName}={formattedValue}");
|
||||
}
|
||||
catch { }
|
||||
|
||||
// write new setting to file
|
||||
lock (locker)
|
||||
{
|
||||
var jObject = readFile();
|
||||
@ -73,20 +100,7 @@ namespace FileManager
|
||||
}
|
||||
}
|
||||
|
||||
public void Set(string propertyName, object newValue)
|
||||
{
|
||||
// set cache
|
||||
objectCache[propertyName] = newValue;
|
||||
|
||||
// set in file
|
||||
lock (locker)
|
||||
{
|
||||
var jObject = readFile();
|
||||
jObject[propertyName] = JToken.Parse(JsonConvert.SerializeObject(newValue));
|
||||
File.WriteAllText(Filepath, JsonConvert.SerializeObject(jObject, Formatting.Indented));
|
||||
}
|
||||
}
|
||||
|
||||
// special case: no caching. no logging
|
||||
public void SetWithJsonPath(string jsonPath, string propertyName, string newValue)
|
||||
{
|
||||
lock (locker)
|
||||
@ -94,6 +108,7 @@ namespace FileManager
|
||||
var jObject = readFile();
|
||||
var token = jObject.SelectToken(jsonPath);
|
||||
var debug_oldValue = (string)token[propertyName];
|
||||
|
||||
token[propertyName] = newValue;
|
||||
File.WriteAllText(Filepath, JsonConvert.SerializeObject(jObject, Formatting.Indented));
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
|
||||
<Version>3.1.0.50</Version>
|
||||
<Version>3.1.0.52</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using FileManager;
|
||||
using LibationWinForms;
|
||||
@ -191,7 +190,6 @@ namespace LibationLauncher
|
||||
//Log.Logger.Here().Debug("Begin Libation. Debug with line numbers");
|
||||
}
|
||||
|
||||
private static event Action cheating;
|
||||
private static void checkForUpdate()
|
||||
{
|
||||
try
|
||||
@ -247,8 +245,9 @@ namespace LibationLauncher
|
||||
private static void logStartupState()
|
||||
{
|
||||
Log.Logger.Information("Begin Libation");
|
||||
|
||||
Log.Logger.Information($"Version: {BuildVersion}");
|
||||
Log.Logger.Information($"LibationFiles: {Configuration.Instance.LibationFiles}");
|
||||
Log.Logger.Information($"Audible locale: {Configuration.Instance.LocaleCountryCode}");
|
||||
}
|
||||
|
||||
private static Version BuildVersion => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||
|
||||
@ -40,13 +40,15 @@
|
||||
this.welcomeLbl.AutoSize = true;
|
||||
this.welcomeLbl.Location = new System.Drawing.Point(12, 9);
|
||||
this.welcomeLbl.Name = "welcomeLbl";
|
||||
this.welcomeLbl.Size = new System.Drawing.Size(399, 78);
|
||||
this.welcomeLbl.Size = new System.Drawing.Size(399, 117);
|
||||
this.welcomeLbl.TabIndex = 0;
|
||||
this.welcomeLbl.Text = resources.GetString("welcomeLbl.Text");
|
||||
//
|
||||
// noQuestionsBtn
|
||||
//
|
||||
this.noQuestionsBtn.Location = new System.Drawing.Point(15, 90);
|
||||
this.noQuestionsBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.noQuestionsBtn.Location = new System.Drawing.Point(15, 129);
|
||||
this.noQuestionsBtn.Name = "noQuestionsBtn";
|
||||
this.noQuestionsBtn.Size = new System.Drawing.Size(396, 57);
|
||||
this.noQuestionsBtn.TabIndex = 1;
|
||||
@ -55,7 +57,9 @@
|
||||
//
|
||||
// basicBtn
|
||||
//
|
||||
this.basicBtn.Location = new System.Drawing.Point(15, 153);
|
||||
this.basicBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.basicBtn.Location = new System.Drawing.Point(15, 192);
|
||||
this.basicBtn.Name = "basicBtn";
|
||||
this.basicBtn.Size = new System.Drawing.Size(396, 57);
|
||||
this.basicBtn.TabIndex = 2;
|
||||
@ -64,7 +68,9 @@
|
||||
//
|
||||
// advancedBtn
|
||||
//
|
||||
this.advancedBtn.Location = new System.Drawing.Point(15, 216);
|
||||
this.advancedBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.advancedBtn.Location = new System.Drawing.Point(15, 255);
|
||||
this.advancedBtn.Name = "advancedBtn";
|
||||
this.advancedBtn.Size = new System.Drawing.Size(396, 57);
|
||||
this.advancedBtn.TabIndex = 3;
|
||||
@ -75,7 +81,7 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(423, 285);
|
||||
this.ClientSize = new System.Drawing.Size(423, 324);
|
||||
this.Controls.Add(this.advancedBtn);
|
||||
this.Controls.Add(this.basicBtn);
|
||||
this.Controls.Add(this.noQuestionsBtn);
|
||||
|
||||
@ -123,6 +123,9 @@
|
||||
Please fill in a few settings. You can also change these settings later.
|
||||
|
||||
After you make your selections, get started by importing your library.
|
||||
Go to Import > Scan Library</value>
|
||||
Go to Import > Scan Library
|
||||
|
||||
Download your entire library from the "Liberate" tab or
|
||||
liberate your books one at a time by clicking the stoplight</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -49,13 +49,11 @@ namespace LibationWinForms
|
||||
// also applies filter. ONLY call AFTER loading grid
|
||||
loadInitialQuickFilterState();
|
||||
|
||||
{ // init bottom counts
|
||||
// init bottom counts
|
||||
backupsCountsLbl.Text = "[Calculating backed up book quantities]";
|
||||
pdfsCountsLbl.Text = "[Calculating backed up PDFs]";
|
||||
|
||||
setBackupCounts(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
#region reload grid
|
||||
bool isProcessingGridSelect = false;
|
||||
@ -142,6 +140,7 @@ namespace LibationWinForms
|
||||
= pending > 0
|
||||
? $"{pending} remaining"
|
||||
: "All books have been liberated";
|
||||
Serilog.Log.Logger.Information(menuItemText);
|
||||
menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Enabled = pending > 0);
|
||||
menuStrip1.UIThread(() => beginBookBackupsToolStripMenuItem.Text = string.Format(beginBookBackupsToolStripMenuItem_format, menuItemText));
|
||||
}
|
||||
@ -167,6 +166,7 @@ namespace LibationWinForms
|
||||
= notDownloaded > 0
|
||||
? $"{notDownloaded} remaining"
|
||||
: "All PDFs have been downloaded";
|
||||
Serilog.Log.Logger.Information(menuItemText);
|
||||
menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Enabled = notDownloaded > 0);
|
||||
menuStrip1.UIThread(() => beginPdfBackupsToolStripMenuItem.Text = string.Format(beginPdfBackupsToolStripMenuItem_format, menuItemText));
|
||||
}
|
||||
|
||||
16
WinFormsDesigner/Dialogs/SetupDialog.Designer.cs
generated
16
WinFormsDesigner/Dialogs/SetupDialog.Designer.cs
generated
@ -40,13 +40,15 @@
|
||||
this.welcomeLbl.AutoSize = true;
|
||||
this.welcomeLbl.Location = new System.Drawing.Point(12, 9);
|
||||
this.welcomeLbl.Name = "welcomeLbl";
|
||||
this.welcomeLbl.Size = new System.Drawing.Size(399, 78);
|
||||
this.welcomeLbl.Size = new System.Drawing.Size(399, 117);
|
||||
this.welcomeLbl.TabIndex = 0;
|
||||
this.welcomeLbl.Text = resources.GetString("welcomeLbl.Text");
|
||||
//
|
||||
// noQuestionsBtn
|
||||
//
|
||||
this.noQuestionsBtn.Location = new System.Drawing.Point(15, 90);
|
||||
this.noQuestionsBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.noQuestionsBtn.Location = new System.Drawing.Point(15, 129);
|
||||
this.noQuestionsBtn.Name = "noQuestionsBtn";
|
||||
this.noQuestionsBtn.Size = new System.Drawing.Size(396, 57);
|
||||
this.noQuestionsBtn.TabIndex = 1;
|
||||
@ -55,7 +57,9 @@
|
||||
//
|
||||
// basicBtn
|
||||
//
|
||||
this.basicBtn.Location = new System.Drawing.Point(15, 153);
|
||||
this.basicBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.basicBtn.Location = new System.Drawing.Point(15, 192);
|
||||
this.basicBtn.Name = "basicBtn";
|
||||
this.basicBtn.Size = new System.Drawing.Size(396, 57);
|
||||
this.basicBtn.TabIndex = 2;
|
||||
@ -64,7 +68,9 @@
|
||||
//
|
||||
// advancedBtn
|
||||
//
|
||||
this.advancedBtn.Location = new System.Drawing.Point(15, 216);
|
||||
this.advancedBtn.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.advancedBtn.Location = new System.Drawing.Point(15, 255);
|
||||
this.advancedBtn.Name = "advancedBtn";
|
||||
this.advancedBtn.Size = new System.Drawing.Size(396, 57);
|
||||
this.advancedBtn.TabIndex = 3;
|
||||
@ -75,7 +81,7 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(423, 285);
|
||||
this.ClientSize = new System.Drawing.Size(423, 324);
|
||||
this.Controls.Add(this.advancedBtn);
|
||||
this.Controls.Add(this.basicBtn);
|
||||
this.Controls.Add(this.noQuestionsBtn);
|
||||
|
||||
@ -123,6 +123,9 @@
|
||||
Please fill in a few settings. You can also change these settings later.
|
||||
|
||||
After you make your selections, get started by importing your library.
|
||||
Go to Import > Scan Library</value>
|
||||
Go to Import > Scan Library
|
||||
|
||||
Download your entire library from the "Liberate" tab or
|
||||
liberate your books one at a time by clicking the stoplight</value>
|
||||
</data>
|
||||
</root>
|
||||
Loading…
x
Reference in New Issue
Block a user