diff --git a/SparkleLib/SparkleConfig.cs b/SparkleLib/SparkleConfig.cs index d05eb316..e088685a 100755 --- a/SparkleLib/SparkleConfig.cs +++ b/SparkleLib/SparkleConfig.cs @@ -25,17 +25,17 @@ namespace SparkleLib { public class SparkleConfig : XmlDocument { - public static string ConfigPath = Path.Combine ( + private static string default_config_path = Path.Combine ( Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData), "sparkleshare"); - public bool DebugMode = true; + public static SparkleConfig DefaultConfig = new SparkleConfig (default_config_path, "config.xml"); + public static bool DebugMode = true; + - public static SparkleConfig DefaultConfig = new SparkleConfig (ConfigPath, "config.xml"); public string FullPath; - public string LogFilePath; public string TmpPath; - + public string LogFilePath; public string HomePath { get { @@ -69,16 +69,12 @@ namespace SparkleLib { } } - if (!Directory.Exists (config_path)) { + if (!Directory.Exists (config_path)) Directory.CreateDirectory (config_path); - SparkleHelpers.DebugInfo ("Config", "Created \"" + config_path + "\""); - } - string icons_path = System.IO.Path.Combine (config_path, "icons"); - if (!Directory.Exists (icons_path)) { + string icons_path = Path.Combine (config_path, "icons"); + if (!Directory.Exists (icons_path)) Directory.CreateDirectory (icons_path); - SparkleHelpers.DebugInfo ("Config", "Created \"" + icons_path + "\""); - } try { Load (FullPath); diff --git a/SparkleLib/SparkleHelpers.cs b/SparkleLib/SparkleHelpers.cs index baf49763..7b262d80 100755 --- a/SparkleLib/SparkleHelpers.cs +++ b/SparkleLib/SparkleHelpers.cs @@ -22,29 +22,25 @@ namespace SparkleLib { public static class SparkleHelpers { - public static bool ShowDebugInfo = true; private static object debug_lock = new object (); // Show debug info if needed public static void DebugInfo (string type, string message) { - if (ShowDebugInfo) { - string timestamp = DateTime.Now.ToString ("HH:mm:ss"); + if (!message.StartsWith ("[")) + message = " " + message; - if (!message.StartsWith ("[")) - message = " " + message; + string timestamp = DateTime.Now.ToString ("HH:mm:ss"); + string line = timestamp + " " + "[" + type + "]" + message; - string line = timestamp + " " + "[" + type + "]" + message; + if (SparkleConfig.DebugMode) + Console.WriteLine (line); - if (SparkleConfig.DefaultConfig.DebugMode) - Console.WriteLine (line); - - lock (debug_lock) { - File.AppendAllText ( - SparkleConfig.DefaultConfig.LogFilePath, - line + Environment.NewLine - ); - } + lock (debug_lock) { + File.AppendAllText ( + SparkleConfig.DefaultConfig.LogFilePath, + line + Environment.NewLine + ); } }