<Compile Include="Services\Encode\Model\Models\Video\VideoPreset.cs" />\r
<Compile Include="Services\Encode\Model\Models\Video\VideoProfile.cs" />\r
<Compile Include="Services\Encode\Model\Models\Video\VideoTune.cs" />\r
+ <Compile Include="Services\Logging\LogHelper.cs" />\r
+ <Compile Include="Services\Logging\Model\LogLevel.cs" />\r
+ <Compile Include="Services\Logging\Model\LogMessage.cs" />\r
+ <Compile Include="Services\Logging\Model\LogMessageType.cs" />\r
<Compile Include="Services\Scan\EventArgs\ScanCompletedEventArgs.cs" />\r
<Compile Include="Services\Scan\EventArgs\ScanProgressEventArgs.cs" />\r
<Compile Include="Utilities\Converters.cs" />\r
using HandBrake.ApplicationServices.Interop.Model;\r
using HandBrake.ApplicationServices.Interop.Model.Encoding;\r
using HandBrake.ApplicationServices.Interop.Model.Preview;\r
+ using HandBrake.ApplicationServices.Services.Logging;\r
+ using HandBrake.ApplicationServices.Services.Logging.Model;\r
\r
using Newtonsoft.Json;\r
\r
};\r
\r
string encode = JsonConvert.SerializeObject(encodeObject, Formatting.Indented, settings);\r
+ LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug));\r
HBFunctions.hb_add_json(this.hbHandle, InteropUtilities.ToUtf8PtrFromString(encode));\r
HBFunctions.hb_start(this.hbHandle);\r
\r
{\r
IntPtr json = HBFunctions.hb_get_state_json(this.hbHandle);\r
string statusJson = Marshal.PtrToStringAnsi(json);\r
+ LogHelper.LogMessage(new LogMessage(statusJson, LogMessageType.progressJson, LogLevel.debug));\r
JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson);\r
\r
if (state != null && state.State == NativeConstants.HB_STATE_SCANNING)\r
{\r
var jsonMsg = HBFunctions.hb_get_title_set_json(this.hbHandle);\r
string scanJson = InteropUtilities.ToStringFromUtf8Ptr(jsonMsg);\r
+ LogHelper.LogMessage(new LogMessage(scanJson, LogMessageType.scanJson, LogLevel.debug));\r
this.titles = JsonConvert.DeserializeObject<JsonScanObject>(scanJson);\r
this.featureTitle = this.titles.MainFeature;\r
\r
{\r
IntPtr json = HBFunctions.hb_get_state_json(this.hbHandle);\r
string statusJson = Marshal.PtrToStringAnsi(json);\r
+\r
+ LogHelper.LogMessage(new LogMessage(statusJson, LogMessageType.progressJson, LogLevel.debug));\r
+\r
JsonState state = JsonConvert.DeserializeObject<JsonState>(statusJson);\r
\r
if (state != null && state.State == NativeConstants.HB_STATE_WORKING)\r
using HandBrake.ApplicationServices.Interop.HbLib;\r
using HandBrake.ApplicationServices.Interop.Json.Anamorphic;\r
using HandBrake.ApplicationServices.Interop.Json.Shared;\r
+ using HandBrake.ApplicationServices.Services.Logging;\r
+ using HandBrake.ApplicationServices.Services.Logging.Model;\r
\r
using Newtonsoft.Json;\r
\r
public static Geometry GetAnamorphicSize(AnamorphicGeometry anamorphicGeometry)\r
{\r
string encode = JsonConvert.SerializeObject(anamorphicGeometry, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });\r
+ LogHelper.LogMessage(new LogMessage(encode, LogMessageType.encodeJson, LogLevel.debug));\r
IntPtr json = HBFunctions.hb_set_anamorphic_size_json(Marshal.StringToHGlobalAnsi(encode));\r
string result = Marshal.PtrToStringAnsi(json);\r
return JsonConvert.DeserializeObject<Geometry>(result);\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="LogHelper.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+// The log service.\r
+// For now, this is just a simple logging service but we could provide support for a formal logging library later.\r
+// Also, we can consider providing the UI layer with more functional logging. (i.e levels, time/date, highlighting etc)\r
+// The Interop Classes are not very OO friendly, so this is going to be a static class.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrake.ApplicationServices.Services.Logging\r
+{\r
+ using System.Diagnostics;\r
+\r
+ using HandBrake.ApplicationServices.Services.Logging.Model;\r
+\r
+ /// <summary>\r
+ /// The log helper.\r
+ /// </summary>\r
+ public static class LogHelper\r
+ {\r
+ private static LogLevel currentLogLevel = LogLevel.debug; // TODO default to Info when this class is implimented. \r
+\r
+ /// <summary>\r
+ /// Log message.\r
+ /// </summary>\r
+ /// <param name="message">\r
+ /// The message.\r
+ /// </param>\r
+ public static void LogMessage(LogMessage message)\r
+ {\r
+ if (message.LogLevel <= currentLogLevel)\r
+ {\r
+ Debug.WriteLine(message.Content);\r
+ }\r
+\r
+ // TODO cache logging. \r
+ }\r
+\r
+ /// <summary>\r
+ /// The set log level. Default: Info.\r
+ /// </summary>\r
+ /// <param name="level">\r
+ /// The level.\r
+ /// </param>\r
+ public static void SetLogLevel(LogLevel level)\r
+ {\r
+ currentLogLevel = level;\r
+ }\r
+ }\r
+}\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="LogLevel.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+// The log level.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrake.ApplicationServices.Services.Logging.Model\r
+{\r
+ /// <summary>\r
+ /// The log level.\r
+ /// </summary>\r
+ public enum LogLevel\r
+ {\r
+ /// <summary>\r
+ /// The info.\r
+ /// </summary>\r
+ info,\r
+\r
+ /// <summary>\r
+ /// The warning.\r
+ /// </summary>\r
+ warning, \r
+\r
+ /// <summary>\r
+ /// The error.\r
+ /// </summary>\r
+ error, \r
+ \r
+ /// <summary>\r
+ /// The debug.\r
+ /// </summary>\r
+ debug, \r
+ }\r
+}\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="LogMessage.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+// The message.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrake.ApplicationServices.Services.Logging.Model\r
+{\r
+ /// <summary>\r
+ /// The json message.\r
+ /// </summary>\r
+ public class LogMessage\r
+ {\r
+ /// <summary>\r
+ /// Initializes a new instance of the <see cref="LogMessage"/> class.\r
+ /// </summary>\r
+ /// <param name="content">\r
+ /// The content.\r
+ /// </param>\r
+ /// <param name="messageType">\r
+ /// The message type.\r
+ /// </param>\r
+ /// <param name="logLevel">\r
+ /// The log level.\r
+ /// </param>\r
+ public LogMessage(string content, LogMessageType messageType, LogLevel logLevel)\r
+ {\r
+ this.Content = content;\r
+ this.MessageType = messageType;\r
+ this.LogLevel = logLevel;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets the content.\r
+ /// </summary>\r
+ public string Content { get; private set; }\r
+\r
+ /// <summary>\r
+ /// Gets a value indicating whether this message was generated by the GUI.\r
+ /// If false, it was provided by libhb.\r
+ /// </summary>\r
+ public LogMessageType MessageType { get; private set; }\r
+\r
+ /// <summary>\r
+ /// Gets the log level.\r
+ /// </summary>\r
+ public LogLevel LogLevel { get; private set; }\r
+ }\r
+}\r
--- /dev/null
+// --------------------------------------------------------------------------------------------------------------------\r
+// <copyright file="LogMessageType.cs" company="HandBrake Project (http://handbrake.fr)">\r
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.\r
+// </copyright>\r
+// <summary>\r
+// The log message type.\r
+// </summary>\r
+// --------------------------------------------------------------------------------------------------------------------\r
+\r
+namespace HandBrake.ApplicationServices.Services.Logging.Model\r
+{\r
+ /// <summary>\r
+ /// The log message type.\r
+ /// </summary>\r
+ public enum LogMessageType\r
+ {\r
+ scanJson,\r
+ encodeJson,\r
+ anamorphicJson,\r
+ progressJson,\r
+ libhb,\r
+ }\r
+}\r
\r
using HandBrake.ApplicationServices.Services.Encode;\r
using HandBrake.ApplicationServices.Services.Encode.Interfaces;\r
+ using HandBrake.ApplicationServices.Services.Logging;\r
using HandBrake.ApplicationServices.Services.Scan;\r
using HandBrake.ApplicationServices.Services.Scan.Interfaces;\r
\r