public void OnUnhandledException(object sender, UnhandledExceptionEventArgs args) { Exception e = (Exception)args.ExceptionObject; LoggerFacade.Fatal("OnUnhandledException:" + e.Message); this.HandleException(sender, e, e.StackTrace); }
public PlayerVlcService() { var currentAssembly = Assembly.GetEntryAssembly(); try { if (currentAssembly != null) { var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName; if (currentDirectory == null) { return; } var vlcLibDirectory = new DirectoryInfo(Path.Combine(currentDirectory, @"lib\x86")); _vlcMediaPlayer = new VlcMediaPlayer(vlcLibDirectory); } else { throw new FileNotFoundException(Localization.strings.PlayerEngineNotFound); } } catch (Exception e) { LoggerFacade.WriteError(Localization.strings.PlayerNotLoaded, e, isShow: true); } _vlcMediaPlayer.EndReached += VlcMediaPlayer_OnEndReached; _vlcMediaPlayer.PositionChanged += VlcMediaPlayer_OnPositionChanged; _vlcMediaPlayer.LengthChanged += VlcMediaPlayer_OnLengthChanged; _vlcMediaPlayer.Stopped += VlcMediaPlayer_OnStopped; _vlcMediaPlayer.Paused += VlcMediaPlayer_OnPaused; _vlcMediaPlayer.Playing += VlcMediaPlayer_OnPlaying; }
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); } } }
public bool DoesMatch(string input) { double inputnum; double rulenum; if (!double.TryParse(input, out inputnum)) { LoggerFacade.Warn("Failed to convert input to number: " + input); return(false); } if (!double.TryParse(this.Content, out rulenum)) { LoggerFacade.Warn("Failed to convert rule content to number: " + this.Content); return(false); } bool result = this.Compare(inputnum, rulenum); if (this.Not) { return(!result); } else { return(result); } }
//Wrap a generic exception handler to get some useful information in the event of a //crash. public void Init(MainWindow ParentWindow, Arguments Arguments) { LoggerFacade.Trace("MainController initializing"); this._envController = new EnvironmentController(this); this._pages = new List <TsPage>(); this._linkinglibrary = new LinkingLibrary(); this._grouplibrary = new GroupLibrary(); this._toggles = new List <IToggleControl>(); this._optionlibrary = new OptionLibrary(); this._authlibrary = new AuthLibrary(); this._args = Arguments; this.ParentWindow = ParentWindow; this.ParentWindow.MouseLeftButtonUp += this.OnWindowMouseUp; this.ParentWindow.LocationChanged += this.OnWindowMoving; try { this.Startup(); } catch (TsGuiKnownException exc) { string msg = "Error message: " + exc.CustomMessage; this.CloseWithError("Application Startup Exception", msg); return; } catch (Exception exc) { string msg = "Error message: " + exc.Message + Environment.NewLine + exc.ToString(); this.CloseWithError("Application Startup Exception", msg); return; } }
public Startup( IConfiguration configuration) { Configuration = configuration; var loggerConfig = new LoggerConfig(); configuration.Bind("Logger", loggerConfig); loggerConfig.Db = new LoggerConfig.DbConfig { ConnectionString = configuration.GetConnectionString("Default"), AssembliesWithLogs = new[] { typeof(CommandsGateway).Assembly, typeof(IDatabaseAccessor).Assembly, typeof(ILogger).Assembly, typeof(Item).Assembly, typeof(IItemRepository).Assembly, typeof(AppGateway).Assembly, typeof(Startup).Assembly } }; LoggerFacade.Configure(loggerConfig); _logger = LoggerFacade.GetLogger(); }
private void ShowErrorMessageAndClose(string Message) { LoggerFacade.Fatal("Closing TsGui. Error message: " + Message); string msg = Message; Director.Instance.CloseWithError("Application Runtime Exception", msg); }
public void Start(TimeoutFunction timeoutfunction) { this._timeoutfunction = timeoutfunction; if (this.TimeoutElapsed != TimeSpan.MinValue) { if (this._resetonactivity) { Director.Instance.ParentWindow.MouseDown += this.ResetElapsed; Director.Instance.ParentWindow.KeyDown += this.ResetElapsed; } this.AfterTimer.Interval = TimeoutElapsed; this.AfterTimer.Tick += this.OnTimeoutReached; this._afterstarttime = DateTime.Now; this._afterendtime = this._afterstarttime + this.TimeoutElapsed; this.AfterTimer.Start(); LoggerFacade.Info("Timeout will occur in " + this.TimeoutElapsed.TotalMilliseconds + " milliseconds"); } if (this.TimeoutDateTime != DateTime.MaxValue) { //first check if the timeout datetime has already passed. if (this.TimeoutDateTime < DateTime.Now) { Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, new Action(() => this.OnTimeoutReached())); return; } this.ResetAtTimerBlock(this, new EventArgs()); } }
public ToolBarItem() { ToolbarClick = new DelegateCommand <ToolBarCommandParam>(new Action <ToolBarCommandParam>((o) => { try { if (toolBarItemEvent != null) { toolBarItemEvent(this, new ToolBarItemArg() { Index = this.index, OpenStyle = this.openStyle, OpenUri = this.openUri, IconUri = this.iconUri, Title = this.title }); } if (string.Equals(o.OpenStyle, "_blank")) { if (o.OpenUri != "") { MainPortal.PortalRegionManager.RequestNavigate("PopupWindow", new Uri(o.OpenUri, UriKind.Relative)); } } else { if (o.OpenUri != "") { MainPortal.PortalRegionManager.RequestNavigate("WindowAreaRoot", new Uri(o.OpenUri, UriKind.Relative)); } } } catch (Exception ex) { LoggerFacade.Error("Navigation exception!May be due to the configuration of the interface type not in the container."); } }), (o) => { return(true); }); }
public AuthState Authenticate() { if (string.IsNullOrEmpty(this.PasswordSource.Password) == true) { LoggerFacade.Warn("Cannot autheticate with empty password"); this.SetState(AuthState.NoPassword); this.AuthStateChanged?.Invoke(); return(AuthState.AccessDenied); } LoggerFacade.Info("Authenticating against local config with ID " + this.AuthID); AuthState newstate = AuthState.AccessDenied; foreach (Password pw in this._validpasswords) { if (pw.PasswordMatches(this.PasswordSource?.Password)) { newstate = AuthState.Authorised; LoggerFacade.Info("Authorised."); break; } } if (newstate != AuthState.Authorised) { LoggerFacade.Warn("Authentication failed"); } this.SetState(newstate); this.AuthStateChanged?.Invoke(); return(newstate); }
public void CtorShouldSetupValuResolverTimedWhenLoggerEnabledCacheTtlIsGreaterThenZero() { grinderContextMock.Setup(c => c.GetProperty(Constants.LoggerEnabledCacheTtlKey, "-1")).Returns("1"); var localLogger = new LoggerFacade(underlyingLoggerMock.Object, grinderContextMock.Object); AssertThatValueResolversAreOfType(localLogger, typeof(ValueResolverTimed <bool>)); }
protected void NotifyUpdate() { LoggerFacade.Info(this.VariableName + " variable value changed. New value: " + this.LiveValue); this.OnPropertyChanged(this, "CurrentValue"); this.OnPropertyChanged(this, "LiveValue"); this.ValueChanged?.Invoke(); }
protected override IUnityContainer CreateContainer() { LoggerFacade.Log(@"Creating the Unity Dependency Injection container and binding (bi-directionally) with the default MEF composition catalog (i.e. Tobi.exe, for the empty shell window)", Category.Debug, Priority.Low); // MEF will scan Tobi.exe only to start with, // so that the shell window doesn't attempt to load dependencies immediately but in a differed manner // (through a container re-composition when we add further MEF discovery catalogs) var aggregateCatalog = new AggregateCatalog(new ComposablePartCatalog[] { new AssemblyCatalog(Assembly.GetExecutingAssembly()), //new AssemblyCatalog(this.GetType().Assembly), //new AssemblyCatalog(typeof(Shell).Assembly), //new TypeCatalog(typeof(typeX)) //new TypeCatalog(typeof(type1), typeof(type2), ...) }); // This instance, once returned to this method, will be available as the "Container" class member (property), // and it will be registered within the Unity dependency injection container itself. var unityContainer = new UnityContainer(); // Bidirectional binding between MEF and Unity. // Remark: calls MEF-Compose, which triggers application Parts scanning // (building the graph of dependencies, and pruning branches that are rejected), // but the OnImportsSatisfied callbacks will only be activated at instanciation time. MefContainer = unityContainer.RegisterFallbackCatalog(aggregateCatalog); return(unityContainer); }
private void ApplicationStopped() { AppGateway.Dispose(); _logger.Log(new WebStoppedLog()); LoggerFacade.CloseAndFlush(); }
//Navigate to the current page, and update the datacontext of the window private void UpdateWindow() { LoggerFacade.Trace("UpdateWindow called"); this.ParentWindow.ContentArea.Navigate(this.CurrentPage.Page); this.ParentWindow.ContentArea.DataContext = this.CurrentPage; this.CurrentPage.Update(); }
//get a value from WMI public static string GetWmiString(string NameSpace, string WmiQuery) { string s = null; try { using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(NameSpace, WmiQuery)) { foreach (ManagementObject m in searcher.Get()) { foreach (PropertyData propdata in m.Properties) { s = s + propdata.Value; } } } if (String.IsNullOrEmpty(s)) { return(null); } else { return(s); } } catch { LoggerFacade.Error("Error running query against namespace " + NameSpace + ": " + WmiQuery); return(null); } }
public static UserControl GetSymbol(string type) { if (type == null) { throw new ArgumentException("Missing Type attribute on Symbol"); } LoggerFacade.Info("Creating symbol, type: " + type); if (type == "OuUI") { return(new TsFolderUI()); } else if (type == "Cross") { return(new TsCrossUI()); } else if (type == "Tick") { return(new TsTickUI()); } else if (type == "Warn") { return(new TsWarnUI()); } else if (type == "TrafficLight") { return(new TsTrafficLightUI()); } else { return(null); } }
public List <ViewBangThuTienRow> EvaluateViewBangThuTienRowsForReport(List <ViewBangThuTienRow> viewBangThuTienRows, DateTime toDate) { HashSet <int> hocSinhIds = new HashSet <int>(); foreach (ViewBangThuTienRow viewBangThuTienRow in viewBangThuTienRows) { if (!hocSinhIds.Contains(viewBangThuTienRow.HocSinhId)) { hocSinhIds.Add(viewBangThuTienRow.HocSinhId); } } LoggerFacade.Info(string.Format("EvaluateViewBangThuTienRowsForReport for list HocSinhIds=[{0}]", StringUtil.JoinWithCommas(hocSinhIds.ToList()))); HocSinhLopTableAdapter hocSinhLopTableAdapter = (HocSinhLopTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterHocSinhLop); Dictionary <int, QLMamNon.Dao.QLMamNonDs.LopRow> hocSinhIdsToLopNames = StaticDataUtil.GetLopsByHocSinhIds(hocSinhIds.ToList(), toDate); HocSinhDataTable hocSinhDataTable = this.getHocSinhData(); foreach (ViewBangThuTienRow viewBangThuTienRow in viewBangThuTienRows) { viewBangThuTienRow.HoTen = StaticDataUtil.GetHocSinhFullNameByHocSinhId(hocSinhDataTable, viewBangThuTienRow.HocSinhId); if (hocSinhIdsToLopNames.ContainsKey(viewBangThuTienRow.HocSinhId)) { viewBangThuTienRow.Lop = hocSinhIdsToLopNames[viewBangThuTienRow.HocSinhId].Name; } } return(viewBangThuTienRows); }
public void fire(string objectId, object value, ActivityType activityType) { if (activityType == ActivityType.TextChanged) { LoggerFacade.Info(string.Format("Text changed {0} {1}", objectId, value)); } }
public MainViewModel(Dispatcher dispatcher) { StopThreads = false; Dispatcher = dispatcher; InitializeLogging(true); Title = "OpenLogger Sample MVVM"; LoggerFacade.LogVerbose("Set Title: " + Title); StartLoggingCommand = new RelayCommand(StartLogging, CanStartLogging); StopLoggingCommand = new RelayCommand(StopLogging, CanStopLogging); ExitAppCommand = new RelayCommand(ExitApp); TabItems = new ObservableCollection <CustomTabItem> { new CustomTabItem { Title = "All Logs", Content = GetMasterLoggingView() }, new CustomTabItem { Title = "Tab 1", Content = GetLoggingView() }, new CustomTabItem { Title = "Tab 2", Content = GetLoggingView() } }; }
private static void AssertThatValueResolversAreOfType(LoggerFacade logger, Type valueResolverType) { Assert.That(logger.IsErrorEnabledResolver, Is.InstanceOf(valueResolverType)); Assert.That(logger.IsWarnEnabledResolver, Is.InstanceOf(valueResolverType)); Assert.That(logger.IsInfoEnabledResolver, Is.InstanceOf(valueResolverType)); Assert.That(logger.IsDebugEnabledResolver, Is.InstanceOf(valueResolverType)); Assert.That(logger.IsTraceEnabledResolver, Is.InstanceOf(valueResolverType)); }
public override bool HandleException(System.Exception exception) { ILoggerFacade logger = new LoggerFacade(); logger.Error("Data access exception", exception); throw exception; return(true); }
protected void InitializeLogging(bool isNewGroup, string origin) { LoggerFacade = new LoggerFacade(Logger.Instance, origin); if (isNewGroup) { LoggerFacade.GroupId = LoggerFacade.GetNewGroupId(); } }
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(); }
public void InstallServices(IServiceCollection services, IConfiguration configuration) { var logger = new LoggerFacade <DiagnosticLogger>(new LoggerSettings { LogLevel = LogLevel.Debug | LogLevel.Error | LogLevel.Fatal | LogLevel.Info | LogLevel.Warn, DefaultLogStrategy = new ConsoleLogStrategy() }); services.AddSingleton <ILogger>(logger); }
static void LogThread() { var logger = new LoggerFacade(Logger.Instance, "Thread Id: " + Thread.CurrentThread.ManagedThreadId); while (true) { logger.LogVerbose("Hello World!"); Thread.Sleep(500); } }
public void Stop() { try { _vlcMediaPlayer.Pause(); } catch (Exception e) { LoggerFacade.WriteError(e); } }
public void Play(Uri playPathUri) { try { _vlcMediaPlayer.Play(playPathUri.AbsoluteUri); } catch (Exception e) { LoggerFacade.WriteError(e); } }
public void SetPosition(float position) { try { _vlcMediaPlayer.Position = position; } catch (Exception e) { LoggerFacade.WriteError(e); } }
public void AddVariable(TsVariable Variable) { LoggerFacade.Info("Applying TS variable: " + Variable.Name + ". Value: " + Variable.Value); try { objTSEnv.Value[Variable.Name] = Variable.Value; } catch (Exception e) { throw new TsGuiKnownException("There was a fatal error while applying TS variable: " + Variable.Name, e.Message); } }