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 -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;