fixed console Log

fix same files problem in python different libs
correct command logging in command handler
This commit is contained in:
Alex Bezdieniezhnykh
2025-06-14 21:01:32 +03:00
parent 09cfcdf61a
commit c0f8dd792d
29 changed files with 74 additions and 87 deletions
-4
View File
@@ -99,10 +99,6 @@ public class CanvasEditor : Canvas
Fill = new SolidColorBrush(Color.FromArgb(128, 128, 128, 128)),
};
KeyDown += (_, args) =>
{
Console.WriteLine($"pressed {args.Key}");
};
MouseDown += CanvasMouseDown;
MouseMove += CanvasMouseMove;
MouseUp += CanvasMouseUp;
+2 -1
View File
@@ -9,6 +9,7 @@ using LinqToDB.Mapping;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Serilog;
namespace Azaion.Common.Database;
@@ -138,7 +139,7 @@ public class DbFactory : IDbFactory
{
var detDeleted = await db.Detections.DeleteAsync(x => annotationNames.Contains(x.AnnotationName), token: cancellationToken);
var annDeleted = await db.Annotations.DeleteAsync(x => annotationNames.Contains(x.Name), token: cancellationToken);
Console.WriteLine($"Deleted {detDeleted} detections, {annDeleted} annotations");
_logger.LogInformation($"Deleted {detDeleted} detections, {annDeleted} annotations");
});
}
}
+1 -2
View File
@@ -4,8 +4,7 @@ public static class ResilienceExt
{
public static void WithRetry(this Action operation, int retryCount = 3, int delayMs = 150) =>
Policy.Handle<Exception>()
.WaitAndRetry(retryCount, num => TimeSpan.FromMilliseconds(num * delayMs),
(exception, timeSpan) => Console.WriteLine($"Exception: {exception}, TimeSpan: {timeSpan}"))
.WaitAndRetry(retryCount, num => TimeSpan.FromMilliseconds(num * delayMs))
.Execute(operation);
public static TResult WithRetry<TResult>(this Func<TResult> operation, int retryCount = 3, int delayMs = 150) =>
+3 -2
View File
@@ -1,6 +1,7 @@
using System.IO;
using Azaion.Common.DTO;
using Newtonsoft.Json;
using Serilog;
namespace Azaion.Common;
@@ -59,7 +60,7 @@ public class SecurityConstants
};
#endregion ExternalClientsConfig
public static InitConfig ReadInitConfig()
public static InitConfig ReadInitConfig(ILogger logger)
{
try
{
@@ -72,7 +73,7 @@ public class SecurityConstants
}
catch (Exception e)
{
Console.WriteLine(e);
logger.Error(e, e.Message);
return DefaultInitConfig;
}
}
+4 -2
View File
@@ -4,7 +4,9 @@ using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using Azaion.Common.DTO;
using Newtonsoft.Json;
using Serilog;
namespace Azaion.Common.Services;
@@ -16,7 +18,7 @@ public interface IAzaionApi
//Stream GetResource(string filename, string folder);
}
public class AzaionApi(HttpClient client, ICache cache, ApiCredentials credentials) : IAzaionApi
public class AzaionApi(ILogger logger, HttpClient client, ICache cache, ApiCredentials credentials) : IAzaionApi
{
private string _jwtToken = null!;
const string APP_JSON = "application/json";
@@ -116,7 +118,7 @@ public class AzaionApi(HttpClient client, ICache cache, ApiCredentials credentia
}
catch (Exception e)
{
Console.WriteLine(e);
logger.Error(e, e.Message);
throw;
}
}
+2 -2
View File
@@ -149,7 +149,7 @@ public class GalleryService(
if (!existingAnnotations.ContainsKey(fName))
{
if (missedAnnotations.ContainsKey(fName))
Console.WriteLine($"{fName} is already exists! Duplicate!");
logger.LogInformation($"{fName} is already exists! Duplicate!");
else
missedAnnotations.TryAdd(fName, annotation);
}
@@ -168,7 +168,7 @@ public class GalleryService(
{
ProgressFn = async num =>
{
Console.WriteLine($"Processed {num} item by Thread {Environment.CurrentManagedThreadId}");
logger.LogInformation($"Processed {num} item by Thread {Environment.CurrentManagedThreadId}");
ProcessedThumbnailsPercentage = imagesCount == 0 ? 0 : Math.Min(100, num * 100 / (double)imagesCount);
ThumbnailsUpdate?.Invoke(ProcessedThumbnailsPercentage);
await Task.CompletedTask;
+2 -5
View File
@@ -54,15 +54,12 @@ public class GpsMatcherClient : IGpsMatcherClient
WorkingDirectory = SecurityConstants.EXTERNAL_GPS_DENIED_FOLDER,
CreateNoWindow = true
};
process.OutputDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); };
process.ErrorDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); };
process.Start();
}
catch (Exception e)
{
Console.WriteLine(e);
//throw;
_logger.LogError(e, e.ToString());
throw;
}
_requestAddress = $"tcp://{gpsConfig.Value.ZeroMqHost}:{gpsConfig.Value.ZeroMqPort}";
+6 -6
View File
@@ -2,6 +2,7 @@
using System.Text;
using Azaion.Common.DTO;
using MessagePack;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NetMQ;
using NetMQ.Sockets;
@@ -18,6 +19,7 @@ public interface IInferenceClient : IDisposable
public class InferenceClient : IInferenceClient
{
private readonly ILogger<InferenceClient> _logger;
public event EventHandler<RemoteCommand>? BytesReceived;
public event EventHandler<RemoteCommand>? InferenceDataReceived;
public event EventHandler<RemoteCommand>? AIAvailabilityReceived;
@@ -28,8 +30,9 @@ public class InferenceClient : IInferenceClient
private readonly InferenceClientConfig _inferenceClientConfig;
private readonly LoaderClientConfig _loaderClientConfig;
public InferenceClient(IOptions<InferenceClientConfig> inferenceConfig, IOptions<LoaderClientConfig> loaderConfig)
public InferenceClient(ILogger<InferenceClient> logger, IOptions<InferenceClientConfig> inferenceConfig, IOptions<LoaderClientConfig> loaderConfig)
{
_logger = logger;
_inferenceClientConfig = inferenceConfig.Value;
_loaderClientConfig = loaderConfig.Value;
Start();
@@ -46,15 +49,12 @@ public class InferenceClient : IInferenceClient
Arguments = $"-p {_inferenceClientConfig.ZeroMqPort} -lp {_loaderClientConfig.ZeroMqPort} -a {_inferenceClientConfig.ApiUrl}",
CreateNoWindow = true
};
process.OutputDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); };
process.ErrorDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); };
process.Start();
}
catch (Exception e)
{
Console.WriteLine(e);
//throw;
_logger.LogError(e, e.Message);
throw;
}
_dealer.Options.Identity = Encoding.UTF8.GetBytes(_clientId.ToString("N"));
+1 -10
View File
@@ -26,20 +26,11 @@ public class LoaderClient(LoaderClientConfig config, ILogger logger, Cancellatio
Arguments = $"--port {config.ZeroMqPort} --api {config.ApiUrl}",
CreateNoWindow = true
};
process.OutputDataReceived += (_, e) =>
{
if (e.Data != null) Console.WriteLine(e.Data);
};
process.ErrorDataReceived += (_, e) =>
{
if (e.Data != null) Console.WriteLine(e.Data);
};
process.Start();
}
catch (Exception e)
{
logger.Error(e.Message);
logger.Error(e, e.Message);
throw;
}
}
@@ -146,7 +146,7 @@ public class SatelliteDownloader(
}
catch (Exception)
{
Console.WriteLine($"Error while loading tile: {tileData}");
logger.LogError($"Error while loading tile: {tileData}");
}
if (token.IsCancellationRequested)
return;