config: don't write any debug output, as DebugInfo method requires a working config
This commit is contained in:
parent
994ccbb07b
commit
c0d5e4f6ea
|
@ -25,17 +25,17 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public class SparkleConfig : XmlDocument {
|
public class SparkleConfig : XmlDocument {
|
||||||
|
|
||||||
public static string ConfigPath = Path.Combine (
|
private static string default_config_path = Path.Combine (
|
||||||
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
|
Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData),
|
||||||
"sparkleshare");
|
"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 FullPath;
|
||||||
public string LogFilePath;
|
|
||||||
public string TmpPath;
|
public string TmpPath;
|
||||||
|
public string LogFilePath;
|
||||||
|
|
||||||
public string HomePath {
|
public string HomePath {
|
||||||
get {
|
get {
|
||||||
|
@ -69,16 +69,12 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists (config_path)) {
|
if (!Directory.Exists (config_path))
|
||||||
Directory.CreateDirectory (config_path);
|
Directory.CreateDirectory (config_path);
|
||||||
SparkleHelpers.DebugInfo ("Config", "Created \"" + config_path + "\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
string icons_path = System.IO.Path.Combine (config_path, "icons");
|
string icons_path = Path.Combine (config_path, "icons");
|
||||||
if (!Directory.Exists (icons_path)) {
|
if (!Directory.Exists (icons_path))
|
||||||
Directory.CreateDirectory (icons_path);
|
Directory.CreateDirectory (icons_path);
|
||||||
SparkleHelpers.DebugInfo ("Config", "Created \"" + icons_path + "\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Load (FullPath);
|
Load (FullPath);
|
||||||
|
|
|
@ -22,29 +22,25 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public static class SparkleHelpers {
|
public static class SparkleHelpers {
|
||||||
|
|
||||||
public static bool ShowDebugInfo = true;
|
|
||||||
private static object debug_lock = new object ();
|
private static object debug_lock = new object ();
|
||||||
|
|
||||||
// Show debug info if needed
|
// Show debug info if needed
|
||||||
public static void DebugInfo (string type, string message)
|
public static void DebugInfo (string type, string message)
|
||||||
{
|
{
|
||||||
if (ShowDebugInfo) {
|
if (!message.StartsWith ("["))
|
||||||
string timestamp = DateTime.Now.ToString ("HH:mm:ss");
|
message = " " + message;
|
||||||
|
|
||||||
if (!message.StartsWith ("["))
|
string timestamp = DateTime.Now.ToString ("HH:mm:ss");
|
||||||
message = " " + message;
|
string line = timestamp + " " + "[" + type + "]" + message;
|
||||||
|
|
||||||
string line = timestamp + " " + "[" + type + "]" + message;
|
if (SparkleConfig.DebugMode)
|
||||||
|
Console.WriteLine (line);
|
||||||
|
|
||||||
if (SparkleConfig.DefaultConfig.DebugMode)
|
lock (debug_lock) {
|
||||||
Console.WriteLine (line);
|
File.AppendAllText (
|
||||||
|
SparkleConfig.DefaultConfig.LogFilePath,
|
||||||
lock (debug_lock) {
|
line + Environment.NewLine
|
||||||
File.AppendAllText (
|
);
|
||||||
SparkleConfig.DefaultConfig.LogFilePath,
|
|
||||||
line + Environment.NewLine
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue