diff options
author | sr55 <[email protected]> | 2015-04-10 22:29:57 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2015-04-10 22:29:57 +0000 |
commit | 01487d5277eaadf2da3a483aa1d74198050fba44 (patch) | |
tree | 71438b397683b1bb2cdc94fbc6416cbbeb744660 /win/CS/HandBrake.ApplicationServices/Services/Logging | |
parent | 9c78da39f3c6947c84c039e1f16497da6020b740 (diff) |
WinGui: Add a basic outline of a logging system to allow logging of the JSON and other types of messages.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7084 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Services/Logging')
4 files changed, 165 insertions, 0 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Logging/LogHelper.cs b/win/CS/HandBrake.ApplicationServices/Services/Logging/LogHelper.cs new file mode 100644 index 000000000..e088acd1e --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Services/Logging/LogHelper.cs @@ -0,0 +1,53 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <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/Model/LogLevel.cs b/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogLevel.cs new file mode 100644 index 000000000..c2e2b8f0a --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogLevel.cs @@ -0,0 +1,37 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <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 HandBrake.ApplicationServices.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,
+ }
+}
diff --git a/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessage.cs b/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessage.cs new file mode 100644 index 000000000..9179e2fa5 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessage.cs @@ -0,0 +1,52 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <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 HandBrake.ApplicationServices.Services.Logging.Model
+{
+ /// <summary>
+ /// The json message.
+ /// </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>
+ public LogMessage(string content, LogMessageType messageType, LogLevel logLevel)
+ {
+ this.Content = content;
+ this.MessageType = messageType;
+ this.LogLevel = logLevel;
+ }
+
+ /// <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 LogMessageType MessageType { get; private set; }
+
+ /// <summary>
+ /// Gets the log level.
+ /// </summary>
+ public LogLevel LogLevel { 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 new file mode 100644 index 000000000..df0ce0fc3 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Services/Logging/Model/LogMessageType.cs @@ -0,0 +1,23 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <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 HandBrake.ApplicationServices.Services.Logging.Model
+{
+ /// <summary>
+ /// The log message type.
+ /// </summary>
+ public enum LogMessageType
+ {
+ scanJson,
+ encodeJson,
+ anamorphicJson,
+ progressJson,
+ libhb,
+ }
+}
|