/[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	2012/05/10 14:01:31	112
+++ trunk/RomCheater/RomCheaterConfigDialog.cs	2013/06/17 10:29:30	692
@@ -1,4 +1,18 @@
-´╗┐using System;
+´╗┐#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
+//#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;
 using System.ComponentModel;
 using System.Data;
@@ -8,18 +22,32 @@
 using System.Windows.Forms;
 using RomCheater.Logging;
 using RomCheater.PluginFramework.Core;
-using RomCheater.PluginFramework.Interfaces;
+using RomCheater.Core;
+
 
 namespace RomCheater
 {
     public partial class RomCheaterConfigDialog : Form
     {
+#if DISABLE_VERBOSE_DEBUG_MESSAGES_FOR_SPEED_BOOST
+        private loggerflags lFlags;
+#endif
+
         private PluginLoader loader = null;
         public RomCheaterConfigDialog()
         {
             InitializeComponent();
+            //lFlags = logger.GetLoggingFlags();
+            //ushort flags = lFlags.Value;
+            //if (lFlags.HasFlag(loggerflags.VERBOSE_DEBUG))
+            //{
+            //    flags = lFlags.Value;
+            //    flags = (ushort)(lFlags.Value & ~loggerflags.VERBOSE_DEBUG.Value);
+            //    logger.SetLoggingFlags(flags);                
+            //}
         }
-        public RomCheaterConfigDialog(PluginLoader loader) : this()
+        public RomCheaterConfigDialog(PluginLoader loader)
+            : this()
         {
             this.loader = loader;
         }
@@ -49,7 +77,7 @@
             {
                 if (item == RomCheater.Properties.Settings.Default.LastConfigPlugin)
                 {
-                    logger.Debug.WriteLine("    loading LastConfigPlugin: {0}", RomCheater.Properties.Settings.Default.LastConfigPlugin);
+                    logger.VerboseDebug.WriteLine("    loading LastConfigPlugin: {0}", RomCheater.Properties.Settings.Default.LastConfigPlugin);
                     comboConfigPlugins.SelectedIndex = comboConfigPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -58,7 +86,7 @@
             {
                 if (item == RomCheater.Properties.Settings.Default.LastInputPlugin)
                 {
-                    logger.Debug.WriteLine("    loading LastInputPlugin: {0}", RomCheater.Properties.Settings.Default.LastInputPlugin);
+                    logger.VerboseDebug.WriteLine("    loading LastInputPlugin: {0}", RomCheater.Properties.Settings.Default.LastInputPlugin);
                     comboInputPlugins.SelectedIndex = comboInputPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -67,7 +95,7 @@
             {
                 if (item == RomCheater.Properties.Settings.Default.LastWindowPlugin)
                 {
-                    logger.Debug.WriteLine("    loading LastWindowPlugin: {0}", RomCheater.Properties.Settings.Default.LastWindowPlugin);
+                    logger.VerboseDebug.WriteLine("    loading LastWindowPlugin: {0}", RomCheater.Properties.Settings.Default.LastWindowPlugin);
                     comboWindowPlugins.SelectedIndex = comboWindowPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -77,16 +105,33 @@
 
         private void load_loggerflags()
         {
-            logger.Debug.WriteLine("Loading logger flags...");
+            logger.Info.WriteLine("  Loading logger flags...");
             loggerflags logflags = Logging.Properties.Settings.Default.LoggingFlags;
-            foreach (loggerflags flags in loggerflags.GetValues())
+
+            if (logflags != logger.GetLoggingFlags())
+            {
+                logflags = logger.GetLoggingFlags(); // we apparently have forced the logging flags (possible for testing)
+            }
+#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);
+            }
+#endif
+            var logger_flags = loggerflags.GetValues();
+
+            foreach (loggerflags flags in logger_flags)
             {
                 if (flags == loggerflags.ALL ||
                     flags == loggerflags.NONE ||
                     flags == loggerflags.DEFAULT)
                     continue;
 
-                string name = flags.ToString();
+                string name = flags.Name;
                 ushort value = (ushort)flags;
 
                 CheckBox chkloggerflags = new CheckBox();
@@ -100,17 +145,16 @@
                 chkloggerflags.Width = size.Width + 25;
 
                 grpLoggingFlags_flow.Controls.Add(chkloggerflags);
-                logger.Debug.WriteLine("\tAdding logger flag: {0} value: 0x{1:x4}", name, value);
-
+                logger.VerboseDebug.WriteLine("\tAdding logger flag: {0} value: 0x{1:x4}", name, value);
                 if (logflags.HasFlag(value))
                 {
                     chkloggerflags.Checked = true;
-                    logger.Debug.WriteLine("\tTurning on logger flag: {0} value: 0x{1:x4}", name, value);
+                    logger.VerboseDebug.WriteLine("\tTurning on logger flag: {0} value: 0x{1:x4}", name, value);
                 }
             }
             //grpLoggingFlags.AutoSize = true;
             //grpLoggingFlags.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
-            logger.Debug.WriteLine("Loaded logger flags.");
+            logger.Info.WriteLine("  Loaded logger flags.");
         }
         private void btnSave_Click(object sender, EventArgs e)
         {
@@ -132,28 +176,38 @@
         }
         private void SaveSelectedPlugins()
         {
-            logger.Debug.WriteLine("    Setting LastConfigPlugin to {0}", comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString());
+            logger.VerboseDebug.WriteLine("    Setting LastConfigPlugin to {0}", comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString());
             RomCheater.Properties.Settings.Default.LastConfigPlugin = comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString();
-
-            logger.Debug.WriteLine("    Setting LastInputPlugin to {0}", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString());
+            logger.VerboseDebug.WriteLine("    Setting LastInputPlugin to {0}", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString());
             RomCheater.Properties.Settings.Default.LastInputPlugin = comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString();
-
-            logger.Debug.WriteLine("    Setting LastWindowPlugin to {0}", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString());
+            logger.VerboseDebug.WriteLine("    Setting LastWindowPlugin to {0}", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString());
             RomCheater.Properties.Settings.Default.LastWindowPlugin = comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString();
         }
         private void SaveLoggingFlags()
         {
             logger.Debug.WriteLine("Saving Logger flags...");
-            loggerflags logflags = loggerflags.NONE;
+            ushort logflags = loggerflags.NONE;
             foreach (CheckBox cb in grpLoggingFlags_flow.Controls)
             {
                 if (!cb.Checked) continue;
                 ushort value = Convert.ToUInt16(cb.Tag);
                 logflags = (ushort)(logflags | value);
-                logger.Debug.WriteLine("\tAdding flag: {0} value: 0x{1:x4} LoggingFlags=0x{2:x4}", cb.Text, value, (int)logflags);                
+                logger.VerboseDebug.WriteLine("\tAdding flag: {0} value: 0x{1:x4} LoggingFlags=0x{2:x4}", cb.Text, value, (int)logflags);                
             }
             Logging.Properties.Settings.Default.LoggingFlags = (ushort)logflags;
             logger.Debug.WriteLine("Saved Logger flags.");
         }
+
+        private void RomCheaterConfigDialog_FormClosing(object sender, FormClosingEventArgs e)
+        {
+
+        }
+
+        private void RomCheaterConfigDialog_FormClosed(object sender, FormClosedEventArgs e)
+        {
+#if DISABLE_VERBOSE_DEBUG_MESSAGES_FOR_SPEED_BOOST
+            logger.SetLoggingFlags(lFlags);
+#endif
+        }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22