Esempio n. 1
0
        private void ShowErrorMessageAndClose(string Message)
        {
            LoggerFacade.Fatal("Closing TsGui. Error message: " + Message);
            string msg = Message;

            Director.Instance.CloseWithError("Application Runtime Exception", msg);
        }
Esempio n. 2
0
        public void OnUnhandledException(object sender, UnhandledExceptionEventArgs args)
        {
            Exception e = (Exception)args.ExceptionObject;

            LoggerFacade.Fatal("OnUnhandledException:" + e.Message);
            this.HandleException(sender, e, e.StackTrace);
        }
Esempio n. 3
0
        void ShouldNotLogEverything()
        {
            // Arrange
            var logStrategy = new Mock <ILogStrategy>();

            logStrategy.Setup(x => x.WriteMessage(It.IsAny <string>())).Verifiable();
            var shouldLog = LogLevel.Fatal | LogLevel.Info | LogLevel.Warn;
            var logger    = new LoggerFacade <RawLogger>(new LoggerSettings
            {
                LogLevel           = shouldLog,
                DefaultLogStrategy = logStrategy.Object
            });

            // Act
            logger.Debug("debug");
            logger.Error("error");
            logger.Fatal("fatal");
            logger.Info("info;");
            logger.Warn("warm;");

            // Assert
            logStrategy.Verify(x => x.WriteMessage(It.IsAny <string>()), Times.Exactly(3));


            foreach (var logLevel in Enum.GetValues(typeof(LogLevel)))
            {
                var logLevelEnum = (LogLevel)logLevel;
                if ((logLevelEnum & shouldLog) != LogLevel.None)
                {
                    logStrategy.Verify(x => x.WriteMessage(It.Is <string>(s => s.Contains($"{logLevelEnum}"))), Times.Once);
                }
            }
        }
Esempio n. 4
0
 public void CloseWithError(string Title, string Message)
 {
     LoggerFacade.Fatal("TsGui closing due to error: " + Title);
     LoggerFacade.Fatal("Error message: " + Message);
     MessageBox.Show(Message, Title, MessageBoxButton.OK, MessageBoxImage.Error);
     this.ParentWindow.Closing -= this.OnWindowClosing;
     this.ParentWindow.Close();
 }
Esempio n. 5
0
 //Exception handler methods
 #region
 public void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs args)
 {
     args.Handled = true;
     if (args.Exception is System.IO.FileNotFoundException)
     {
         LoggerFacade.Error("System.IO.FileNotFoundException logged. This is a known issue with DragDrop");
     }
     else
     {
         LoggerFacade.Fatal("OnDispatcherUnhandledException:" + args.Exception.ToString());
         LoggerFacade.Fatal("OnDispatcherUnhandledException:" + args.Exception.Message);
         this.HandleException(sender, args.Exception, args.Exception.StackTrace);
     }
 }