summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF
diff options
context:
space:
mode:
authorsr55 <[email protected]>2018-05-08 21:31:26 +0100
committersr55 <[email protected]>2018-05-08 21:31:26 +0100
commita6f3cd670f492a3474bf4695f1a8a6302fc3ed56 (patch)
treef862920629c676c23d095da6e9cb2877bb1f413d /win/CS/HandBrakeWPF
parent1a16ebead7e49a214276859f53ce18a0c844f102 (diff)
WinGui: Remove Logging abstraction from the Services library. Let the library consumers decide how to log instead utilising the log events instead.
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r--win/CS/HandBrakeWPF/HandBrakeWPF.csproj6
-rw-r--r--win/CS/HandBrakeWPF/Helpers/LogManager.cs6
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs4
-rw-r--r--win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs7
-rw-r--r--win/CS/HandBrakeWPF/Services/Logging/EventArgs/LogEventArgs.cs37
-rw-r--r--win/CS/HandBrakeWPF/Services/Logging/Interfaces/ILog.cs88
-rw-r--r--win/CS/HandBrakeWPF/Services/Logging/LogService.cs395
-rw-r--r--win/CS/HandBrakeWPF/Services/Logging/Model/LogLevel.cs42
-rw-r--r--win/CS/HandBrakeWPF/Services/Logging/Model/LogMessage.cs61
-rw-r--r--win/CS/HandBrakeWPF/Services/Logging/Model/LogMessageType.cs22
-rw-r--r--win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs5
-rw-r--r--win/CS/HandBrakeWPF/Services/Scan/LibScan.cs7
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs9
-rw-r--r--win/CS/HandBrakeWPF/Views/LogView.xaml.cs3
14 files changed, 673 insertions, 19 deletions
diff --git a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
index cd1fdcfa2..4757f7eec 100644
--- a/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
+++ b/win/CS/HandBrakeWPF/HandBrakeWPF.csproj
@@ -209,6 +209,12 @@
<Compile Include="Services\Encode\Model\Models\Video\VideoProfile.cs" />
<Compile Include="Services\Encode\Model\Models\Video\VideoTune.cs" />
<Compile Include="Services\Interfaces\INotifyIconService.cs" />
+ <Compile Include="Services\Logging\EventArgs\LogEventArgs.cs" />
+ <Compile Include="Services\Logging\Interfaces\ILog.cs" />
+ <Compile Include="Services\Logging\LogService.cs" />
+ <Compile Include="Services\Logging\Model\LogLevel.cs" />
+ <Compile Include="Services\Logging\Model\LogMessage.cs" />
+ <Compile Include="Services\Logging\Model\LogMessageType.cs" />
<Compile Include="Services\Presets\Factories\JsonPresetFactory.cs" />
<Compile Include="Services\Presets\Interfaces\IPresetObject.cs" />
<Compile Include="Services\Presets\Model\PresetDisplayCategory.cs" />
diff --git a/win/CS/HandBrakeWPF/Helpers/LogManager.cs b/win/CS/HandBrakeWPF/Helpers/LogManager.cs
index 2cd94a25d..ec1c11ffc 100644
--- a/win/CS/HandBrakeWPF/Helpers/LogManager.cs
+++ b/win/CS/HandBrakeWPF/Helpers/LogManager.cs
@@ -9,15 +9,15 @@
namespace HandBrakeWPF.Helpers
{
- using System;
using System.IO;
using HandBrake.ApplicationServices.Interop;
- using HandBrake.ApplicationServices.Services.Logging;
- using HandBrake.ApplicationServices.Services.Logging.Interfaces;
using HandBrakeWPF.Utilities;
+ using ILog = HandBrakeWPF.Services.Logging.Interfaces.ILog;
+ using LogService = HandBrakeWPF.Services.Logging.LogService;
+
/// <summary>
/// Tempory Class to Initialise the logging.
/// </summary>
diff --git a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
index e3a807cf9..ffc33113f 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/EncodeBase.cs
@@ -15,8 +15,6 @@ namespace HandBrakeWPF.Services.Encode
using System.IO;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Logging;
- using HandBrake.ApplicationServices.Services.Logging.Interfaces;
using HandBrakeWPF.Utilities;
@@ -26,6 +24,8 @@ namespace HandBrakeWPF.Services.Encode
using EncodeProgressEventArgs = HandBrakeWPF.Services.Encode.EventArgs.EncodeProgressEventArgs;
using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask;
using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;
+ using ILog = HandBrakeWPF.Services.Logging.Interfaces.ILog;
+ using LogService = HandBrakeWPF.Services.Logging.LogService;
/// <summary>
/// A Base Class for the Encode Services.
diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
index b6b811454..02a361ba6 100644
--- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
+++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs
@@ -18,9 +18,6 @@ namespace HandBrakeWPF.Services.Encode
using HandBrake.ApplicationServices.Interop.Interfaces;
using HandBrake.ApplicationServices.Interop.Json.State;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Logging;
- using HandBrake.ApplicationServices.Services.Logging.Interfaces;
- using HandBrake.ApplicationServices.Services.Logging.Model;
using HandBrakeWPF.Exceptions;
using HandBrakeWPF.Properties;
@@ -28,6 +25,10 @@ namespace HandBrakeWPF.Services.Encode
using EncodeTask = Model.EncodeTask;
using IEncode = Interfaces.IEncode;
+ using ILog = HandBrakeWPF.Services.Logging.Interfaces.ILog;
+ using LogLevel = HandBrakeWPF.Services.Logging.Model.LogLevel;
+ using LogMessageType = HandBrakeWPF.Services.Logging.Model.LogMessageType;
+ using LogService = HandBrakeWPF.Services.Logging.LogService;
/// <summary>
/// LibHB Implementation of IEncode
diff --git a/win/CS/HandBrakeWPF/Services/Logging/EventArgs/LogEventArgs.cs b/win/CS/HandBrakeWPF/Services/Logging/EventArgs/LogEventArgs.cs
new file mode 100644
index 000000000..121010e31
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Services/Logging/EventArgs/LogEventArgs.cs
@@ -0,0 +1,37 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="LogEventArgs.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Defines the LogEventArgs type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Services.Logging.EventArgs
+{
+ using System;
+
+ using LogMessage = HandBrakeWPF.Services.Logging.Model.LogMessage;
+
+ /// <summary>
+ /// The Message Logged Event Args
+ /// </summary>
+ public class LogEventArgs : EventArgs
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LogEventArgs"/> class.
+ /// </summary>
+ /// <param name="message">
+ /// The message.
+ /// </param>
+ public LogEventArgs(LogMessage message)
+ {
+ this.Log = message;
+ }
+
+ /// <summary>
+ /// Gets the Message.
+ /// </summary>
+ public LogMessage Log { get; private set; }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Services/Logging/Interfaces/ILog.cs b/win/CS/HandBrakeWPF/Services/Logging/Interfaces/ILog.cs
new file mode 100644
index 000000000..d0f5949a2
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Services/Logging/Interfaces/ILog.cs
@@ -0,0 +1,88 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="ILog.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Defines the ILog type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Services.Logging.Interfaces
+{
+ using System;
+ using System.Collections.Generic;
+
+ using LogEventArgs = HandBrakeWPF.Services.Logging.EventArgs.LogEventArgs;
+ using LogLevel = HandBrakeWPF.Services.Logging.Model.LogLevel;
+ using LogMessage = HandBrakeWPF.Services.Logging.Model.LogMessage;
+ using LogMessageType = HandBrakeWPF.Services.Logging.Model.LogMessageType;
+
+ /// <summary>
+ /// The Log interface.
+ /// </summary>
+ public interface ILog
+ {
+ /// <summary>
+ /// The message logged.
+ /// </summary>
+ event EventHandler<LogEventArgs> MessageLogged;
+
+ /// <summary>
+ /// The log reset event
+ /// </summary>
+ event EventHandler LogReset;
+
+ /// <summary>
+ /// Gets the log messages.
+ /// </summary>
+ IEnumerable<LogMessage> LogMessages { get; }
+
+ /// <summary>
+ /// Gets the activity log.
+ /// </summary>
+ string ActivityLog { get; }
+
+ /// <summary>
+ /// The reset.
+ /// </summary>
+ void Reset();
+
+ /// <summary>
+ /// The enable.
+ /// </summary>
+ void Enable();
+
+ /// <summary>
+ /// Log a message.
+ /// </summary>
+ /// <param name="content">
+ /// The content of the log message,
+ /// </param>
+ /// <param name="type">
+ /// The Message Type. (i.e. where it came from)
+ /// </param>
+ /// <param name="level">
+ /// The log level
+ /// </param>
+ void LogMessage(string content, LogMessageType type, LogLevel level);
+
+ /// <summary>
+ /// Enable Logging to Disk
+ /// </summary>
+ /// <param name="logFile">
+ /// The log file to write to.
+ /// </param>
+ /// <param name="deleteCurrentLogFirst">
+ /// Delete the current log file if it exists.
+ /// </param>
+ void EnableLoggingToDisk(string logFile, bool deleteCurrentLogFirst);
+
+ /// <summary>
+ /// The setup log header.
+ /// </summary>
+ /// <param name="header">
+ /// The header.
+ /// </param>
+ void SetupLogHeader(string header);
+ }
+} \ No newline at end of file
diff --git a/win/CS/HandBrakeWPF/Services/Logging/LogService.cs b/win/CS/HandBrakeWPF/Services/Logging/LogService.cs
new file mode 100644
index 000000000..70bea3067
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Services/Logging/LogService.cs
@@ -0,0 +1,395 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="LogService.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The log service.
+// For now, this is just a simple logging service but we could provide support for a formal logging library later.
+// Also, we can consider providing the UI layer with more functional logging. (i.e levels, time/date, highlighting etc)
+// The Interop Classes are not very OO friendly, so this is going to be a static class.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Services.Logging
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.IO;
+ using System.Linq;
+ using System.Text;
+
+ using HandBrake.ApplicationServices.Interop;
+ using HandBrake.ApplicationServices.Interop.EventArgs;
+
+ using ILog = Interfaces.ILog;
+ using LogEventArgs = EventArgs.LogEventArgs;
+ using LogLevel = Model.LogLevel;
+ using LogMessage = Model.LogMessage;
+ using LogMessageType = Model.LogMessageType;
+
+ /// <summary>
+ /// The log helper.
+ /// </summary>
+ public class LogService : ILog
+ {
+ // TODO List.
+ // Maybe make the event weak?
+ // Make this class Thread Safe.
+ private static ILog loggerInstance;
+ private readonly object lockObject = new object();
+ private readonly object fileWriterLock = new object();
+ private readonly StringBuilder logBuilder = new StringBuilder();
+
+ private LogLevel currentLogLevel = LogLevel.Error;
+ private bool isLoggingEnabled;
+ private List<LogMessage> logMessages = new List<LogMessage>();
+ private long messageIndex;
+ private string diskLogPath;
+ private bool deleteLogFirst;
+ private bool isDiskLoggingEnabled;
+ private StreamWriter fileWriter;
+ private string logHeader;
+
+ public LogService()
+ {
+ HandBrakeUtils.MessageLogged += this.HandBrakeUtils_MessageLogged;
+ HandBrakeUtils.ErrorLogged += this.HandBrakeUtils_ErrorLogged;
+ }
+
+ /// <summary>
+ /// Fires when a new QueueTask starts
+ /// </summary>
+ public event EventHandler<LogEventArgs> MessageLogged;
+
+ /// <summary>
+ /// The log reset event
+ /// </summary>
+ public event EventHandler LogReset;
+
+ /// <summary>
+ /// Gets the log messages.
+ /// </summary>
+ public IEnumerable<LogMessage> LogMessages
+ {
+ get
+ {
+ lock (this.lockObject)
+ {
+ return this.logMessages.ToList();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the Activity Log as a string.
+ /// </summary>
+ public string ActivityLog
+ {
+ get
+ {
+ lock (this.lockObject)
+ {
+ return this.logBuilder.ToString();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Log message.
+ /// </summary>
+ /// <param name="content">
+ /// The content.
+ /// </param>
+ /// <param name="type">
+ /// The type.
+ /// </param>
+ /// <param name="level">
+ /// The level.
+ /// </param>
+ public void LogMessage(string content, LogMessageType type, LogLevel level)
+ {
+ if (!this.isLoggingEnabled)
+ {
+ return;
+ }
+
+ if (level > this.currentLogLevel)
+ {
+ return;
+ }
+
+ LogMessage msg = new LogMessage(content, type, level, this.messageIndex);
+ lock (this.lockObject)
+ {
+ this.messageIndex = this.messageIndex + 1;
+ this.logMessages.Add(msg);
+ this.logBuilder.AppendLine(msg.Content);
+ this.LogMessageToDisk(msg);
+
+ if (this.logMessages.Count > 50000)
+ {
+ this.messageIndex = this.messageIndex + 1;
+ msg = new LogMessage(
+ "Log Service Pausing. Too Many Log messages. This may indicate a problem with your encode.",
+ LogMessageType.Application,
+ LogLevel.Error,
+ this.messageIndex);
+ this.logMessages.Add(msg);
+ this.logBuilder.AppendLine(msg.Content);
+ this.LogMessageToDisk(msg);
+
+ this.Disable();
+ }
+ }
+
+ this.OnMessageLogged(msg); // Must be outside lock to be thread safe.
+ }
+
+ /// <summary>
+ /// Gets an shared instance of the logger. Logging is enabled by default
+ /// You can turn it off by calling Disable() if you don't want it.
+ /// </summary>
+ /// <returns>
+ /// An instance of this logger.
+ /// </returns>
+ public static ILog GetLogger()
+ {
+ return loggerInstance ?? (loggerInstance = new LogService());
+ }
+
+ /// <summary>
+ /// The set log level. Default: Info.
+ /// </summary>
+ /// <param name="level">
+ /// The level.
+ /// </param>
+ public void SetLogLevel(LogLevel level)
+ {
+ this.currentLogLevel = level;
+ }
+
+ /// <summary>
+ /// The enable.
+ /// </summary>
+ public void Enable()
+ {
+ this.isLoggingEnabled = true;
+ }
+
+ /// <summary>
+ /// Enable Logging to Disk
+ /// </summary>
+ /// <param name="logFile">
+ /// The log file to write to.
+ /// </param>
+ /// <param name="deleteCurrentLogFirst">
+ /// Delete the current log file if it exists.
+ /// </param>
+ public void EnableLoggingToDisk(string logFile, bool deleteCurrentLogFirst)
+ {
+ if (this.isDiskLoggingEnabled)
+ {
+ throw new Exception("Disk Logging already enabled!");
+ }
+
+ try
+ {
+ if (!Directory.Exists(Path.GetDirectoryName(logFile)))
+ {
+ throw new Exception("Log Directory does not exist. This service will not create it for you!");
+ }
+
+ if (deleteCurrentLogFirst && File.Exists(logFile))
+ {
+ File.Delete(logFile);
+ }
+
+ this.diskLogPath = logFile;
+ this.isDiskLoggingEnabled = true;
+ this.deleteLogFirst = deleteCurrentLogFirst;
+
+ lock (this.fileWriterLock)
+ {
+ this.fileWriter = new StreamWriter(logFile) { AutoFlush = true };
+ }
+ }
+ catch (Exception exc)
+ {
+ this.LogMessage("Failed to Initialise Disk Logging. " + Environment.NewLine + exc, LogMessageType.Application, LogLevel.Error);
+
+ if (this.fileWriter != null)
+ {
+ lock (this.fileWriterLock)
+ {
+ this.fileWriter.Flush();
+ this.fileWriter.Close();
+ this.fileWriter.Dispose();
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// The setup log header.
+ /// </summary>
+ /// <param name="header">
+ /// The header.
+ /// </param>
+ public void SetupLogHeader(string header)
+ {
+ this.logHeader = header;
+ this.LogMessage(header, LogMessageType.Application, LogLevel.Info);
+ }
+
+ /// <summary>
+ /// The disable.
+ /// </summary>
+ public void Disable()
+ {
+ this.isLoggingEnabled = false;
+ }
+
+ /// <summary>
+ /// Clear the log messages collection.
+ /// </summary>
+ public void Reset()
+ {
+ lock (this.lockObject)
+ {
+ this.logMessages.Clear();
+ this.logBuilder.Clear();
+ this.messageIndex = 0;
+
+ try
+ {
+ lock (this.fileWriterLock)
+ {
+ if (this.fileWriter != null)
+ {
+ this.fileWriter.Flush();
+ this.fileWriter.Close();
+ this.fileWriter.Dispose();
+ }
+
+ this.fileWriter = null;
+ }
+ }
+ catch (Exception exc)
+ {
+ Debug.WriteLine(exc);
+ }
+
+ if (this.fileWriter == null)
+ {
+ this.isDiskLoggingEnabled = false;
+ this.EnableLoggingToDisk(this.diskLogPath, this.deleteLogFirst);
+ }
+
+ if (!string.IsNullOrEmpty(this.logHeader))
+ {
+ this.SetupLogHeader(this.logHeader);
+ }
+
+ this.OnLogReset();
+ }
+ }
+
+ /// <summary>
+ /// Called when a log message is created.
+ /// </summary>
+ /// <param name="msg">
+ /// The Log Message
+ /// </param>
+ protected virtual void OnMessageLogged(LogMessage msg)
+ {
+ var onMessageLogged = this.MessageLogged;
+ if (onMessageLogged != null)
+ {
+ onMessageLogged.Invoke(this, new LogEventArgs(msg));
+ }
+ }
+
+ /// <summary>
+ /// Shutdown and Dispose of the File Writer.
+ /// </summary>
+ protected void ShutdownFileWriter()
+ {
+ try
+ {
+ lock (this.fileWriterLock)
+ {
+ if (this.fileWriter != null)
+ {
+ this.fileWriter.Flush();
+ this.fileWriter.Close();
+ this.fileWriter.Dispose();
+ }
+
+ this.fileWriter = null;
+ }
+ }
+ catch (Exception exc)
+ {
+ Debug.WriteLine(exc); // This exception doesn't warrant user interaction, but it should be logged
+ }
+ }
+
+ /// <summary>
+ /// Trigger the Event to notify any subscribers that the log has been reset.
+ /// </summary>
+ protected virtual void OnLogReset()
+ {
+ this.LogReset?.Invoke(this, System.EventArgs.Empty);
+ }
+
+ /// <summary>
+ /// Helper method for logging content to disk
+ /// </summary>
+ /// <param name="msg">
+ /// Log message to write.
+ /// </param>
+ private void LogMessageToDisk(LogMessage msg)
+ {
+ if (!this.isDiskLoggingEnabled)
+ {
+ return;
+ }
+
+ try
+ {
+ lock (this.fileWriterLock)
+ {
+ if (this.fileWriter != null && this.fileWriter.BaseStream.CanWrite)
+ {
+ this.fileWriter.WriteLine(msg.Content);
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ Debug.WriteLine(exc); // This exception doesn't warrant user interaction, but it should be logged
+ }
+ }
+
+ private void HandBrakeUtils_ErrorLogged(object sender, MessageLoggedEventArgs e)
+ {
+ if (e == null || string.IsNullOrEmpty(e.Message))
+ {
+ return;
+ }
+
+ this.LogMessage(e.Message, LogMessageType.ScanOrEncode, LogLevel.Error);
+ }
+
+ private void HandBrakeUtils_MessageLogged(object sender, MessageLoggedEventArgs e)
+ {
+ if (e == null || string.IsNullOrEmpty(e.Message))
+ {
+ return;
+ }
+
+ this.LogMessage(e.Message, LogMessageType.ScanOrEncode, LogLevel.Info);
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Services/Logging/Model/LogLevel.cs b/win/CS/HandBrakeWPF/Services/Logging/Model/LogLevel.cs
new file mode 100644
index 000000000..07f35e304
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Services/Logging/Model/LogLevel.cs
@@ -0,0 +1,42 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="LogLevel.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The log level.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Services.Logging.Model
+{
+ /// <summary>
+ /// The log level.
+ /// </summary>
+ public enum LogLevel
+ {
+ /// <summary>
+ /// The info.
+ /// </summary>
+ Info,
+
+ /// <summary>
+ /// The warning.
+ /// </summary>
+ Warning,
+
+ /// <summary>
+ /// The error.
+ /// </summary>
+ Error,
+
+ /// <summary>
+ /// The debug.
+ /// </summary>
+ Debug,
+
+ /// <summary>
+ /// Trace Level Logging.
+ /// </summary>
+ Trace,
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Services/Logging/Model/LogMessage.cs b/win/CS/HandBrakeWPF/Services/Logging/Model/LogMessage.cs
new file mode 100644
index 000000000..7fa98d1d2
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Services/Logging/Model/LogMessage.cs
@@ -0,0 +1,61 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="LogMessage.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The message.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Services.Logging.Model
+{
+ /// <summary>
+ /// An Immutable Log Entry.
+ /// </summary>
+ public class LogMessage
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LogMessage"/> class.
+ /// </summary>
+ /// <param name="content">
+ /// The content.
+ /// </param>
+ /// <param name="messageType">
+ /// The message type.
+ /// </param>
+ /// <param name="logLevel">
+ /// The log level.
+ /// </param>
+ /// <param name="messageIndex">
+ /// The message Index.
+ /// </param>
+ public LogMessage(string content, LogMessageType messageType, LogLevel logLevel, long messageIndex)
+ {
+ this.Content = content;
+ this.MessageType = messageType;
+ this.LogLevel = logLevel;
+ this.MessageIndex = messageIndex;
+ }
+
+ /// <summary>
+ /// Gets the content.
+ /// </summary>
+ public string Content { get; private set; }
+
+ /// <summary>
+ /// Gets a value indicating whether this message was generated by the GUI.
+ /// If false, it was provided by libhb.
+ /// </summary>
+ public HandBrakeWPF.Services.Logging.Model.LogMessageType MessageType { get; private set; }
+
+ /// <summary>
+ /// Gets the log level.
+ /// </summary>
+ public HandBrakeWPF.Services.Logging.Model.LogLevel LogLevel { get; private set; }
+
+ /// <summary>
+ /// Gets the message index.
+ /// </summary>
+ public long MessageIndex { get; private set; }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Services/Logging/Model/LogMessageType.cs b/win/CS/HandBrakeWPF/Services/Logging/Model/LogMessageType.cs
new file mode 100644
index 000000000..7c50267fb
--- /dev/null
+++ b/win/CS/HandBrakeWPF/Services/Logging/Model/LogMessageType.cs
@@ -0,0 +1,22 @@
+// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="LogMessageType.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// The log message type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Services.Logging.Model
+{
+ /// <summary>
+ /// The log message type.
+ /// </summary>
+ public enum LogMessageType
+ {
+ ScanOrEncode,
+ API,
+ Progress,
+ Application,
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
index 098e9201a..9cf9b1320 100644
--- a/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
+++ b/win/CS/HandBrakeWPF/Services/Queue/QueueProcessor.cs
@@ -17,8 +17,6 @@ namespace HandBrakeWPF.Services.Queue
using System.Xml.Serialization;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Logging;
- using HandBrake.ApplicationServices.Services.Logging.Model;
using HandBrake.ApplicationServices.Utilities;
using HandBrakeWPF.Factories;
@@ -33,6 +31,9 @@ namespace HandBrakeWPF.Services.Queue
using Execute = Caliburn.Micro.Execute;
using GeneralApplicationException = HandBrakeWPF.Exceptions.GeneralApplicationException;
using IEncode = HandBrakeWPF.Services.Encode.Interfaces.IEncode;
+ using LogLevel = HandBrakeWPF.Services.Logging.Model.LogLevel;
+ using LogMessageType = HandBrakeWPF.Services.Logging.Model.LogMessageType;
+ using LogService = HandBrakeWPF.Services.Logging.LogService;
using QueueCompletedEventArgs = HandBrakeWPF.EventArgs.QueueCompletedEventArgs;
using QueueProgressEventArgs = HandBrakeWPF.EventArgs.QueueProgressEventArgs;
diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
index bb2703903..14b13d2e4 100644
--- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
+++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
@@ -22,9 +22,6 @@ namespace HandBrakeWPF.Services.Scan
using HandBrake.ApplicationServices.Interop.Model.Encoding;
using HandBrake.ApplicationServices.Interop.Model.Preview;
using HandBrake.ApplicationServices.Model;
- using HandBrake.ApplicationServices.Services.Logging;
- using HandBrake.ApplicationServices.Services.Logging.Interfaces;
- using HandBrake.ApplicationServices.Services.Logging.Model;
using HandBrakeWPF.Services.Encode.Model;
using HandBrakeWPF.Services.Encode.Model.Models;
@@ -34,6 +31,10 @@ namespace HandBrakeWPF.Services.Scan
using HandBrakeWPF.Utilities;
using Chapter = HandBrakeWPF.Services.Scan.Model.Chapter;
+ using ILog = HandBrakeWPF.Services.Logging.Interfaces.ILog;
+ using LogLevel = HandBrakeWPF.Services.Logging.Model.LogLevel;
+ using LogMessageType = HandBrakeWPF.Services.Logging.Model.LogMessageType;
+ using LogService = HandBrakeWPF.Services.Logging.LogService;
using ScanProgressEventArgs = HandBrake.ApplicationServices.Interop.EventArgs.ScanProgressEventArgs;
using Subtitle = HandBrakeWPF.Services.Scan.Model.Subtitle;
using Title = HandBrakeWPF.Services.Scan.Model.Title;
diff --git a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs
index 3fcb4c96c..6573b1f5a 100644
--- a/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/LogViewModel.cs
@@ -16,14 +16,13 @@ namespace HandBrakeWPF.ViewModels
using Caliburn.Micro;
- using HandBrake.ApplicationServices.Services.Logging;
- using HandBrake.ApplicationServices.Services.Logging.EventArgs;
- using HandBrake.ApplicationServices.Services.Logging.Model;
-
using HandBrakeWPF.Utilities;
using HandBrakeWPF.ViewModels.Interfaces;
- using ILog = HandBrake.ApplicationServices.Services.Logging.Interfaces.ILog;
+ using ILog = HandBrakeWPF.Services.Logging.Interfaces.ILog;
+ using LogEventArgs = HandBrakeWPF.Services.Logging.EventArgs.LogEventArgs;
+ using LogMessage = HandBrakeWPF.Services.Logging.Model.LogMessage;
+ using LogService = HandBrakeWPF.Services.Logging.LogService;
/// <summary>
/// The Log View Model
diff --git a/win/CS/HandBrakeWPF/Views/LogView.xaml.cs b/win/CS/HandBrakeWPF/Views/LogView.xaml.cs
index 67d2f21df..096032a04 100644
--- a/win/CS/HandBrakeWPF/Views/LogView.xaml.cs
+++ b/win/CS/HandBrakeWPF/Views/LogView.xaml.cs
@@ -14,6 +14,7 @@ namespace HandBrakeWPF.Views
using System.Windows;
using System.Windows.Controls;
+ using HandBrakeWPF.Services.Logging.EventArgs;
using HandBrakeWPF.ViewModels;
/// <summary>
@@ -58,7 +59,7 @@ namespace HandBrakeWPF.Views
/// <param name="e">
/// The e.
/// </param>
- private void Vm_LogMessageReceived(object sender, HandBrake.ApplicationServices.Services.Logging.EventArgs.LogEventArgs e)
+ private void Vm_LogMessageReceived(object sender, LogEventArgs e)
{
try
{