/[RomCheater]/trunk/RomCheater/RomCheaterConfigDialog.cs
ViewVC logotype

Diff of /trunk/RomCheater/RomCheaterConfigDialog.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater/RomCheaterConfigDialog.cs	2013/06/18 19:18:05	722
+++ trunk/RomCheater/RomCheaterConfigDialog.cs	2014/04/15 18:02:07	817
@@ -1,16 +1,16 @@
-#region Logging Defines
-// include this any class or method that required logging, and comment-out what is not needed
+//#region Logging Defines
+//// include this any class or method that required logging, and comment-out what is not needed
 
-#region Enabled logging levels
-#define LOGGING_ENABLE_INFO
-#define LOGGING_ENABLE_WARN
-#define LOGGING_ENABLE_DEBUG
-#define LOGGING_ENABLE_VERBOSEDEBUG
-#define LOGGING_ENABLE_ERROR
-#define LOGGING_ENABLE_VERBOSEERROR
-#define LOGGING_ENABLE_PROFILER
-#endregion
-#endregion
+//#region Enabled logging levels
+//#define LOGGING_ENABLE_INFO
+//#define LOGGING_ENABLE_WARN
+//#define LOGGING_ENABLE_DEBUG
+//#define LOGGING_ENABLE_VERBOSEDEBUG
+//#define LOGGING_ENABLE_ERROR
+//#define LOGGING_ENABLE_VERBOSEERROR
+//#define LOGGING_ENABLE_PROFILER
+//#endregion
+//#endregion
 //#define DISABLE_VERBOSE_DEBUG_MESSAGES_FOR_SPEED_BOOST //when defined, will not log verbose debug messages (without changeing logging flags)
 using System;
 using System.Collections.Generic;
@@ -24,6 +24,7 @@
 using RomCheater.PluginFramework.Core;
 using RomCheater.Core;
 using RomCheater.UserSettingsSupport;
+using Enterprise.Logging;
 
 
 namespace RomCheater
@@ -61,10 +62,10 @@
         }
         private void RomCheaterConfigDialog_Load(object sender, EventArgs e)
         {
-            logger.Info.WriteLine("Loading user settings...");
+            gLog.Info.WriteLine("Loading user settings...");
             load_loggerflags();
             setup_plugin_entries();
-            logger.Info.WriteLine("Loaded user settings.");
+            gLog.Info.WriteLine("Loaded user settings.");
         }
 
         private void setup_plugin_entries()
@@ -85,7 +86,7 @@
             {
                 if (item == RomCheater.Properties.Settings.Default.LastConfigPlugin)
                 {
-                    logger.VerboseDebug.WriteLine("    loading LastConfigPlugin: {0}", MainSettingsSubscriber.GetValue("LastConfigPlugin"));
+                    gLog.Verbose.Debug.WriteLine("    loading LastConfigPlugin: {0}", MainSettingsSubscriber.GetValue("LastConfigPlugin"));
                     comboConfigPlugins.SelectedIndex = comboConfigPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -94,7 +95,7 @@
             {
                 if (item == RomCheater.Properties.Settings.Default.LastInputPlugin)
                 {
-                    logger.VerboseDebug.WriteLine("    loading LastInputPlugin: {0}", MainSettingsSubscriber.GetValue("LastInputPlugin"));
+                    gLog.Verbose.Debug.WriteLine("    loading LastInputPlugin: {0}", MainSettingsSubscriber.GetValue("LastInputPlugin"));
                     comboInputPlugins.SelectedIndex = comboInputPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -103,7 +104,7 @@
             {
                 if (item == RomCheater.Properties.Settings.Default.LastWindowPlugin)
                 {
-                    logger.VerboseDebug.WriteLine("    loading LastWindowPlugin: {0}", MainSettingsSubscriber.GetValue("LastWindowPlugin"));
+                    gLog.Verbose.Debug.WriteLine("    loading LastWindowPlugin: {0}", MainSettingsSubscriber.GetValue("LastWindowPlugin"));
                     comboWindowPlugins.SelectedIndex = comboWindowPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -113,60 +114,60 @@
 
         private void load_loggerflags()
         {
-            logger.Info.WriteLine("  Loading logger flags...");
-            object o_flags = LoggingettingsSubscriber.GetValue("LoggingFlags");
-            loggerflags logflags = (ushort)Convert.ChangeType(o_flags, typeof(ushort));
-            if (logflags != logger.GetLoggingFlags())
-            {
-                logflags = logger.GetLoggingFlags(); // we apparently have forced the logging flags (possible for testing)
+            gLog.Info.WriteLine("  Loading logger flags...");
+
+            bool upgraded_flags = Convert.ToBoolean(LoggingettingsSubscriber.GetValue("UpgradedLogLevel"));
+            object o_flags = null;
+            if (!upgraded_flags)
+            {
+                o_flags = new LoggingFlagsConverter(Logging.Properties.Settings.Default.LoggingFlags).ConvertFlags();
+                LoggingettingsSubscriber.SetValue("UpgradedLogLevel", true);
+                LoggingettingsSubscriber.SetValue("gLogLoggingFlags", Convert.ToUInt32(o_flags));
+                LoggingettingsSubscriber.SaveSettings();
             }
+            o_flags = LoggingettingsSubscriber.GetValue("gLogLoggingFlags");
+            LogLevel log_level = (LogLevel)o_flags;
 #if DISABLE_VERBOSE_DEBUG_MESSAGES_FOR_SPEED_BOOST
-            lFlags = logflags;
-            ushort pflags = lFlags.Value;
-            if (lFlags.HasFlag(loggerflags.VERBOSE_DEBUG))
-            {
-                pflags = lFlags.Value;
-                pflags = (ushort)(lFlags.Value & ~loggerflags.VERBOSE_DEBUG.Value);
-                logger.SetLoggingFlags(pflags);
-            }
+      gLog.SetLogLevel(log_level & ~LogLevel.kLogLevel_Verbose);      
 #endif
-            var logger_flags = loggerflags.GetValues();
-
-            foreach (loggerflags flags in logger_flags)
+            foreach (LogLevel t in Enum.GetValues(typeof(LogLevel)))
             {
-                if (flags == loggerflags.ALL ||
-                    flags == loggerflags.NONE ||
-                    flags == loggerflags.DEFAULT)
+                if (t == LogLevel.kLogLevel_All ||
+                        t == LogLevel.kLogLevel_Disable ||
+                        t == LogLevel.kLogLevel_None ||
+                        t == LogLevel.kLogLevel_All_NoProgress ||
+                        t == LogLevel.kLogLevel_All_NoProfiler ||
+                        t == LogLevel.kLogLevel_All_NoProfilerOrProgress ||
+                        t == LogLevel.kLogLevel_Default ||
+                        t == LogLevel.kLogLevel_Verbose)
+                {
                     continue;
-
-                string name = flags.Name;
-                ushort value = (ushort)flags;
-
+                }
                 CheckBox chkloggerflags = new CheckBox();
                 chkloggerflags.Font = this.Font;
+                string name = Enum.GetName(typeof(LogLevel), t).Replace("kLogLevel_", "");
+                LogLevel value = t;
                 chkloggerflags.Name = name;
                 chkloggerflags.Text = name;
                 chkloggerflags.Tag = value;
                 Graphics g = chkloggerflags.CreateGraphics();
-
                 Size size = g.MeasureString(chkloggerflags.Text, chkloggerflags.Font).ToSize();
                 chkloggerflags.Width = size.Width + 25;
-
                 grpLoggingFlags_flow.Controls.Add(chkloggerflags);
-                logger.VerboseDebug.WriteLine("\tAdding logger flag: {0} value: 0x{1:x4}", name, value);
-                if (logflags.HasFlag(value))
+                if (log_level.HasFlag(t))
                 {
                     chkloggerflags.Checked = true;
-                    logger.VerboseDebug.WriteLine("\tTurning on logger flag: {0} value: 0x{1:x4}", name, value);
+                    gLog.Verbose.Debug.WriteLine("\tTurning on logger flag: {0} value: 0x{1:x4}", name, (uint)value);
                 }
             }
             //grpLoggingFlags.AutoSize = true;
             //grpLoggingFlags.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
-            logger.Info.WriteLine("  Loaded logger flags.");
+
+            gLog.Info.WriteLine("  Loaded logger flags.");
         }
         private void btnSave_Click(object sender, EventArgs e)
         {
-            logger.Info.WriteLine("Saving user settings...");
+            gLog.Info.WriteLine("Saving user settings...");
             SaveSettings();
             this.Close();
         }
@@ -182,33 +183,33 @@
             LoggingettingsSubscriber.SaveSettings();
             //RomCheater.Properties.Settings.Default.Save();
             //Logging.Properties.Settings.Default.Save();
-            logger.Info.WriteLine("Saved user settings.");
+            gLog.Info.WriteLine("Saved user settings.");
         }
         private void SaveSelectedPlugins()
         {
-            logger.VerboseDebug.WriteLine("    Setting LastConfigPlugin to {0}", comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString());
+            gLog.Verbose.Debug.WriteLine("    Setting LastConfigPlugin to {0}", comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString());
             MainSettingsSubscriber.SetValue("LastConfigPlugin",comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString());
 
-            logger.VerboseDebug.WriteLine("    Setting LastInputPlugin to {0}", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString());            
+            gLog.Verbose.Debug.WriteLine("    Setting LastInputPlugin to {0}", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString());            
             MainSettingsSubscriber.SetValue("LastInputPlugin", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString());
 
-            logger.VerboseDebug.WriteLine("    Setting LastWindowPlugin to {0}", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString());            
+            gLog.Verbose.Debug.WriteLine("    Setting LastWindowPlugin to {0}", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString());            
             MainSettingsSubscriber.SetValue("LastWindowPlugin", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString());
         }
         private void SaveLoggingFlags()
         {
-            logger.Debug.WriteLine("Saving Logger flags...");
-            ushort logflags = loggerflags.NONE;
+            gLog.Debug.WriteLine("Saving Logger flags...");
+            LogLevel logflags = LogLevel.kLogLevel_None;
             foreach (CheckBox cb in grpLoggingFlags_flow.Controls)
             {
                 if (!cb.Checked) continue;
-                ushort value = Convert.ToUInt16(cb.Tag);
-                logflags = (ushort)(logflags | value);
-                logger.VerboseDebug.WriteLine("\tAdding flag: {0} value: 0x{1:x4} LoggingFlags=0x{2:x4}", cb.Text, value, (int)logflags);                
+                uint value = Convert.ToUInt32(cb.Tag);
+                logflags = logflags | (LogLevel)value;
+                gLog.Verbose.Debug.WriteLine("\tAdding flag: {0} value: 0x{1:x8} LoggingFlags=0x{2:x4}", cb.Text, value, (int)logflags);
             }
 
-            LoggingettingsSubscriber.SetValue("LoggingFlags", (ushort)logflags);
-            logger.Debug.WriteLine("Saved Logger flags.");
+            LoggingettingsSubscriber.SetValue("gLogLoggingFlags", (uint)logflags);
+            gLog.Debug.WriteLine("Saved Logger flags.");
         }
 
         private void RomCheaterConfigDialog_FormClosing(object sender, FormClosingEventArgs e)

 

  ViewVC Help
Powered by ViewVC 1.1.22