fix: logs
This commit is contained in:
parent
8fd4a3633f
commit
3a1497cdf5
@ -108,7 +108,7 @@ namespace YTExtractor.Logging.Configuration
|
|||||||
Console.WriteLine($"🌐 Conectividade com Seq OK: {seqUrl}");
|
Console.WriteLine($"🌐 Conectividade com Seq OK: {seqUrl}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($"⚠️ Seq configurado mas pode não estar respondendo: {response.StatusCode}");
|
Console.WriteLine($"⚠️ Seq configurado mas pode não estar respondendo: {response.StatusCode}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,27 +119,4 @@ namespace YTExtractor.Logging.Configuration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static class SerilogConfiguration
|
|
||||||
//{
|
|
||||||
// public static LoggerConfiguration SetLoggerConfiguration(this WebApplicationBuilder builder, LoggerConfiguration config, IServiceProvider services, IConfiguration configuration)
|
|
||||||
// {
|
|
||||||
// var workspace = configuration["Serilog:Properties:Workspace"];
|
|
||||||
// var seqServer = configuration.GetValue<string>("Serilog:WriteTo:2:Args:serverUrl"); ;
|
|
||||||
|
|
||||||
// config
|
|
||||||
// .ReadFrom.Configuration(configuration)
|
|
||||||
// .ReadFrom.Services(services)
|
|
||||||
// .Enrich.FromLogContext()
|
|
||||||
// .Enrich.WithEnvironmentName()
|
|
||||||
// //.Enrich.WithMachineName()
|
|
||||||
// .Enrich.WithProperty("Application", "SumaTube")
|
|
||||||
// .Enrich.WithProperty("Workspace", workspace)
|
|
||||||
// .WriteTo.Seq(seqServer)
|
|
||||||
// ;
|
|
||||||
|
|
||||||
// return config;
|
|
||||||
// }
|
|
||||||
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,9 +42,11 @@ app.MapPost("/api/video-info", async (VideoRequest request, MongoDBConnector mon
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Log.Information("Requisição recebida");
|
||||||
if (!youtubeService.IsValidYouTubeUrl(request.Url))
|
if (!youtubeService.IsValidYouTubeUrl(request.Url))
|
||||||
return Results.BadRequest("Invalid YouTube URL");
|
return Results.BadRequest("Invalid YouTube URL");
|
||||||
|
|
||||||
|
Log.Information("Obtendo pasta atual");
|
||||||
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||||
Directory.CreateDirectory(tempDir);
|
Directory.CreateDirectory(tempDir);
|
||||||
|
|
||||||
@ -52,9 +54,11 @@ app.MapPost("/api/video-info", async (VideoRequest request, MongoDBConnector mon
|
|||||||
{
|
{
|
||||||
Log.Information($"Obtendo dados do video: {request.Url}");
|
Log.Information($"Obtendo dados do video: {request.Url}");
|
||||||
var service = new ConvertTranscriptService();
|
var service = new ConvertTranscriptService();
|
||||||
|
Log.Information("Obtendo dados da url no mongo");
|
||||||
var videoExists = await mongo.GetVideoByUrl(request.Url);
|
var videoExists = await mongo.GetVideoByUrl(request.Url);
|
||||||
if (videoExists != null)
|
if (videoExists != null)
|
||||||
{
|
{
|
||||||
|
Log.Information($"Retorno via mongo db da url: {request.Url}");
|
||||||
return Results.Ok(new VideoInfo(
|
return Results.Ok(new VideoInfo(
|
||||||
videoExists.Url,
|
videoExists.Url,
|
||||||
videoExists.Titulo,
|
videoExists.Titulo,
|
||||||
@ -63,9 +67,11 @@ app.MapPost("/api/video-info", async (VideoRequest request, MongoDBConnector mon
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.Information("Obtendo dados da url na api do youtube");
|
||||||
var info = await youtubeService.GetVideoInfo(request.Url, tempDir);
|
var info = await youtubeService.GetVideoInfo(request.Url, tempDir);
|
||||||
var subtitles = service.ExtractPlainText(await youtubeService.GetSubtitles(request.Url, request.Language, tempDir));
|
var subtitles = service.ExtractPlainText(await youtubeService.GetSubtitles(request.Url, request.Language, tempDir));
|
||||||
|
|
||||||
|
Log.Information("Guardar no mongodb");
|
||||||
await mongo.InsertVideo(new VideoData
|
await mongo.InsertVideo(new VideoData
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid().ToString(),
|
Id = Guid.NewGuid().ToString(),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user