diff options
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices')
12 files changed, 538 insertions, 76 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index c6fddcfb7..91342b059 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -181,7 +181,9 @@ <Compile Include="Interop\Model\VideoQualityLimits.cs" />
<Compile Include="Model\HBConfiguration.cs" />
<Compile Include="Model\VideoScaler.cs" />
- <Compile Include="Services\Logging\LogHelper.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" />
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs index a862dc1e6..633c4e1fb 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeInstance.cs @@ -34,6 +34,7 @@ namespace HandBrake.ApplicationServices.Interop using HandBrake.ApplicationServices.Interop.Model.Encoding;
using HandBrake.ApplicationServices.Interop.Model.Preview;
using HandBrake.ApplicationServices.Services.Logging;
+ using HandBrake.ApplicationServices.Services.Logging.Interfaces;
using HandBrake.ApplicationServices.Services.Logging.Model;
using Newtonsoft.Json;
@@ -55,6 +56,8 @@ namespace HandBrake.ApplicationServices.Interop /// </summary>
private const double EncodePollIntervalMs = 250;
+ private readonly ILog log = LogService.GetLogger();
+
/// <summary>
/// The native handle to the HandBrake instance.
/// </summary>
@@ -502,7 +505,7 @@ namespace HandBrake.ApplicationServices.Interop {
IntPtr json = HBFunctions.hb_get_state_json(this.hbHandle);
string statusJson = Marshal.PtrToStringAnsi(json);
- LogHelper.LogMessage(new LogMessage(statusJson, LogMessageType.progressJson, LogLevel.debug));
+ this.log.LogMessage(statusJson, LogMessageType.Progress, LogLevel.Trace);
JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson);
if (state != null && state.State == NativeConstants.HB_STATE_SCANNING)
@@ -516,7 +519,7 @@ namespace HandBrake.ApplicationServices.Interop {
var jsonMsg = HBFunctions.hb_get_title_set_json(this.hbHandle);
string scanJson = InteropUtilities.ToStringFromUtf8Ptr(jsonMsg);
- LogHelper.LogMessage(new LogMessage(scanJson, LogMessageType.scanJson, LogLevel.debug));
+ this.log.LogMessage(scanJson, LogMessageType.Progress, LogLevel.Trace);
this.titles = JsonConvert.DeserializeObject<JsonScanObject>(scanJson);
this.featureTitle = this.titles.MainFeature;
@@ -541,7 +544,7 @@ namespace HandBrake.ApplicationServices.Interop IntPtr json = HBFunctions.hb_get_state_json(this.hbHandle);
string statusJson = Marshal.PtrToStringAnsi(json);
- LogHelper.LogMessage(new LogMessage(statusJson, LogMessageType.progressJson, LogLevel.debug));
+ this.log.LogMessage(statusJson, LogMessageType.Progress, LogLevel.Trace);
JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson);
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs index fcc6d61da..7e1f95d3e 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakePresetService.cs @@ -18,6 +18,7 @@ namespace HandBrake.ApplicationServices.Interop using HandBrake.ApplicationServices.Interop.Helpers;
using HandBrake.ApplicationServices.Interop.Json.Presets;
using HandBrake.ApplicationServices.Services.Logging;
+ using HandBrake.ApplicationServices.Services.Logging.Interfaces;
using HandBrake.ApplicationServices.Services.Logging.Model;
using Newtonsoft.Json;
@@ -27,6 +28,8 @@ namespace HandBrake.ApplicationServices.Interop /// </summary>
public class HandBrakePresetService
{
+ private static readonly ILog log = LogService.GetLogger();
+
/// <summary>
/// The get built in presets.
/// Requires an hb_init to have been invoked.
@@ -39,7 +42,7 @@ namespace HandBrake.ApplicationServices.Interop IntPtr presets = HBFunctions.hb_presets_builtin_get_json();
string presetJson = Marshal.PtrToStringAnsi(presets);
- LogHelper.LogMessage(new LogMessage(presetJson, LogMessageType.progressJson, LogLevel.debug));
+ log.LogMessage(presetJson, LogMessageType.API, LogLevel.Debug);
IList<PresetCategory> presetList = JsonConvert.DeserializeObject<IList<PresetCategory>>(presetJson);
@@ -60,7 +63,7 @@ namespace HandBrake.ApplicationServices.Interop IntPtr presetStringPointer = HBFunctions.hb_presets_read_file_json(InteropUtilities.ToUtf8PtrFromString(filename));
string presetJson = Marshal.PtrToStringAnsi(presetStringPointer);
- LogHelper.LogMessage(new LogMessage(presetJson, LogMessageType.libhb, LogLevel.debug));
+ log.LogMessage(presetJson, LogMessageType.API, LogLevel.Debug);
PresetTransportContainer preset = JsonConvert.DeserializeObject<PresetTransportContainer>(presetJson);
diff --git a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs index 3540bb368..ef98f3f86 100644 --- a/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.ApplicationServices/Interop/HandBrakeUtils.cs @@ -11,7 +11,6 @@ namespace HandBrake.ApplicationServices.Interop {
using System;
using System.Collections.Generic;
- using System.Diagnostics;
using System.Runtime.InteropServices;
using HandBrake.ApplicationServices.Interop.EventArgs;
@@ -19,6 +18,7 @@ namespace HandBrake.ApplicationServices.Interop using HandBrake.ApplicationServices.Interop.Json.Anamorphic;
using HandBrake.ApplicationServices.Interop.Json.Shared;
using HandBrake.ApplicationServices.Services.Logging;
+ using HandBrake.ApplicationServices.Services.Logging.Interfaces;
using HandBrake.ApplicationServices.Services.Logging.Model;
using Newtonsoft.Json;
@@ -28,6 +28,8 @@ namespace HandBrake.ApplicationServices.Interop /// </summary>
public static class HandBrakeUtils
{
+ private static readonly ILog log = LogService.GetLogger();
+
/// <summary>
/// The callback for log messages from HandBrake.
/// </summary>
@@ -301,7 +303,7 @@ namespace HandBrake.ApplicationServices.Interop public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry)
{
string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
- LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug));
+ log.LogMessage(encode, LogMessageType.API, LogLevel.Debug);
IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));
string result = Marshal.PtrToStringAnsi(json);
return JsonConvert.DeserializeObject<Geometry>(result);
@@ -317,10 +319,9 @@ namespace HandBrake.ApplicationServices.Interop {
if (MessageLogged != null)
{
+ log.LogMessage(message, LogMessageType.ScanOrEncode, LogLevel.Info);
MessageLogged(null, new MessageLoggedEventArgs(message));
}
-
- Debug.WriteLine(message);
}
/// <summary>
@@ -333,10 +334,9 @@ namespace HandBrake.ApplicationServices.Interop {
if (ErrorLogged != null)
{
+ log.LogMessage(message, LogMessageType.ScanOrEncode, LogLevel.Error);
ErrorLogged(null, new MessageLoggedEventArgs(message));
}
-
- Debug.WriteLine("ERROR: " + message);
}
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Logging/EventArgs/LogEventArgs.cs b/win/CS/HandBrake.ApplicationServices/Services/Logging/EventArgs/LogEventArgs.cs new file mode 100644 index 000000000..b9691e4a3 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/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 HandBrake.ApplicationServices.Services.Logging.EventArgs +{ + using System; + + using Model; + + /// <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/HandBrake.ApplicationServices/Services/Logging/Interfaces/ILog.cs b/win/CS/HandBrake.ApplicationServices/Services/Logging/Interfaces/ILog.cs new file mode 100644 index 000000000..dc0b3c08b --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Services/Logging/Interfaces/ILog.cs @@ -0,0 +1,87 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <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 HandBrake.ApplicationServices.Services.Logging.Interfaces +{ + using System; + using System.Collections.Generic; + + using EventArgs; + + using Model; + + /// <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/HandBrake.ApplicationServices/Services/Logging/LogHelper.cs b/win/CS/HandBrake.ApplicationServices/Services/Logging/LogHelper.cs deleted file mode 100644 index 44ccc757c..000000000 --- a/win/CS/HandBrake.ApplicationServices/Services/Logging/LogHelper.cs +++ /dev/null @@ -1,53 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="LogHelper.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 HandBrake.ApplicationServices.Services.Logging
-{
- using System.Diagnostics;
-
- using HandBrake.ApplicationServices.Services.Logging.Model;
-
- /// <summary>
- /// The log helper.
- /// </summary>
- public static class LogHelper
- {
- private static LogLevel currentLogLevel = LogLevel.debug; // TODO default to Info when this class is implimented.
-
- /// <summary>
- /// Log message.
- /// </summary>
- /// <param name="message">
- /// The message.
- /// </param>
- public static void LogMessage(LogMessage message)
- {
- if (message.LogLevel <= currentLogLevel)
- {
- //Debug.WriteLine(message.Content);
- }
-
- // TODO cache logging.
- }
-
- /// <summary>
- /// The set log level. Default: Info.
- /// </summary>
- /// <param name="level">
- /// The level.
- /// </param>
- public static void SetLogLevel(LogLevel level)
- {
- currentLogLevel = level;
- }
- }
-}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Logging/LogService.cs b/win/CS/HandBrake.ApplicationServices/Services/Logging/LogService.cs new file mode 100644 index 000000000..cd0d5a483 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Services/Logging/LogService.cs @@ -0,0 +1,361 @@ +// -------------------------------------------------------------------------------------------------------------------- +// <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 HandBrake.ApplicationServices.Services.Logging +{ + using System; + using System.Collections.Generic; + using System.Diagnostics; + using System.IO; + using System.Text; + + using HandBrake.ApplicationServices.Services.Logging.EventArgs; + using HandBrake.ApplicationServices.Services.Logging.Interfaces; + using HandBrake.ApplicationServices.Services.Logging.Model; + + /// <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; + + /// <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; + } + } + } + + /// <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.Vital, + 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.Vital, 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.Vital, 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> + /// 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 warrent user interaction, but it should be logged + } + } + + /// <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 warrent user interaction, but it should be logged + } + } + + // Trigger the Event to notify any subscribers that the log has been reset. + protected virtual void OnLogReset() + { + this.LogReset?.Invoke(this, System.EventArgs.Empty); + } + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogLevel.cs b/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogLevel.cs index c2e2b8f0a..a319ae385 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogLevel.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogLevel.cs @@ -17,21 +17,26 @@ namespace HandBrake.ApplicationServices.Services.Logging.Model /// <summary>
/// The info.
/// </summary>
- info,
+ Info,
/// <summary>
/// The warning.
/// </summary>
- warning,
+ Warning,
/// <summary>
/// The error.
/// </summary>
- error,
+ Error,
/// <summary>
/// The debug.
/// </summary>
- debug,
+ Debug,
+
+ /// <summary>
+ /// Trace Level Logging.
+ /// </summary>
+ Trace,
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessage.cs b/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessage.cs index 9179e2fa5..edf071ba1 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessage.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessage.cs @@ -10,7 +10,7 @@ namespace HandBrake.ApplicationServices.Services.Logging.Model
{
/// <summary>
- /// The json message.
+ /// An Immutable Log Entry.
/// </summary>
public class LogMessage
{
@@ -26,11 +26,15 @@ namespace HandBrake.ApplicationServices.Services.Logging.Model /// <param name="logLevel">
/// The log level.
/// </param>
- public LogMessage(string content, LogMessageType messageType, LogLevel logLevel)
+ /// <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>
@@ -48,5 +52,10 @@ namespace HandBrake.ApplicationServices.Services.Logging.Model /// Gets the log level.
/// </summary>
public LogLevel LogLevel { get; private set; }
+
+ /// <summary>
+ /// Gets the message index.
+ /// </summary>
+ public long MessageIndex { get; private set; }
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessageType.cs b/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessageType.cs index df0ce0fc3..47302a872 100644 --- a/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessageType.cs +++ b/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessageType.cs @@ -14,10 +14,9 @@ namespace HandBrake.ApplicationServices.Services.Logging.Model /// </summary>
public enum LogMessageType
{
- scanJson,
- encodeJson,
- anamorphicJson,
- progressJson,
- libhb,
+ ScanOrEncode,
+ API,
+ Progress,
+ Vital,
}
}
diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs index 1acc9cccc..12665c062 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs @@ -277,6 +277,15 @@ namespace HandBrake.ApplicationServices.Utilities return iso6392Codes;
}
+ /// <summary>
+ /// The get language names.
+ /// </summary>
+ /// <param name="languageCodes">
+ /// The language codes.
+ /// </param>
+ /// <returns>
+ /// The <see cref="List"/>.
+ /// </returns>
public static List<string> GetLanguageNames(IList<string> languageCodes)
{
// Translate to Iso Codes
|