#endregion
using System.ComponentModel.Composition;
using System.Diagnostics;
+using System.IO;
+using System.Linq;
using Pithos.Client.WPF.Properties;
using Pithos.Interfaces;
+using log4net.Appender;
+using log4net.Core;
+using log4net.Repository.Hierarchy;
namespace Pithos.Client.WPF.Configuration
{
get { return _settings.PithosSite; }
}*/
- public string PithosLoginUrl
- {
- get { return _settings.PithosLoginUrl; }
- }
public string IconsPath
{
get { return _settings.FileIdleTimeout; }
}
+ public bool UpdateForceCheck
+ {
+ get { return _settings.UpdateForceCheck; }
+ }
+
+ public bool DebugLoggingEnabled
+ {
+ get { return _settings.DebugLoggingEnabled; }
+ set
+ {
+ _settings.DebugLoggingEnabled = value;
+
+ SetDebugLevel();
+ }
+ }
+
+ private static void SetDebugLevel()
+ {
+ var loggerRepository = (Hierarchy) log4net.LogManager.GetRepository();
+
+ var appenders = loggerRepository.GetAppenders();
+
+ var debugAppender = appenders.OfType<RollingFileAppender>()
+ .FirstOrDefault(a => a.Name == "DebugFileAppender");
+ if (debugAppender != null)
+ {
+ var pithosDataPath = PithosDataPath;
+ debugAppender.File = Path.Combine(pithosDataPath, "debuglog.xml");
+ debugAppender.Threshold = !Settings.Default.DebugLoggingEnabled ? Level.Off : Level.All;
+ debugAppender.ActivateOptions();
+ }
+ }
+
+ public static string PithosDataPath
+ {
+ get
+ {
+ var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
+ var pithosDataPath = Path.Combine(appDataPath, "GRNET\\PITHOS");
+ return pithosDataPath;
+ }
+ }
+
public void Save()
{
_settings.Save();