Improved logging for file decrypt
This commit is contained in:
parent
1cecd4ba2e
commit
57bc74cd23
@ -8,7 +8,13 @@ namespace LibationWinForm.BookLiberation
|
|||||||
{
|
{
|
||||||
public partial class DecryptForm : Form
|
public partial class DecryptForm : Form
|
||||||
{
|
{
|
||||||
public DecryptForm()
|
class SerilogTextWriter : System.IO.TextWriter
|
||||||
|
{
|
||||||
|
public override System.Text.Encoding Encoding => System.Text.Encoding.ASCII;
|
||||||
|
public override void WriteLine(string value) => Serilog.Log.Logger.Debug(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecryptForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
@ -18,7 +24,7 @@ namespace LibationWinForm.BookLiberation
|
|||||||
{
|
{
|
||||||
// redirect Console.WriteLine to console, textbox
|
// redirect Console.WriteLine to console, textbox
|
||||||
var controlWriter = new RichTextBoxTextWriter(this.rtbLog);
|
var controlWriter = new RichTextBoxTextWriter(this.rtbLog);
|
||||||
var multiLogger = new MultiTextWriter(origOut, controlWriter);
|
var multiLogger = new MultiTextWriter(origOut, controlWriter, new SerilogTextWriter());
|
||||||
Console.SetOut(multiLogger);
|
Console.SetOut(multiLogger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,19 +63,6 @@ namespace LibationWinForm.BookLiberation
|
|||||||
public void SetCoverImage(byte[] coverBytes)
|
public void SetCoverImage(byte[] coverBytes)
|
||||||
=> pictureBox1.UIThread(() => pictureBox1.Image = ImageReader.ToImage(coverBytes));
|
=> pictureBox1.UIThread(() => pictureBox1.Image = ImageReader.ToImage(coverBytes));
|
||||||
|
|
||||||
public void AppendError(Exception ex)
|
|
||||||
{
|
|
||||||
Serilog.Log.Logger.Error(ex, "Decrypt form: error");
|
|
||||||
appendText("ERROR: " + ex.Message);
|
|
||||||
}
|
|
||||||
public void AppendText(string text)
|
|
||||||
{
|
|
||||||
Serilog.Log.Logger.Debug($"Decrypt form: {text}");
|
|
||||||
appendText(text);
|
|
||||||
}
|
|
||||||
private void appendText(string text) => Console.WriteLine($"{DateTime.Now} {text}");
|
|
||||||
|
|
||||||
|
|
||||||
public void UpdateProgress(int percentage) => progressBar1.UIThread(() => progressBar1.Value = percentage);
|
public void UpdateProgress(int percentage) => progressBar1.UIThread(() => progressBar1.Value = percentage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -109,8 +109,20 @@ namespace LibationWinForm
|
|||||||
.Select(sp => sp.Book)
|
.Select(sp => sp.Book)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
setBookBackupCounts(books);
|
// will often fail once if book has been moved while libation is closed. just retry once for now
|
||||||
setPdfBackupCounts(books);
|
// fix actual issue later
|
||||||
|
// FilePathCache.GetPath() :: inMemoryCache.SingleOrDefault(i => i.Id == id && i.FileType == type)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
setBookBackupCounts(books);
|
||||||
|
setPdfBackupCounts(books);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
System.Threading.Thread.Sleep(100);
|
||||||
|
setBookBackupCounts(books);
|
||||||
|
setPdfBackupCounts(books);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
enum AudioFileState { full, aax, none }
|
enum AudioFileState { full, aax, none }
|
||||||
private void setBookBackupCounts(IEnumerable<Book> books)
|
private void setBookBackupCounts(IEnumerable<Book> books)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user