diff --git a/src/BreCalClient/App.config b/src/BreCalClient/App.config index 8ff9c1b..954decf 100644 --- a/src/BreCalClient/App.config +++ b/src/BreCalClient/App.config @@ -9,10 +9,11 @@
- + + @@ -25,6 +26,28 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/src/BreCalClient/App.xaml.cs b/src/BreCalClient/App.xaml.cs index c4407b8..e70d52c 100644 --- a/src/BreCalClient/App.xaml.cs +++ b/src/BreCalClient/App.xaml.cs @@ -18,8 +18,11 @@ namespace BreCalClient private void Application_Startup(object sender, StartupEventArgs e) { + // Configure the logger + log4net.Config.XmlConfigurator.Configure(); + // Window size sanity check - if(Settings.Default.Width == 0) + if (Settings.Default.Width == 0) { Settings.Default.Width = 800; Settings.Default.Save(); diff --git a/src/BreCalClient/AppNotification.cs b/src/BreCalClient/AppNotification.cs index 7db4d5c..637d2e5 100644 --- a/src/BreCalClient/AppNotification.cs +++ b/src/BreCalClient/AppNotification.cs @@ -120,7 +120,7 @@ namespace BreCalClient if (!_notificationsCollection.Where(x => x.Id == notification.Id).Any()) { - List newList = new(_notificationsCollection); + List newList = [.. _notificationsCollection]; AppNotification ap = new(notification.Id) { diff --git a/src/BreCalClient/BreCalClient.csproj b/src/BreCalClient/BreCalClient.csproj index addb077..e1a86f9 100644 --- a/src/BreCalClient/BreCalClient.csproj +++ b/src/BreCalClient/BreCalClient.csproj @@ -118,12 +118,13 @@ - + - + + - - + + diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs index ed94257..4046013 100644 --- a/src/BreCalClient/MainWindow.xaml.cs +++ b/src/BreCalClient/MainWindow.xaml.cs @@ -141,6 +141,7 @@ namespace BreCalClient private void Window_Loaded(object sender, RoutedEventArgs e) { + _log.Info("Client startup"); labelGeneralStatus.Text = $"Connection {ConnectionStatus.UNDEFINED}"; labelVersion.Text = "V. " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; if (!string.IsNullOrEmpty(Properties.Settings.Default.APP_TITLE)) @@ -157,6 +158,7 @@ namespace BreCalClient private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { + _log.Info("Client closing"); // serialize filter settings Properties.Settings.Default.FilterCriteriaMap = SearchFilterModel.Serialize(); Properties.Settings.Default.Save(); diff --git a/src/BreCalClient/ShipcallControl.xaml.cs b/src/BreCalClient/ShipcallControl.xaml.cs index 7e24700..c71f5fa 100644 --- a/src/BreCalClient/ShipcallControl.xaml.cs +++ b/src/BreCalClient/ShipcallControl.xaml.cs @@ -292,6 +292,7 @@ namespace BreCalClient if((this.ShipcallControlModel?.Shipcall?.Type == ShipcallType.Arrival) && (this.ShipcallControlModel?.Shipcall.TimeRefPoint != null)) { int timeRefPointIndex = this.ShipcallControlModel?.Shipcall?.TimeRefPoint ?? 0; + if (timeRefPointIndex < 0) timeRefPointIndex = 0; this.labelETAETDAgent.Content = BreCalLists.TimeRefs[timeRefPointIndex]; this.labelETAETDMooring.Content = BreCalLists.TimeRefs[timeRefPointIndex]; diff --git a/src/server/BreCal/__init__.py b/src/server/BreCal/__init__.py index 8924b11..be42b24 100644 --- a/src/server/BreCal/__init__.py +++ b/src/server/BreCal/__init__.py @@ -3,6 +3,9 @@ from flask import Flask import os import logging from . import local_db +import logging_loki +import logging.handlers +from multiprocessing import Queue from .api import shipcalls from .api import participant @@ -70,6 +73,16 @@ def create_app(test_config=None, instance_path=None): app.register_blueprint(ports.bp) logging.basicConfig(filename='brecaltest.log', level=logging.DEBUG, format='%(asctime)s | %(name)s | %(levelname)s | %(message)s') + handler = logging_loki.LokiQueueHandler( + Queue(-1), + url="http://loki.fritz.box:3100/loki/api/v1/push", + tags={"application": "brecal"}, + version="1", + ) + logger = logging.getLogger() + logger.setLevel(logging.INFO) + logger.addHandler(handler) + local_db.initPool(os.path.dirname(app.instance_path)) logging.info('App started') diff --git a/src/server/BreCal/local_db.py b/src/server/BreCal/local_db.py index 3c7b936..d610e02 100644 --- a/src/server/BreCal/local_db.py +++ b/src/server/BreCal/local_db.py @@ -13,7 +13,7 @@ def initPool(instancePath, connection_filename="connection_data_test.json"): if(config_path == None): config_path = os.path.join(instancePath,f'../../../secure/{connection_filename}') #connection_data_test.json'); - # config_path = "E:/temp/connection_data.json" + config_path = "E:/temp/connection_data.json" print (config_path) if not os.path.exists(config_path): @@ -35,7 +35,7 @@ def initPool(instancePath, connection_filename="connection_data_test.json"): credentials_file = "email_credentials_test.json" credentials_path = os.path.join(instancePath,f'../../../secure/{credentials_file}') - # credentials_path = "E:/temp/email_credentials_devel.json" + credentials_path = "E:/temp/email_credentials_devel.json" if not os.path.exists(credentials_path): print ('cannot find ' + os.path.abspath(credentials_path))