diff --git a/OpenBullet/Globals.cs b/OpenBullet/Globals.cs index 9808021..d3cc84e 100644 --- a/OpenBullet/Globals.cs +++ b/OpenBullet/Globals.cs @@ -12,25 +12,6 @@ using System.Windows.Media; namespace OpenBullet { - public enum Components - { - Main, - RunnerManager, - Runner, - ProxyManager, - WordlistManager, - HitsDB, - ConfigManager, - Stacker, - OtherOptions, - Settings, - ListGenerator, - SeleniumTools, - Database, - ComboSuite, - About - } - public static class Globals { // Version @@ -41,7 +22,7 @@ namespace OpenBullet // Log Window public static LogWindow logWindow; - public static OBLog log = new OBLog(); + public static LoggerViewModel logger = new LoggerViewModel(); // Constant file paths public static string dataBaseFile = @"DB/OpenBullet.db"; @@ -62,84 +43,7 @@ namespace OpenBullet // Runners public static ObservableCollection Runners = new ObservableCollection(); - // Logging Methods - public static void Log(Components component, LogLevel level, string message, bool prompt = false, int timeout = 0) - { - if (prompt) - { - if (timeout == 0) - { - MessageBox.Show(message, level.ToString()); - } - else - { - var w = new System.Windows.Forms.Form() { Size = new System.Drawing.Size(0, 0) }; - Task.Delay(TimeSpan.FromSeconds(timeout)) - .ContinueWith((t) => w.Close(), TaskScheduler.FromCurrentSynchronizationContext()); - - System.Windows.Forms.MessageBox.Show(w, message, level.ToString()); - } - } - - if (!CanLog()) return; - App.Current.Dispatcher.Invoke(new Action(() => - { - var entry = new LogEntry(component.ToString(), message, level); - InsertEntry(entry); - LogToFile(entry); - })); - } - - public static void LogInfo(Components component, string message, bool prompt = false, int timeout = 0) - { - Log(component, LogLevel.Info, message, prompt, timeout); - } - - public static void LogWarning(Components component, string message, bool prompt = false, int timeout = 0) - { - Log(component, LogLevel.Warning, message, prompt, timeout); - } - - public static void LogError(Components component, string message, bool prompt = false, int timeout = 0) - { - Log(component, LogLevel.Error, message, prompt, timeout); - } - - private static bool CanLog() - { - try - { - return obSettings.General.EnableLogging; - } - catch { return false; } - } - - private static void InsertEntry(LogEntry entry) - { - try - { - log.List.Insert(0, entry); - - var count = log.List.Count; - if (count > obSettings.General.LogBufferSize) - { - log.List.RemoveAt(count - 1); - } - } - catch { } - } - - private static void LogToFile(LogEntry entry) - { - try - { - if(obSettings.General.LogToFile) - File.AppendAllText(logFile, $"[{entry.LogTime}] ({entry.LogLevel}) {entry.LogComponent} - " + entry.LogString + Environment.NewLine); - } - catch { } - } - - public static System.Windows.Media.Color GetColor(string propertyName) + public static Color GetColor(string propertyName) { try { return ((SolidColorBrush)App.Current.Resources[propertyName]).Color; } catch { return ((SolidColorBrush)App.Current.Resources["ForegroundMain"]).Color; } diff --git a/OpenBullet/LogWindow.xaml b/OpenBullet/LogWindow.xaml index dd81155..43ac890 100644 --- a/OpenBullet/LogWindow.xaml +++ b/OpenBullet/LogWindow.xaml @@ -19,7 +19,7 @@ - +