public MicrosoftLoggerTests() { _logObserver = Substitute.For <IObserver <MicrosoftLogEvent> >(); _observableLogger = new ObservableLogger("logger", (s, level) => true, _logObserver); _observableLogger.BeginScope <string>("scope"); _logger = new MicrosoftLogger(_observableLogger); }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); ShutdownMode = ShutdownMode.OnLastWindowClose; DispatcherUnhandledException += (sender, args) => { LogException(LogLevel.Critical, args.Exception); Logger.FlushAllAsync().Wait(); #if DEBUG args.Handled = true; #else Current.Shutdown(); #endif }; #if DEBUG Logger.Level = LogLevel.Trace; Logger.AddBannedScope("GENERATOR"); var logger = new ObservableLogger(1000, RunOnUiThreadAsync); Logger.RegisterReceiver(logger); _logWindow = new LogWindow(logger); _logWindow.Show(); #else Logger.Level = LogLevel.None; #endif LogMessage(LogLevel.Info, "Application ready"); }
public static void StartLoggers() { Logger.Level = LogLevel.Trace; ObservableLogger = new ObservableLogger(10000, App.RunOnUiThreadAsync) { Level = Logger.Level }; Logger.RegisterReceiver(ObservableLogger, true); }
public MainWindow() { InitializeComponent(); Logger.Level = LogLevel.Trace; _observableLogger = new ObservableLogger(1000, App.RunOnUiThreadAsync); Logger.RegisterReceiver(_observableLogger); Logger.LogEntry("Test", LogLevel.Info, "Started"); }
private void StartLog() { Logger.Level = LogLevel.Trace; var observableLogger = new ObservableLogger(1000, App.RunOnUiThread); Logger.RegisterReceiver(observableLogger); _logWindow = new LogWindow(observableLogger); _logWindow.Show(); Logger.LogEntry("GAME", LogLevel.Info, "Game started"); Activate(); }
public ILogger CreateLogger(string categoryName) { ObservableLogger res; // get logger from dict or create a new one if (!_loggerDict.TryGetValue(categoryName, out res)) { res = new ObservableLogger(); CategoryNames.Add(categoryName); _loggerDict.TryAdd(categoryName, res); } res.Enabled = _isEnabled; return(res); }
public LogWindow(ObservableLogger logger) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } InitializeComponent(); LogDataGrid.ItemsSource = logger.LogEntryCollection; WindowState = WindowState.Maximized; var names = Enum.GetValues(typeof(LogLevel)).Cast <LogLevel>().Select(EnumHelper.LogLevelName).ToList(); LocalLogLevelComboBox.ItemsSource = names; LocalLogLevelComboBox.SelectedValue = EnumHelper.LogLevelName(Logger.Level); }
private void InitLoggers() { Logger.Level = LogLevel.Trace; var logDirectory = Environment.CurrentDirectory + "\\Log"; if (!Directory.Exists(logDirectory)) { Directory.CreateDirectory(logDirectory); } var logFile = logDirectory + $"\\{DateTime.Now:yyyy-MM-dd HH-mm-ss}.txt"; var fileLogger = new BufferedFileLogger(logFile); Logger.RegisterReceiver(fileLogger); _observableLogger = new ObservableLogger(1000, RunOnUiThreadAsync); Logger.RegisterReceiver(_observableLogger); Logger.RegisterReceiver(new DebugLogger()); }