public static PerformConfig PrepaireConfig(string configfile, string logPath, string tmpPath) { if (string.IsNullOrEmpty(logPath)) { logPath = "log"; } if (string.IsNullOrEmpty(tmpPath)) { tmpPath = "tmp"; } var tmpWorkDirPath = Path.Combine(tmpPath, $"dackup-tmp-{DateTime.UtcNow:s}"); DackupContext.Create(Path.Join(logPath, "dackup.log"), tmpWorkDirPath); Log.Logger = new LoggerConfiguration() .MinimumLevel.Information() .WriteTo.Console() .WriteTo.File(DackupContext.Current.LogFile, rollingInterval: RollingInterval.Month, rollOnFileSizeLimit: true) .CreateLogger(); AppDomain.CurrentDomain.UnhandledException += (s, e) => Log.Error("*** Crash! ***", "UnhandledException"); TaskScheduler.UnobservedTaskException += (s, e) => Log.Error("*** Crash! ***", "UnobservedTaskException"); return(PerformConfigHelper.LoadFrom(configfile)); }
public static DackupContext Create(string logFile, string tmpPath) { if (instance != null) { throw new InvalidOperationException("DackupContext already created - use BacupContext.Current to get"); } else { lock (_mutex) { if (instance == null) { instance = new DackupContext(logFile, tmpPath); } } } return(instance); }